diff --git a/.gitignore b/.gitignore index c24e01f..fda7434 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ cmake_install.cmake install_manifest.txt compile_commands.json CTestTestfile.cmake +/build/* ### C template # Prerequisites *.d diff --git a/CMakeLists.txt b/CMakeLists.txt index 9387fa3..9a1a83e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,9 @@ add_executable(gebaard src/config/config.cpp src/config/config.h src/daemonizer.cpp - src/daemonizer.h) + src/daemonizer.h + src/util.cpp + src/util.h) find_package(PkgConfig) if (PKG_CONFIG_FOUND) diff --git a/README.md b/README.md index 1da64a4..37bc4cc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ Gebaar ========= -[![](https://img.shields.io/gitter/room/gebaar-libinput/community.svg?style=flat)](https://gitter.im/gebaar-libinput/community) WM Independent Touchpad Gesture Daemon for libinput @@ -15,6 +14,9 @@ Run any command by simply gesturing on your touchpad! Gebaar directly interfaces with libinput to receive and react to the events. This is more stable, faster, and more efficient as it **does not parse the output of a program** like the aforementioned projects do. +### Getting support (or talking about the project's future) + +Click to join: [![Discord](https://img.shields.io/discord/548978799136473106.svg?label=Discord)](https://discord.gg/9mbKhFR) ### How to build and install diff --git a/gebaar-libinput.desktop b/gebaar-libinput.desktop new file mode 100644 index 0000000..4550187 --- /dev/null +++ b/gebaar-libinput.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=gebaar-libinput +Comment=Touchpad Gesture Daemon for libinput +Exec=/usr/bin/gebaard -b +StartupNotify=false +Terminal=false +Type=Application +X-GNOME-Autostart-enabled=true diff --git a/src/config/config.cpp b/src/config/config.cpp index 013ea41..7600f3c 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -19,6 +19,7 @@ #include #include "config.h" +#include "../util.h" /** * Check if config file exists at current path @@ -68,17 +69,21 @@ void gebaar::config::Config::load_config() */ bool gebaar::config::Config::find_config_file() { - const char* temp_path; - temp_path = getenv("XDG_CONFIG_HOME"); - if (temp_path==nullptr) { - temp_path = getenv("HOME"); - if (temp_path==nullptr) { + std::string temp_path = gebaar::util::stringFromCharArray(getenv("XDG_CONFIG_HOME")); + if (temp_path.empty()) { + // first get the path to HOME + temp_path = gebaar::util::stringFromCharArray(getenv("HOME")); + if (temp_path.empty()) { temp_path = getpwuid(getuid())->pw_dir; } + // then append .config + if (!temp_path.empty()) { + temp_path.append("/.config"); + } } - if (temp_path!=nullptr) { + if (!temp_path.empty()) { config_file_path = temp_path; - config_file_path.append("/.config/gebaar/gebaard.toml"); + config_file_path.append("/gebaar/gebaard.toml"); return true; } return false; diff --git a/src/util.cpp b/src/util.cpp new file mode 100644 index 0000000..a56dfe6 --- /dev/null +++ b/src/util.cpp @@ -0,0 +1,29 @@ +/* + gebaar + Copyright (C) 2019 coffee2code + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "util.h" + +/** + * @brief Safely converts a char array to a std::string + * @param charArr The char array to convert + * @return charArr or an empty string, if charArr is a nullptr + */ +std::string gebaar::util::stringFromCharArray(char* charArr) +{ + return charArr == nullptr ? "" : charArr; +} diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..eafec82 --- /dev/null +++ b/src/util.h @@ -0,0 +1,28 @@ +/* + gebaar + Copyright (C) 2019 coffee2code + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef UTIL_H +#define UTIL_H + +#include + +namespace gebaar::util { + std::string stringFromCharArray(char* charArr); +} + +#endif // UTIL_H