diff --git a/comfortable-swipe.compile.sh b/comfortable-swipe.compile.sh deleted file mode 100755 index 2425f6d..0000000 --- a/comfortable-swipe.compile.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -dir="$(dirname $0)" -g++ "$dir/comfortable-swipe.cpp" \ - -o "$1" \ - -std=c++11 \ - -O2 -lxdo -Wno-unused-result \ - -DCOMFORTABLE_SWIPE_VERSION="\"$(cat $dir/VERSION | tr -d '[:space:]')\"" diff --git a/lib/index.hpp b/comfortable_swipe/all_headers.hpp similarity index 77% rename from lib/index.hpp rename to comfortable_swipe/all_headers.hpp index 3ce48a6..e761da0 100644 --- a/lib/index.hpp +++ b/comfortable_swipe/all_headers.hpp @@ -1,5 +1,12 @@ -#ifndef __COMFORTABLE_SWIPE__index_hpp__ -#define __COMFORTABLE_SWIPE__index_hpp__ +/** + * Add header files will be imported here. + * You can import this as a shorthand: + * + * #include "../all_headers.hpp" + */ + +#ifndef __COMFORTABLE_SWIPE__all_headers_hpp__ +#define __COMFORTABLE_SWIPE__all_headers_hpp__ /* Comfortable Swipe @@ -36,21 +43,20 @@ along with this program. If not, see . #include // std::map #include // std::string -/** - * Make sure to include your header files here so that they can be imported by other modules. - */ -#include "gesture/xdo_gesture.h" -#include "gesture/swipe_gesture.h" extern "C" { namespace comfortable_swipe { + // driver method + int driver(); + // this is found in the util/ folder namespace util { const char* autostart_filename(); constexpr const char* conf_filename(); std::map read_config_file(const char*); } + // this is found in the service/ folder namespace service { void autostart(); @@ -66,4 +72,10 @@ extern "C" } } -#endif /* __COMFORTABLE_SWIPE__index_hpp__ */ +// add headers for classes here so it can be imported during include +#include "gesture/xdo_gesture.h" +#include "gesture/swipe_gesture.h" +#include "gesture/keyboard_swipe_gesture.h" +#include "gesture/mouse_hold_gesture.h" + +#endif /* __COMFORTABLE_SWIPE__all_headers_hpp__ */ diff --git a/lib/service/buffer.cpp b/comfortable_swipe/driver.cpp similarity index 73% rename from lib/service/buffer.cpp rename to comfortable_swipe/driver.cpp index ed76b1d..22b6d69 100644 --- a/lib/service/buffer.cpp +++ b/comfortable_swipe/driver.cpp @@ -1,5 +1,5 @@ -#ifndef __COMFORTABLE_SWIPE__service_buffer__ -#define __COMFORTABLE_SWIPE__service_buffer__ +#ifndef __COMFORTABLE_SWIPE__driver__ +#define __COMFORTABLE_SWIPE__driver__ /* Comfortable Swipe @@ -21,15 +21,16 @@ along with this program. If not, see . #include // fgets_unlocked, stdin #include // std::ios, std::cout, std::cin -#include "../index.hpp" +#include "all_headers.hpp" /** - * Starts the comfortable-swipe service by buffering libinput debug-events. + * The main driver program. */ -namespace comfortable_swipe::service +namespace comfortable_swipe { - void buffer() + int driver() { + // unsync for faster IO std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); @@ -40,6 +41,19 @@ namespace comfortable_swipe::service comfortable_swipe::util::conf_filename() ); + // initialize mouse hold gesture handler + // for now, this supports 3-finger and 4-finger hold + // Examples: + // hold3=move move mouse on 3 fingers + // hold3=button1 hold button 1 on 3 fingers + // hold4=button3 hold button 3 (right click) on 3 fingers + // hold3=ignore + comfortable_swipe::gesture::mouse_hold_gesture mouse_hold + ( + config["hold3"].c_str(), + config["hold4"].c_str() + ); + // initialize keyboard swipe gesture handler comfortable_swipe::gesture::keyboard_swipe_gesture keyboard_swipe ( @@ -54,13 +68,6 @@ namespace comfortable_swipe::service config["down4"].c_str() ); - // initialize mouse swipe gesture handler - comfortable_swipe::gesture::mouse_swipe_gesture mouse_hold - ( - "", - "mouse1" - ); - // prepare data containers std::array line; @@ -77,7 +84,9 @@ namespace comfortable_swipe::service keyboard_swipe.parse_line(line.data()); } } + + return 0; } } -#endif /* __COMFORTABLE_SWIPE__service_buffer__ */ +#endif /* __COMFORTABLE_SWIPE__driver__ */ diff --git a/lib/gesture/keyboard_swipe_gesture.cpp b/comfortable_swipe/gesture/keyboard_swipe_gesture.cpp similarity index 100% rename from lib/gesture/keyboard_swipe_gesture.cpp rename to comfortable_swipe/gesture/keyboard_swipe_gesture.cpp diff --git a/lib/gesture/keyboard_swipe_gesture.h b/comfortable_swipe/gesture/keyboard_swipe_gesture.h similarity index 100% rename from lib/gesture/keyboard_swipe_gesture.h rename to comfortable_swipe/gesture/keyboard_swipe_gesture.h diff --git a/lib/gesture/mouse_swipe_gesture.cpp b/comfortable_swipe/gesture/mouse_hold_gesture.cpp similarity index 68% rename from lib/gesture/mouse_swipe_gesture.cpp rename to comfortable_swipe/gesture/mouse_hold_gesture.cpp index ce4cdc3..d44b7ba 100644 --- a/lib/gesture/mouse_swipe_gesture.cpp +++ b/comfortable_swipe/gesture/mouse_hold_gesture.cpp @@ -1,5 +1,5 @@ -#ifndef __COMFORTABLE_SWIPE__gesture_mouse_swipe_gesture__ -#define __COMFORTABLE_SWIPE__gesture_mouse_swipe_gesture__ +#ifndef __COMFORTABLE_SWIPE__gesture_mouse_hold_gesture__ +#define __COMFORTABLE_SWIPE__gesture_mouse_hold_gesture__ /* Comfortable Swipe @@ -21,8 +21,8 @@ along with this program. If not, see . #include // std::cout, std::endl #include // std::sscanf -#include // strncmp -#include "mouse_swipe_gesture.h" +#include // strncmp +#include "mouse_hold_gesture.h" extern "C" { @@ -36,7 +36,7 @@ namespace comfortable_swipe::gesture /** * Constructs a new mouse gesture, given "hold3" and "hold4" configurations. */ - mouse_swipe_gesture::mouse_swipe_gesture + mouse_hold_gesture::mouse_hold_gesture ( const char* hold3, const char* hold4 @@ -50,19 +50,24 @@ namespace comfortable_swipe::gesture /** * Destructs this mouse swipe gesture. */ - mouse_swipe_gesture::~mouse_swipe_gesture() + mouse_hold_gesture::~mouse_hold_gesture() { } /** * Run mousedown command on hold input. */ - void mouse_swipe_gesture::do_mousedown(const char * mouseinput) + void mouse_hold_gesture::do_mousedown(const char * mouseinput) { - int mouse = this->parse_mouse_input(mouseinput); - if (mouse != -1) + int button = this->parse_mouse_button(mouseinput); + if (button != -1) { // eg. MOUSE DOWN hold3 mouse1 std::printf("MOUSE DOWN hold%d %s\n", this->fingers, mouseinput); + if (button != 0) + { + // send mouse down on associated button + xdo_mouse_down(this->xdo, CURRENTWINDOW, button); + } this->flag_mousedown = true; } } @@ -70,17 +75,17 @@ namespace comfortable_swipe::gesture /** * Run mouseup command on hold output. */ - void mouse_swipe_gesture::do_mouseup(const char * mouseinput) + void mouse_hold_gesture::do_mouseup(const char * mouseinput) { - int mouse = this->parse_mouse_input(mouseinput); - if (mouse != -1) + int button = this->parse_mouse_button(mouseinput); + if (button != -1) { std::printf("MOUSE UP hold%d %s\n", this->fingers, mouseinput); - if (mouse != 0) + if (button != 0) { - // send mouse up to xdo + // send mouse up on associated button + xdo_mouse_up(this->xdo, CURRENTWINDOW, button); } - this->flag_mousedown = false; } } @@ -89,22 +94,17 @@ namespace comfortable_swipe::gesture * Utility method to parse mouse number from input. * Returns -1 on failure. */ - int mouse_swipe_gesture::parse_mouse_input(const char *input) + int mouse_hold_gesture::parse_mouse_button(const char *input) { - // check if "mouse" is prefix - if (strncmp(input, "mouse", 5) == 0) + // just move without holding button down + if (std::strcmp(input, "move") == 0) + return 0; + // get button number + int button; + if (std::sscanf(input, "button%d", &button) == 1) { - if (input[5] == '\0') - { - // just "mouse" without a number - return 0; - } - int mouseno; - if (std::sscanf(input + 5, "%d", &mouseno) == 1) - { - // parse the number after "mouse" - return mouseno; - } + // parse the number after "mouse" + return button; } return -1; @@ -113,7 +113,7 @@ namespace comfortable_swipe::gesture /** * Hook on begin of mouse swipe gesture. */ - void mouse_swipe_gesture::begin() + void mouse_hold_gesture::begin() { // call superclass method swipe_gesture::begin(); @@ -131,7 +131,7 @@ namespace comfortable_swipe::gesture /** * Hook on end of mouse swipe gesture. */ - void mouse_swipe_gesture::update() + void mouse_hold_gesture::update() { // call superclass method swipe_gesture::update(); @@ -149,7 +149,7 @@ namespace comfortable_swipe::gesture /** * Hook on end of swipe gesture. */ - void mouse_swipe_gesture::end() + void mouse_hold_gesture::end() { if (this->is_mousedown()) { @@ -170,10 +170,10 @@ namespace comfortable_swipe::gesture /** * Utility method to check if mouse is current held. */ - bool mouse_swipe_gesture::is_mousedown() + bool mouse_hold_gesture::is_mousedown() { return this->flag_mousedown; } } -#endif /* __COMFORTABLE_SWIPE__gesture_mouse_swipe_gesture__ */ +#endif /* __COMFORTABLE_SWIPE__gesture_mouse_hold_gesture__ */ diff --git a/lib/gesture/mouse_swipe_gesture.h b/comfortable_swipe/gesture/mouse_hold_gesture.h similarity index 81% rename from lib/gesture/mouse_swipe_gesture.h rename to comfortable_swipe/gesture/mouse_hold_gesture.h index d2c35fd..74e7659 100644 --- a/lib/gesture/mouse_swipe_gesture.h +++ b/comfortable_swipe/gesture/mouse_hold_gesture.h @@ -1,5 +1,5 @@ -#ifndef __COMFORTABLE_SWIPE__gesture_mouse_swipe_gesture_h__ -#define __COMFORTABLE_SWIPE__gesture_mouse_swipe_gesture_h__ +#ifndef __COMFORTABLE_SWIPE__gesture_mouse_hold_gesture_h__ +#define __COMFORTABLE_SWIPE__gesture_mouse_hold_gesture_h__ /* Comfortable Swipe @@ -27,16 +27,16 @@ extern "C" { namespace comfortable_swipe::gesture { - class mouse_swipe_gesture : public swipe_gesture + class mouse_hold_gesture : public swipe_gesture { public: // constructor - mouse_swipe_gesture( + mouse_hold_gesture( const char* hold3, // 3 finger mouse down const char* hold4 // 4 finger mouse down ); - virtual ~mouse_swipe_gesture(); + virtual ~mouse_hold_gesture(); // override begin and end for mousedown virtual void begin() override; @@ -49,7 +49,7 @@ namespace comfortable_swipe::gesture virtual bool is_mousedown(); // utility method to parse mouse input given config characters - virtual int parse_mouse_input(const char*); + virtual int parse_mouse_button(const char*); protected: // command holders @@ -65,4 +65,4 @@ namespace comfortable_swipe::gesture } #endif -#endif /* __COMFORTABLE_SWIPE__gesture_mouse_swipe_gesture_h__ */ +#endif /* __COMFORTABLE_SWIPE__gesture_mouse_hold_gesture_h__ */ diff --git a/lib/gesture/swipe_gesture.cpp b/comfortable_swipe/gesture/swipe_gesture.cpp similarity index 100% rename from lib/gesture/swipe_gesture.cpp rename to comfortable_swipe/gesture/swipe_gesture.cpp diff --git a/lib/gesture/swipe_gesture.h b/comfortable_swipe/gesture/swipe_gesture.h similarity index 100% rename from lib/gesture/swipe_gesture.h rename to comfortable_swipe/gesture/swipe_gesture.h diff --git a/lib/gesture/swipe_gesture.regex.cpp b/comfortable_swipe/gesture/swipe_gesture.regex.cpp similarity index 100% rename from lib/gesture/swipe_gesture.regex.cpp rename to comfortable_swipe/gesture/swipe_gesture.regex.cpp diff --git a/lib/gesture/xdo_gesture.cpp b/comfortable_swipe/gesture/xdo_gesture.cpp similarity index 100% rename from lib/gesture/xdo_gesture.cpp rename to comfortable_swipe/gesture/xdo_gesture.cpp diff --git a/lib/gesture/xdo_gesture.h b/comfortable_swipe/gesture/xdo_gesture.h similarity index 100% rename from lib/gesture/xdo_gesture.h rename to comfortable_swipe/gesture/xdo_gesture.h diff --git a/lib/comfortable_swipe b/comfortable_swipe/lib similarity index 89% rename from lib/comfortable_swipe rename to comfortable_swipe/lib index a7ebc06..3219843 100644 --- a/lib/comfortable_swipe +++ b/comfortable_swipe/lib @@ -19,17 +19,17 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "index.hpp" +#include "all_headers.hpp" /** - * Make sure to include all implementation (.cpp) files below to be ready for export. + * Add all cpp files below to be ready for export. */ #include "gesture/xdo_gesture.cpp" #include "gesture/swipe_gesture.cpp" #include "gesture/swipe_gesture.regex.cpp" #include "gesture/keyboard_swipe_gesture.cpp" -#include "gesture/mouse_swipe_gesture.cpp" +#include "gesture/mouse_hold_gesture.cpp" #include "service/autostart.cpp" #include "service/buffer.cpp" #include "service/config.cpp" @@ -42,5 +42,6 @@ along with this program. If not, see . #include "util/autostart_filename.cpp" #include "util/conf_filename.cpp" #include "util/read_config_file.cpp" +#include "driver.cpp" #endif /* __COMFORTABLE_SWIPE__ */ diff --git a/lib/service/autostart.cpp b/comfortable_swipe/service/autostart.cpp similarity index 98% rename from lib/service/autostart.cpp rename to comfortable_swipe/service/autostart.cpp index 1a4575f..56f7ecd 100644 --- a/lib/service/autostart.cpp +++ b/comfortable_swipe/service/autostart.cpp @@ -24,7 +24,7 @@ along with this program. If not, see . #include // std::string #include // std::remove #include // std::system -#include "../index.hpp" +#include "../all_headers.hpp" namespace comfortable_swipe::service { @@ -45,7 +45,7 @@ namespace comfortable_swipe::service << std::endl; else std::cout << "Autostart switched off" << std::endl; - } + } else { // file not found, create it int result = std::system(("mkdir -p $(dirname " + path + ")").data()); diff --git a/comfortable_swipe/service/buffer.cpp b/comfortable_swipe/service/buffer.cpp new file mode 100644 index 0000000..1ceef02 --- /dev/null +++ b/comfortable_swipe/service/buffer.cpp @@ -0,0 +1,36 @@ +#ifndef __COMFORTABLE_SWIPE__service_buffer__ +#define __COMFORTABLE_SWIPE__service_buffer__ + +/* +Comfortable Swipe +by Rico Tiongson + +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 // std::exit +#include "../all_headers.hpp" + +/** + * Starts the comfortable-swipe service by buffering libinput debug-events. + */ +namespace comfortable_swipe::service +{ + void buffer() + { + std::exit(comfortable_swipe::driver()); + } +} + +#endif /* __COMFORTABLE_SWIPE__service_buffer__ */ diff --git a/lib/service/config.cpp b/comfortable_swipe/service/config.cpp similarity index 97% rename from lib/service/config.cpp rename to comfortable_swipe/service/config.cpp index 6bb02bd..52964e4 100644 --- a/lib/service/config.cpp +++ b/comfortable_swipe/service/config.cpp @@ -19,8 +19,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "../index.hpp" #include // std::puts +#include "../all_headers.hpp" namespace comfortable_swipe::service { diff --git a/lib/service/debug.cpp b/comfortable_swipe/service/debug.cpp similarity index 100% rename from lib/service/debug.cpp rename to comfortable_swipe/service/debug.cpp diff --git a/lib/service/help.cpp b/comfortable_swipe/service/help.cpp similarity index 98% rename from lib/service/help.cpp rename to comfortable_swipe/service/help.cpp index 9654132..60730c3 100644 --- a/lib/service/help.cpp +++ b/comfortable_swipe/service/help.cpp @@ -20,7 +20,7 @@ along with this program. If not, see . */ #include // std::puts, std::printf -#include "../index.hpp" +#include "../all_headers.hpp" namespace comfortable_swipe::service { diff --git a/lib/service/restart.cpp b/comfortable_swipe/service/restart.cpp similarity index 97% rename from lib/service/restart.cpp rename to comfortable_swipe/service/restart.cpp index 28191c8..51c7495 100644 --- a/lib/service/restart.cpp +++ b/comfortable_swipe/service/restart.cpp @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "../index.hpp" +#include "../all_headers.hpp" namespace comfortable_swipe::service { diff --git a/lib/service/start.cpp b/comfortable_swipe/service/start.cpp similarity index 97% rename from lib/service/start.cpp rename to comfortable_swipe/service/start.cpp index 9ab566e..8ccd1f7 100644 --- a/lib/service/start.cpp +++ b/comfortable_swipe/service/start.cpp @@ -19,8 +19,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "../index.hpp" #include // std::system +#include "../all_headers.hpp" namespace comfortable_swipe::service { diff --git a/lib/service/status.cpp b/comfortable_swipe/service/status.cpp similarity index 99% rename from lib/service/status.cpp rename to comfortable_swipe/service/status.cpp index be25ae7..324b506 100644 --- a/lib/service/status.cpp +++ b/comfortable_swipe/service/status.cpp @@ -19,7 +19,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "../index.hpp" #include // std::runtime_error #include // popen, pclose, getpid, access, F_OK #include // std::unique_ptr @@ -27,6 +26,7 @@ along with this program. If not, see . #include // std::atoi #include // FILE, std::feof, std::fgets, std::printf #include // std::cmatch, std::regex, std::regex_match +#include "../all_headers.hpp" namespace comfortable_swipe::service { diff --git a/lib/service/stop.cpp b/comfortable_swipe/service/stop.cpp similarity index 96% rename from lib/service/stop.cpp rename to comfortable_swipe/service/stop.cpp index 7469c69..c046752 100644 --- a/lib/service/stop.cpp +++ b/comfortable_swipe/service/stop.cpp @@ -1,9 +1,6 @@ #ifndef __COMFORTABLE_SWIPE__service_stop__ #define __COMFORTABLE_SWIPE__service_stop__ -#include // std::FILE, std::feof, std::fgets -#include // std::atoi, std::system -#include // std::string, std::to_string /* Comfortable Swipe by Rico Tiongson @@ -26,8 +23,9 @@ along with this program. If not, see . #include // popen, pclose, getpid #include // std::unique_ptr #include // std::array -#include // std::atoi -#include // FILE, std::feof, std::fgets +#include // std::FILE, std::feof, std::fgets +#include // std::atoi, std::system +#include // std::string, std::to_string namespace comfortable_swipe::service { diff --git a/lib/util/autostart_filename.cpp b/comfortable_swipe/util/autostart_filename.cpp similarity index 100% rename from lib/util/autostart_filename.cpp rename to comfortable_swipe/util/autostart_filename.cpp diff --git a/lib/util/conf_filename.cpp b/comfortable_swipe/util/conf_filename.cpp similarity index 97% rename from lib/util/conf_filename.cpp rename to comfortable_swipe/util/conf_filename.cpp index 5de5ae9..74393bc 100644 --- a/lib/util/conf_filename.cpp +++ b/comfortable_swipe/util/conf_filename.cpp @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "../index.hpp" +#include "../all_headers.hpp" namespace comfortable_swipe::util { diff --git a/lib/util/read_config_file.cpp b/comfortable_swipe/util/read_config_file.cpp similarity index 100% rename from lib/util/read_config_file.cpp rename to comfortable_swipe/util/read_config_file.cpp diff --git a/comfortable-swipe.cpp b/command_line.cpp similarity index 96% rename from comfortable-swipe.cpp rename to command_line.cpp index 65359b5..426f09c 100644 --- a/comfortable-swipe.cpp +++ b/command_line.cpp @@ -19,9 +19,9 @@ along with this program. If not, see . #include // std::ios #include // std::cin, std::cout, std::cerr #include // std::string -#include "lib/comfortable_swipe" +#include "comfortable_swipe/lib" -/* MAIN DRIVER FUNCTION */ +/* Command-line function. */ int main(int argc, char** args) { diff --git a/cpp.compile.sh b/cpp.compile.sh new file mode 100755 index 0000000..6dcd0ac --- /dev/null +++ b/cpp.compile.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +dir="$(dirname $0)" +version="$(cat "$dir/VERSION" | tr -d '[:space:]')" + +exec g++ $@ \ + -std=c++11 \ + -O2 -lxdo -Wno-unused-result \ + -DCOMFORTABLE_SWIPE_VERSION="\"$version\"" diff --git a/install b/install index 1bbc844..20d7acb 100755 --- a/install +++ b/install @@ -1,11 +1,13 @@ #!/bin/bash +set -e + function install { # prefer running as root - local dir="$(dirname $0)" + local dir="$(dirname "$0")" local program=comfortable-swipe local program_exe=/usr/local/bin/$program - local compile_command="$dir/$program.compile.sh" + local compile_command="$dir/cpp.compile.sh $dir/command_line.cpp" local conf_path=/usr/local/share/$program/$program.conf local dconf_path="$dir/defaults.conf" local old_conf_path="${XDG_CONFIG_HOME:-$HOME/.config}/$program.conf" @@ -70,7 +72,7 @@ function install { fi # compile library - sudo "$compile_command" "$program_exe" || abort + sudo "$compile_command" -o "$program_exe" || abort # add permissions to input group (defer) # GROUP=$(ls -l /dev/input/event* | awk '{print $4}' | head --line=1) || abort diff --git a/tests/run_tests b/tests/run_tests index 20da97d..e6f34d7 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -1,6 +1,24 @@ -#!/bin/sh +#!/bin/bash -DIR=$(dirname $0) -g++ -std=c++11 -O2 $DIR/test_regex.cpp -lxdo -o test.out || exec "Test aborted" -./test.out || rm test.out -rm test.out \ No newline at end of file +set -e + +DIR="$(dirname "$0")" + +# just call abort on error +tempout="$(mktemp)" +abort () { + rm "$tempout" + echo "Test aborted" + exit 1 +} + +# run all shell files in this directory +for sh in "$DIR/test_"*.sh; do + /bin/bash "$sh" || abort +done + +# run all cpp files in this directory +for cpp in "$DIR/test_"*.cpp; do + g++ -std=c++11 -O2 "$cpp" -lxdo -o "$tempout" || abort + "$tempout" || abort +done diff --git a/tests/test_compiler.sh b/tests/test_compiler.sh new file mode 100755 index 0000000..f727dd3 --- /dev/null +++ b/tests/test_compiler.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -ex + +DIR="$(dirname "$0")" +root="$(dirname "$DIR")" +compiler="$root/cpp.compile.sh" +command_line="$root/command_line.cpp" +module="$root/comfortable_swipe" + +# just call abort on error +tempout="$(mktemp)" +abort () { + rm "$tempout" + echo "Test aborted" + exit 1 +} + +# try to compile every cpp/hpp file in module +# header files first +# then compile cpp files +# finally, compile command line +shopt -s nullglob +for cpp in \ + "$module"/**/*.h \ + "$module"/**/*.hpp \ + "$module"/**/*.cpp \ + "$module"/lib \ + "$command_line" +do + "$compiler" -c "$cpp" -o "$tempout" || abort +done diff --git a/tests/test_regex.cpp b/tests/test_regex.cpp old mode 100644 new mode 100755 index f2a524b..be858fd --- a/tests/test_regex.cpp +++ b/tests/test_regex.cpp @@ -2,8 +2,8 @@ #include #include #include -#include "../lib/gesture/swipe_gesture.h" -#include "../lib/gesture/swipe_gesture.regex.cpp" +#include "../comfortable_swipe/gesture/swipe_gesture.h" +#include "../comfortable_swipe/gesture/swipe_gesture.regex.cpp" /* Comfortable Swipe diff --git a/uninstall b/uninstall index 900c2f5..1c7a9fc 100644 --- a/uninstall +++ b/uninstall @@ -1,7 +1,8 @@ #!/bin/bash + echo "Uninstalling..." -rm ${XDG_CONFIG_HOME:-$HOME/.config}/autostart/comfortable-swipe.desktop 2> /dev/null +rm "${XDG_CONFIG_HOME:-$HOME/.config}/autostart/comfortable-swipe.desktop" 2> /dev/null comfortable-swipe stop 2> /dev/null -rm $HOME/.local/bin/comfortable-swipe 2> /dev/null # compat +rm "$HOME/.local/bin/comfortable-swipe" 2> /dev/null # compat sudo rm /usr/local/bin/comfortable-swipe 2> /dev/null echo "Successfully uninstalled comfortable-swipe"