-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
First Release (v0.0.1) See merge request Coffee2Code/gebaar-libinput!1
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "libs/cxxopts"] | ||
path = libs/cxxopts | ||
url = [email protected]:jarro2783/cxxopts.git | ||
[submodule "libs/cpptoml"] | ||
path = libs/cpptoml | ||
url = [email protected]:skystrife/cpptoml.git |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include <zconf.h> | ||
#include "config.h" | ||
|
||
bool gebaar::config::Config::find_config_file() | ||
{ | ||
auto true_path = std::filesystem::path(config_file_path); | ||
return std::filesystem::exists(true_path); | ||
} | ||
|
||
void gebaar::config::Config::load_config() | ||
{ | ||
if (find_home_folder()) { | ||
if (find_config_file()) { | ||
config = cpptoml::parse_file(std::filesystem::path(config_file_path)); | ||
swipe_three_up_command = *config->get_qualified_as<std::string>("commands.swipe.three.up"); | ||
swipe_three_down_command = *config->get_qualified_as<std::string>("commands.swipe.three.down"); | ||
swipe_three_left_command = *config->get_qualified_as<std::string>("commands.swipe.three.left"); | ||
swipe_three_right_command = *config->get_qualified_as<std::string>("commands.swipe.three.right"); | ||
swipe_four_up_command = *config->get_qualified_as<std::string>("commands.swipe.four.up"); | ||
swipe_four_down_command = *config->get_qualified_as<std::string>("commands.swipe.four.down"); | ||
swipe_four_left_command = *config->get_qualified_as<std::string>("commands.swipe.four.left"); | ||
swipe_four_right_command = *config->get_qualified_as<std::string>("commands.swipe.four.right"); | ||
loaded = true; | ||
} | ||
} | ||
|
||
} | ||
|
||
bool gebaar::config::Config::find_home_folder() | ||
{ | ||
const char* temp_path; | ||
temp_path = getenv("XDG_CONFIG_HOME"); | ||
if (temp_path==nullptr) { | ||
temp_path = getenv("HOME"); | ||
if (temp_path==nullptr) { | ||
temp_path = getpwuid(getuid())->pw_dir; | ||
} | ||
} | ||
if (temp_path!=nullptr) { | ||
config_file_path = temp_path; | ||
config_file_path.append("/.config/gebaar/gebaard.toml"); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
gebaar::config::Config::Config() | ||
{ | ||
if (!loaded) { | ||
load_config(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef GEBAAR_CONFIG_H | ||
#define GEBAAR_CONFIG_H | ||
|
||
#include <cpptoml.h> | ||
#include <filesystem> | ||
#include <pwd.h> | ||
#include <iostream> | ||
|
||
namespace gebaar::config { | ||
class Config { | ||
public: | ||
Config(); | ||
|
||
bool loaded = false; | ||
|
||
void load_config(); | ||
|
||
std::string swipe_four_up_command; | ||
std::string swipe_four_down_command; | ||
std::string swipe_four_left_command; | ||
std::string swipe_four_right_command; | ||
std::string swipe_three_up_command; | ||
std::string swipe_three_down_command; | ||
std::string swipe_three_left_command; | ||
std::string swipe_three_right_command; | ||
private: | ||
bool find_config_file(); | ||
|
||
bool find_home_folder(); | ||
|
||
std::string config_file_path; | ||
std::shared_ptr<cpptoml::table> config; | ||
}; | ||
} | ||
#endif //GEBAAR_CONFIG_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include "daemonizer.h" | ||
|
||
|
||
bool gebaar::daemonizer::Daemonizer::daemonize() | ||
{ | ||
pid_t pid = 0; | ||
pid = fork(); | ||
if (pid<0) { | ||
exit(EXIT_FAILURE); | ||
} | ||
if (pid>0) { | ||
exit(EXIT_SUCCESS); | ||
} | ||
if (setsid()<0) { | ||
// Boo. | ||
} | ||
signal(SIGCHLD, SIG_IGN); | ||
signal(SIGTRAP, SIG_IGN); | ||
pid = fork(); | ||
if (pid<0) { | ||
exit(EXIT_FAILURE); | ||
} | ||
if (pid>0) { | ||
exit(EXIT_SUCCESS); | ||
} | ||
umask(0); | ||
if ((chdir("/"))<0) { | ||
return false; | ||
} | ||
close(STDOUT_FILENO); | ||
close(STDIN_FILENO); | ||
close(STDERR_FILENO); | ||
if (getpid()!=getsid(getpid())) { | ||
// | ||
} | ||
return true; | ||
|
||
} | ||
|
||
gebaar::daemonizer::Daemonizer::Daemonizer() = default; | ||
|
||
gebaar::daemonizer::Daemonizer::~Daemonizer() = default; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include <csignal> | ||
#include <unistd.h> | ||
#include <cstdlib> | ||
#include <sys/stat.h> | ||
|
||
#ifndef GEBAAR_DAEMONIZER_H | ||
#define GEBAAR_DAEMONIZER_H | ||
namespace gebaar::daemonizer { | ||
class Daemonizer { | ||
public: | ||
Daemonizer(); | ||
~Daemonizer(); | ||
bool daemonize(); | ||
}; | ||
} | ||
#endif //GEBAAR_DAEMONIZER_H |