From 2c6f74a800748f0223a134ec4b6ce1489351c1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mon=20S?= <6475387+Coffee2CodeNL@users.noreply.github.com> Date: Wed, 27 Mar 2019 10:38:16 +0100 Subject: [PATCH] Release v0.0.5 (#18) * Update README.md to reflect version bump * Update to README.md, new shields Added AUR Package shield Changed gitter.im shield * Added support for oblique gesture swipes. To add the support the config class was modified to include the new gestures types: left_up, right_up, left_down, right_down. Also changed the way the commands are saved in the config class, so there won't be a need for a lot of if statements to handle 4 finger swipes and 3 finger swipes. Finally, the handle_swipe_event_without_coords was modified to detect the oblique swipes. * Commenting the code a bit and some minor cosmetic and semantic changes - Added comments to each function - Increased string array size to 10 in config.h even though we only need 9 slots, I'm being a bit pedantic about this - Adding some build flags to CMakeLists.txt to show every error, preferably we'd get clean output eventually - Renamed find_gesture_device to gesture_device_exists in Input class - Renamed find_config_file to config_file_exists as this actually describes the logic of this function in Config class - Renamed find_home_folder to find_config_file in Config class in preparation to adding /etc/gebaar/gebaard.toml to list of possible config file locations * Prepare for release by bumping up version in README.md * Let warnings be warnings, release v0.0.4 * Goodbye Gitter, Hello Discord. * Fix config location (#13) If XDG_CONFIG_HOME is set, .config will be appended a second time resulting in /home/example/.config/.config/gebaar/gebaard.toml This is fixed by only appending .config, when the HOME directory workaround is used. Fixes #12 * Fix nullptr conversion to std::string (#16) Instead of using the result of getenv directly, we must check first, if getenv returned a nullptr, otherwise the program will crash. Regression from 41c7c05 * Add the build directory to gitignore (#15) The README build instructions use this directory. * Add a desktop file (#14) Users can copy this desktop file to $XDG_CONFIG_HOME/autostart to enable autostart on most desktop environments. --- .gitignore | 1 + CMakeLists.txt | 4 +++- README.md | 4 +++- gebaar-libinput.desktop | 8 ++++++++ src/config/config.cpp | 19 ++++++++++++------- src/util.cpp | 29 +++++++++++++++++++++++++++++ src/util.h | 28 ++++++++++++++++++++++++++++ 7 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 gebaar-libinput.desktop create mode 100644 src/util.cpp create mode 100644 src/util.h 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