From 6448587eb8ea52d8c03a198b54760b72f2f76468 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Sun, 9 Aug 2020 19:37:22 +0200 Subject: [PATCH] complete revision of gestures, using new edge system Signed-off-by: Maarten van Gompel --- programs/sxmo_screenlock.c | 2 +- scripts/core/sxmo_gesturehandler.sh | 125 +++++++++++++++++++++++ scripts/core/sxmo_hotcorner.sh | 25 +++++ scripts/core/sxmo_killwindow.sh | 2 + scripts/core/sxmo_lisgdonefingercheck.sh | 8 -- scripts/core/sxmo_lisgdstart.sh | 51 ++++++--- 6 files changed, 192 insertions(+), 21 deletions(-) create mode 100755 scripts/core/sxmo_gesturehandler.sh create mode 100755 scripts/core/sxmo_hotcorner.sh create mode 100755 scripts/core/sxmo_killwindow.sh delete mode 100755 scripts/core/sxmo_lisgdonefingercheck.sh diff --git a/programs/sxmo_screenlock.c b/programs/sxmo_screenlock.c index a332cd7..b802593 100644 --- a/programs/sxmo_screenlock.c +++ b/programs/sxmo_screenlock.c @@ -426,7 +426,7 @@ writefile(char *filepath, char *str) } void usage() { - fprintf(stderr, "Usage: sxmo_screenlock [--screen-off] [--suspend]\n"); + fprintf(stderr, "Usage: sxmo_screenlock [--screen-off] [--suspend] [--wake-interval n]\n"); } diff --git a/scripts/core/sxmo_gesturehandler.sh b/scripts/core/sxmo_gesturehandler.sh new file mode 100755 index 0000000..93f4583 --- /dev/null +++ b/scripts/core/sxmo_gesturehandler.sh @@ -0,0 +1,125 @@ +#!/usr/bin/env sh +ACTION="$1" + +XPROPOUT="$(xprop -id "$(xdotool getactivewindow)")" +WMCLASS="$(echo "$XPROPOUT" | grep WM_CLASS | cut -d ' ' -f3- | cut -d ' ' -f1 | tr -d '\",')" + +HANDLE=1 +if [ -x "$XDG_CONFIG_HOME"/sxmo/hooks/gesture ]; then + #hook script must exit with a zero exit code ONLY if it has handled the gesture! + "$XDG_CONFIG_HOME"/sxmo/hooks/gesture "$WMCLASS" "$@" + HANDLE=$? +fi + +if [ "$HANDLE" -ne 0 ]; then + #special context-sensitive handling + case "$WMCLASS" in + "foxtrotgps") + # E.g. just a check to ignore 1-finger gestures in foxtrotgps + if [ "$ACTION" != "killwindow" ]; then + HANDLE=0 + fi + ;; + "st-256color") + # First we try to handle the app running inside st: + WMNAME=$(echo "$XPROPOUT" | grep -E "^WM_NAME" | cut -d ' ' -f3-) + if echo "$WMNAME" | grep -i -w tuir; then + if [ "$ACTION" = "enter" ]; then + xdotool key o + HANDLE=0 + elif [ "$ACTION" = "back" ]; then + xdotool key s + HANDLE=0 + fi + fi + ;; + esac +fi + +if [ "$HANDLE" -ne 0 ]; then + #standard handling + case "$ACTION" in + "prevdesktop") + xdotool key --clearmodifiers Alt+Shift+e + ;; + "nextdesktop") + xdotool key --clearmodifiers Alt+Shift+r + ;; + "moveprevdesktop") + xdotool key --clearmodifiers Alt+e + ;; + "movenextdesktop") + xdotool key --clearmodifiers Alt+r + ;; + "unmute") + sxmo_vol.sh unmute & + ;; + "mute") + sxmo_vol.sh mute & + ;; + "brightnessup") + sxmo_brightness.sh up & + ;; + "brightnessdown") + sxmo_brightness.sh down & + ;; + "volup") + sxmo_vol.sh up & + ;; + "voldown") + sxmo_vol.sh down & + ;; + "showkeyboard") + pidof "$KEYBOARD" || "$KEYBOARD" & + ;; + "hidekeyboard") + pkill -9 "$KEYBOARD" + ;; + "showmenu") + sxmo_appmenu.sh & + ;; + "showsysmenu") + sxmo_appmenu.sh sys & + ;; + "hidemenu") + pkill -9 dmenu + ;; + "killwindow") + sxmo_killwindow.sh + ;; + "scrollup_long") + xdotool key Prior + ;; + "scrolldown_long") + xdotool key Next + ;; + "scrollup_med") + xdotool key Up Up Up + ;; + "scrolldown_med") + xdotool key Down Down Down + ;; + "scrollup_short") + xdotool key Up + ;; + "scrolldown_short") + xdotool key Down + ;; + "scrollleft_short") + xdotool key Left + ;; + "scrollright_short") + xdotool key Right + ;; + "enter") + xdotool key Return + ;; + "back") + xdotool key BackSpace + ;; + *) + #fallback, just execute the command + "$@" + ;; + esac +fi diff --git a/scripts/core/sxmo_hotcorner.sh b/scripts/core/sxmo_hotcorner.sh new file mode 100755 index 0000000..2a9a933 --- /dev/null +++ b/scripts/core/sxmo_hotcorner.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh +if [ -z "$1" ]; then + exit 1 +else + CORNER="$1" +fi + +if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/hotcorner_$CORNER" ]; then + "$XDG_CONFIG_HOME/sxmo/hooks/hotcorner_$CORNER" + exit $? +fi + +case "$CORNER" in + "topleft") + sxmo_appmenu.sh sys & + ;; + "topright") + ;; + "bottomleft") + sxmo_lock.sh & + ;; + "bottomright") + sxmo_rotate.sh & + ;; +esac diff --git a/scripts/core/sxmo_killwindow.sh b/scripts/core/sxmo_killwindow.sh new file mode 100755 index 0000000..57a0104 --- /dev/null +++ b/scripts/core/sxmo_killwindow.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +xdotool windowkill "$(xdotool getactivewindow)" diff --git a/scripts/core/sxmo_lisgdonefingercheck.sh b/scripts/core/sxmo_lisgdonefingercheck.sh deleted file mode 100755 index d970aa3..0000000 --- a/scripts/core/sxmo_lisgdonefingercheck.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env sh -ACTIVEWIN="$(xdotool getactivewindow)" -WMCLASS="$(xprop -id "$ACTIVEWIN" | grep WM_CLASS | cut -d ' ' -f3-)" - -# E.g. just a check to ignore 1-finger gestures in foxtrotgps -if echo "$WMCLASS" | grep -vi foxtrot; then - "$@" -fi diff --git a/scripts/core/sxmo_lisgdstart.sh b/scripts/core/sxmo_lisgdstart.sh index cff9e38..a4e1df1 100755 --- a/scripts/core/sxmo_lisgdstart.sh +++ b/scripts/core/sxmo_lisgdstart.sh @@ -1,15 +1,42 @@ #!/usr/bin/env sh pkill -9 lisgd -lisgd "$@" \ - -g '1,LR,sxmo_lisgdonefingercheck.sh xdotool key --clearmodifiers Alt+Shift+e' \ - -g '1,RL,sxmo_lisgdonefingercheck.sh xdotool key --clearmodifiers Alt+Shift+r' \ - -g '1,DLUR,sxmo_lisgdonefingercheck.sh sxmo_vol.sh up' \ - -g '1,URDL,sxmo_lisgdonefingercheck.sh sxmo_vol.sh down' \ - -g '1,DRUL,sxmo_lisgdonefingercheck.sh sxmo_brightness.sh up' \ - -g '1,ULDR,sxmo_lisgdonefingercheck.sh sxmo_brightness.sh down' \ - -g '2,LR,xdotool key --clearmodifiers Alt+e' \ - -g '2,RL,xdotool key --clearmodifiers Alt+r' \ - -g "2,DU,pidof $KEYBOARD || $KEYBOARD &" \ - -g "2,UD,pkill -9 $KEYBOARD" \ - & +if [ -x "$XDG_CONFIG_HOME"/sxmo/hooks/lisgdstart ]; then + "$XDG_CONFIG_HOME"/sxmo/hooks/lisgdstart & +else + #-g format: + # fingers,swipe,edge,distance,command + #order matters, only the first match gets executed + lisgd "$@" -t 200 \ + -g '1,DRUL,BR,*,sxmo_hotcorner.sh bottomright' \ + -g '1,DLUR,BL,*,sxmo_hotcorner.sh bottomleft' \ + -g '1,ULDR,TL,*,sxmo_hotcorner.sh topleft' \ + -g '1,DRUL,TR,*,sxmo_hotcorner.sh topright' \ + -g '1,LR,B,L,sxmo_gesturehandler.sh enter' \ + -g '1,RL,B,L,sxmo_gesturehandler.sh back' \ + -g '1,LR,L,*,sxmo_gesturehandler.sh prevdesktop' \ + -g '1,RL,R,*,sxmo_gesturehandler.sh nextdesktop' \ + -g '1,DU,L,L,sxmo_gesturehandler.sh unmute' \ + -g '1,UD,L,L,sxmo_gesturehandler.sh mute' \ + -g '1,DU,L,*,sxmo_gesturehandler.sh volup' \ + -g '1,UD,L,*,sxmo_gesturehandler.sh voldown' \ + -g '1,LR,T,*,sxmo_gesturehandler.sh brightnessup' \ + -g '1,RL,T,*,sxmo_gesturehandler.sh brightnessdown' \ + -g "1,DU,B,*,sxmo_gesturehandler.sh showkeyboard" \ + -g "1,UD,B,*,sxmo_gesturehandler.sh hidekeyboard" \ + -g "1,UD,T,*,sxmo_gesturehandler.sh showmenu" \ + -g "1,DU,T,*,sxmo_gesturehandler.sh hidemenu" \ + -g "2,UD,T,*,sxmo_gesturehandler.sh showsysmenu" \ + -g "2,UD,B,*,sxmo_gesturehandler.sh killwindow" \ + -g '2,LR,*,*,sxmo_gesturehandler.sh moveprevdesktop' \ + -g '2,RL,*,*,sxmo_gesturehandler.sh movenextdesktop' \ + -g '1,DU,R,L,sxmo_gesturehandler.sh scrollup_long' \ + -g '1,UD,R,L,sxmo_gesturehandler.sh scrolldown_long' \ + -g '1,DU,R,M,sxmo_gesturehandler.sh scrollup_med' \ + -g '1,UD,R,M,sxmo_gesturehandler.sh scrolldown_med' \ + -g '1,DU,R,S,sxmo_gesturehandler.sh scrollup_short' \ + -g '1,UD,R,S,sxmo_gesturehandler.sh scrolldown_short' \ + -g '1,LR,R,S,sxmo_gesturehandler.sh scrollright_short' \ + -g '1,RL,L,S,sxmo_gesturehandler.sh scrollleft_short' \ + & +fi