Add logid service & install target
This commit is contained in:
parent
c2b5fceaf5
commit
b55db6777e
|
@ -7,8 +7,4 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Wall")
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_subdirectory(src/logid)
|
add_subdirectory(src/logid)
|
||||||
|
|
||||||
if(NOT EXISTS "${PROJECT_BINARY_DIR}/logid.cfg")
|
|
||||||
configure_file("logid.example.cfg" "logid.cfg" COPYONLY)
|
|
||||||
endif()
|
|
|
@ -22,7 +22,7 @@ cmake ..
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
Installation is currently not implemented.
|
To install, run `sudo make install` after building. You can set the daemon to start at boot by running `sudo systemctl start logid`.
|
||||||
|
|
||||||
## Compatible Devices
|
## Compatible Devices
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(logid)
|
project(logid)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
@ -25,8 +25,7 @@ add_executable(logid
|
||||||
set_target_properties(logid PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
set_target_properties(logid PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
|
|
||||||
pkg_check_modules(PC_EVDEV libevdev)
|
pkg_check_modules(PC_EVDEV libevdev)
|
||||||
pkg_check_modules(libhidpp REQUIRED)
|
pkg_check_modules(SYSTEMD "systemd")
|
||||||
pkg_check_modules(libconfig++ REQUIRED)
|
|
||||||
|
|
||||||
find_path(HIDPP_INCLUDE_DIR hidpp)
|
find_path(HIDPP_INCLUDE_DIR hidpp)
|
||||||
find_library(HIDPP_LIBRARY libhidpp.so)
|
find_library(HIDPP_LIBRARY libhidpp.so)
|
||||||
|
@ -39,3 +38,20 @@ find_library(EVDEV_LIBRARY
|
||||||
include_directories(${HIDPP_INCLUDE_DIR}/hidpp ${EVDEV_INCLUDE_DIR})
|
include_directories(${HIDPP_INCLUDE_DIR}/hidpp ${EVDEV_INCLUDE_DIR})
|
||||||
|
|
||||||
target_link_libraries(logid ${CMAKE_THREAD_LIBS_INIT} ${EVDEV_LIBRARY} config++ ${HIDPP_LIBRARY})
|
target_link_libraries(logid ${CMAKE_THREAD_LIBS_INIT} ${EVDEV_LIBRARY} config++ ${HIDPP_LIBRARY})
|
||||||
|
|
||||||
|
install(TARGETS logid DESTINATION bin)
|
||||||
|
|
||||||
|
if (SYSTEMD_FOUND AND "${SYSTEMD_SERVICES_INSTALL_DIR}" STREQUAL "")
|
||||||
|
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
|
||||||
|
--variable=systemdsystemunitdir systemd
|
||||||
|
OUTPUT_VARIABLE SYSTEMD_SERVICES_INSTALL_DIR)
|
||||||
|
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SERVICES_INSTALL_DIR
|
||||||
|
"${SYSTEMD_SERVICES_INSTALL_DIR}")
|
||||||
|
configure_file(logid.service.cmake ${CMAKE_BINARY_DIR}/logid.service)
|
||||||
|
message(STATUS "systemd units will be installed at ${SYSTEMD_SERVICES_INSTALL_DIR}")
|
||||||
|
install(FILES ${CMAKE_BINARY_DIR}/logid.service
|
||||||
|
DESTINATION ${SYSTEMD_SERVICES_INSTALL_DIR}
|
||||||
|
COMPONENT cp)
|
||||||
|
elseif(NOT SYSTEMD_FOUND AND SYSTEMD_SERVICES_INSTALL_DIR)
|
||||||
|
message(FATAL_ERROR "systemd is not found w/ pkg-config but SYSTEMD_SERVICES_INSTALL_DIR is defined.")
|
||||||
|
endif()
|
||||||
|
|
|
@ -21,7 +21,7 @@ Configuration::Configuration(const char *config_file)
|
||||||
}
|
}
|
||||||
catch(const FileIOException &e)
|
catch(const FileIOException &e)
|
||||||
{
|
{
|
||||||
log_printf(ERROR, "I/O Error while reading configuration file: %s", e.what());
|
log_printf(ERROR, "I/O Error while reading %s: %s", config_file, e.what());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
catch(const ParseException &e)
|
catch(const ParseException &e)
|
||||||
|
|
|
@ -27,6 +27,7 @@ class Configuration
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Configuration(const char* config_file);
|
Configuration(const char* config_file);
|
||||||
|
Configuration() {}
|
||||||
std::map<std::string, DeviceConfig*> devices;
|
std::map<std::string, DeviceConfig*> devices;
|
||||||
private:
|
private:
|
||||||
libconfig::Config cfg;
|
libconfig::Config cfg;
|
||||||
|
|
|
@ -115,6 +115,7 @@ void DeviceFinder::addDevice(const char *path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(HIDPP::Dispatcher::NoHIDPPReportException &e) { }
|
||||||
catch(std::system_error &e) { log_printf(WARN, "Failed to open %s: %s", string_path.c_str(), e.what()); }
|
catch(std::system_error &e) { log_printf(WARN, "Failed to open %s: %s", string_path.c_str(), e.what()); }
|
||||||
|
|
||||||
for(auto dev : _devs)
|
for(auto dev : _devs)
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "DeviceFinder.h"
|
#include "DeviceFinder.h"
|
||||||
|
|
||||||
#define evdev_name "logid"
|
#define evdev_name "logid"
|
||||||
|
#define DEFAULT_CONFIG_FILE "/etc/logid.cfg"
|
||||||
|
|
||||||
LogLevel global_verbosity = INFO;
|
LogLevel global_verbosity = INFO;
|
||||||
Configuration* global_config;
|
Configuration* global_config;
|
||||||
|
@ -33,7 +34,7 @@ enum class Option
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
char* config_file = "/etc/logid.cfg";
|
std::string config_file = DEFAULT_CONFIG_FILE;
|
||||||
for(int i = 1; i < argc; i++)
|
for(int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
Option option = Option::None;
|
Option option = Option::None;
|
||||||
|
@ -101,7 +102,7 @@ Possible options are:
|
||||||
-v,--verbose [level] Set log level to debug/info/warn/error (leave blank for debug)
|
-v,--verbose [level] Set log level to debug/info/warn/error (leave blank for debug)
|
||||||
-c,--config [file path] Change config file from default at %s
|
-c,--config [file path] Change config file from default at %s
|
||||||
-h,--help Print this message.
|
-h,--help Print this message.
|
||||||
)", argv[0], config_file);
|
)", argv[0], DEFAULT_CONFIG_FILE);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
case Option::None:
|
case Option::None:
|
||||||
|
@ -111,8 +112,8 @@ Possible options are:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read config
|
// Read config
|
||||||
try { global_config = new Configuration(config_file); }
|
try { global_config = new Configuration(config_file.c_str()); }
|
||||||
catch (std::exception &e) { return EXIT_FAILURE; }
|
catch (std::exception &e) { global_config = new Configuration(); }
|
||||||
|
|
||||||
//Create an evdev device called 'logid'
|
//Create an evdev device called 'logid'
|
||||||
try { global_evdev = new EvdevDevice(evdev_name); }
|
try { global_evdev = new EvdevDevice(evdev_name); }
|
||||||
|
|
11
src/logid/logid.service.cmake
Normal file
11
src/logid/logid.service.cmake
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Logitech Configuration Daemon
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=${CMAKE_INSTALL_PREFIX}/bin/logid
|
||||||
|
User=root
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user