Cleanup input handling
We now use uncontextualized event name from lisgd as leftrightcorner. We will determine the action name only in the input handler. It allow events to match multiple action depending on contexts. We also add some basics events as left/rigth/up/down and twoleft/tworight/twoup/twodown and use some of them. Use use twoup and twodown to scroll in less and right left to change the page. We also prefer use case switch instead of if conditions. We remove this HANDLE variable usage and exit directly when the event has been handled. We also add some methods as type, key or typeenter to simplify some code. Signed-off-by: Stacy Harper <contact@stacyharper.net> Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This commit is contained in:
parent
a3d13c6c7d
commit
c427a0eb7b
2 changed files with 242 additions and 188 deletions
|
@ -28,6 +28,21 @@ lock_screen() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
key() {
|
||||||
|
xdotool windowactivate "$WIN"
|
||||||
|
xdotool key --delay 50 --clearmodifiers "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
type() {
|
||||||
|
xdotool windowactivate "$WIN"
|
||||||
|
xdotool type --delay 50 --clearmodifiers "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
typeenter() {
|
||||||
|
type "$@"
|
||||||
|
xdotool key Return
|
||||||
|
}
|
||||||
|
|
||||||
if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
|
if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
|
||||||
case "$ACTION" in
|
case "$ACTION" in
|
||||||
"volup_three")
|
"volup_three")
|
||||||
|
@ -51,176 +66,209 @@ XPROPOUT="$(xprop -id "$(xdotool getactivewindow)")"
|
||||||
WMCLASS="$(echo "$XPROPOUT" | grep WM_CLASS | cut -d ' ' -f3-)"
|
WMCLASS="$(echo "$XPROPOUT" | grep WM_CLASS | cut -d ' ' -f3-)"
|
||||||
WMNAME=$(echo "$XPROPOUT" | grep -E "^WM_NAME" | cut -d ' ' -f3-)
|
WMNAME=$(echo "$XPROPOUT" | grep -E "^WM_NAME" | cut -d ' ' -f3-)
|
||||||
|
|
||||||
HANDLE=1
|
|
||||||
if [ -x "$XDG_CONFIG_HOME"/sxmo/hooks/inputhandler ]; then
|
if [ -x "$XDG_CONFIG_HOME"/sxmo/hooks/inputhandler ]; then
|
||||||
#hook script must exit with a zero exit code ONLY if it has handled the gesture!
|
#hook script must exit with a zero exit code ONLY if it has handled the gesture!
|
||||||
"$XDG_CONFIG_HOME"/sxmo/hooks/inputhandler "$WMCLASS" "$WMNAME" "$@"
|
"$XDG_CONFIG_HOME"/sxmo/hooks/inputhandler "$WMCLASS" "$WMNAME" "$@" && exit
|
||||||
HANDLE=$?
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$HANDLE" -ne 0 ]; then
|
#special context-sensitive handling
|
||||||
#special context-sensitive handling
|
case "$WMCLASS" in
|
||||||
case "$WMCLASS" in
|
*"st-256color"*)
|
||||||
"foxtrotgps")
|
# First we try to handle the app running inside st:
|
||||||
# E.g. just a check to ignore 1-finger gestures in foxtrotgps
|
case "$WMNAME" in
|
||||||
if [ "$ACTION" != "killwindow" ]; then
|
*"tuir"*)
|
||||||
HANDLE=0
|
if [ "$ACTION" = "rightbottomcorner" ]; then
|
||||||
fi
|
type o
|
||||||
;;
|
exit 0
|
||||||
"st-256color")
|
elif [ "$ACTION" = "leftbottomcorner" ]; then
|
||||||
# First we try to handle the app running inside st:
|
type s
|
||||||
if echo "$WMNAME" | grep -i -w tuir; then
|
exit 0
|
||||||
if [ "$ACTION" = "enter" ]; then
|
|
||||||
xdotool key o
|
|
||||||
HANDLE=0
|
|
||||||
elif [ "$ACTION" = "back" ]; then
|
|
||||||
xdotool key s
|
|
||||||
HANDLE=0
|
|
||||||
fi
|
fi
|
||||||
elif echo "$WMNAME" | grep -i -E -w "(less|mless)"; then
|
;;
|
||||||
if [ "$ACTION" = "back" ] || [ "$ACTION" = "scrollleft_short" ]; then
|
*"less"*)
|
||||||
xdotool key q
|
case "$ACTION" in
|
||||||
HANDLE=0
|
"leftbottomcorner")
|
||||||
fi
|
type q
|
||||||
fi
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
"leftrightcorner_short")
|
||||||
fi
|
type q
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"twodown")
|
||||||
|
type u
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"twoup")
|
||||||
|
type d
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"left")
|
||||||
|
typeenter ":n"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"right")
|
||||||
|
typeenter ":p"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
esac
|
||||||
|
|
||||||
if [ "$HANDLE" -ne 0 ]; then
|
#standard handling
|
||||||
#standard handling
|
case "$ACTION" in
|
||||||
case "$ACTION" in
|
"rightleftcorner")
|
||||||
"prevdesktop")
|
key Super+Shift+e
|
||||||
xdotool key --clearmodifiers Super+Shift+e
|
exit 0
|
||||||
;;
|
;;
|
||||||
"nextdesktop")
|
"leftrightcorner")
|
||||||
xdotool key --clearmodifiers Super+Shift+r
|
key Super+Shift+r
|
||||||
;;
|
exit 0
|
||||||
"moveprevdesktop")
|
;;
|
||||||
xdotool key --clearmodifiers Super+e
|
"twoleft") # Move window previous
|
||||||
;;
|
key Super+e
|
||||||
"movenextdesktop")
|
exit 0
|
||||||
xdotool key --clearmodifiers Super+r
|
;;
|
||||||
;;
|
"tworight") # Move window next
|
||||||
"unmute")
|
key Super+r
|
||||||
sxmo_vol.sh unmute &
|
exit 0
|
||||||
;;
|
;;
|
||||||
"mute")
|
"unmute")
|
||||||
sxmo_vol.sh mute &
|
sxmo_vol.sh unmute &
|
||||||
;;
|
exit 0
|
||||||
"brightnessup")
|
;;
|
||||||
sxmo_brightness.sh up &
|
"mute")
|
||||||
;;
|
sxmo_vol.sh mute &
|
||||||
"brightnessdown")
|
exit 0
|
||||||
sxmo_brightness.sh down &
|
;;
|
||||||
;;
|
"righttopcorner")
|
||||||
"volup")
|
sxmo_brightness.sh up &
|
||||||
sxmo_vol.sh up &
|
exit 0
|
||||||
;;
|
;;
|
||||||
"voldown")
|
"lefttopcorner")
|
||||||
sxmo_vol.sh down &
|
sxmo_brightness.sh down &
|
||||||
;;
|
exit 0
|
||||||
"showkeyboard")
|
;;
|
||||||
sxmo_keyboard.sh open
|
"upleftcorner")
|
||||||
;;
|
sxmo_vol.sh up &
|
||||||
"hidekeyboard")
|
exit 0
|
||||||
sxmo_keyboard.sh close
|
;;
|
||||||
;;
|
"downleftcorner")
|
||||||
"showmenu")
|
sxmo_vol.sh down &
|
||||||
pidof dmenu || setsid -f sxmo_appmenu.sh &
|
exit 0
|
||||||
;;
|
;;
|
||||||
"showsysmenu")
|
"upbottomcorner")
|
||||||
pidof dmenu || setsid -f sxmo_appmenu.sh sys &
|
sxmo_keyboard.sh open
|
||||||
;;
|
exit 0
|
||||||
"hidemenu")
|
;;
|
||||||
pkill -9 dmenu
|
"downbottomcorner")
|
||||||
dunstctl close-all
|
sxmo_keyboard.sh close
|
||||||
;;
|
exit 0
|
||||||
"closewindow")
|
;;
|
||||||
sxmo_killwindow.sh close
|
"downtopcorner")
|
||||||
;;
|
pidof dmenu || setsid -f sxmo_appmenu.sh &
|
||||||
"killwindow")
|
exit 0
|
||||||
sxmo_killwindow.sh
|
;;
|
||||||
;;
|
"twodowntopcorner")
|
||||||
"scrollup_long")
|
pidof dmenu || setsid -f sxmo_appmenu.sh sys &
|
||||||
xdotool key Prior
|
exit 0
|
||||||
;;
|
;;
|
||||||
"scrolldown_long")
|
"uptopcorner")
|
||||||
xdotool key Next
|
pkill -9 dmenu
|
||||||
;;
|
dunstctl close-all
|
||||||
"scrollup_med")
|
exit 0
|
||||||
xdotool key Up Up Up
|
;;
|
||||||
;;
|
"twodownbottomcorner")
|
||||||
"scrolldown_med")
|
sxmo_killwindow.sh close
|
||||||
xdotool key Down Down Down
|
exit 0
|
||||||
;;
|
;;
|
||||||
"scrollup_short")
|
"threedownbottomcorner")
|
||||||
xdotool key Up
|
sxmo_killwindow.sh
|
||||||
;;
|
exit 0
|
||||||
"scrolldown_short")
|
;;
|
||||||
xdotool key Down
|
"uprightcorner")
|
||||||
;;
|
xdotool key Up
|
||||||
"scrollleft_short")
|
exit 0
|
||||||
xdotool key Left
|
;;
|
||||||
;;
|
"downrightcorner")
|
||||||
"scrollright_short")
|
xdotool key Down
|
||||||
xdotool key Right
|
exit 0
|
||||||
;;
|
;;
|
||||||
"enter")
|
"leftrightcorner_short")
|
||||||
xdotool key Return
|
xdotool key Left
|
||||||
;;
|
exit 0
|
||||||
"back")
|
;;
|
||||||
xdotool key BackSpace
|
"rightrightcorner_short")
|
||||||
;;
|
xdotool key Right
|
||||||
"powerbutton_one")
|
exit 0
|
||||||
if echo "$WMCLASS" | grep -i "megapixels"; then
|
;;
|
||||||
xdotool key --clearmodifiers "space"
|
"rightbottomcorner")
|
||||||
else
|
xdotool key Return
|
||||||
sxmo_keyboard.sh toggle
|
exit 0
|
||||||
fi
|
;;
|
||||||
;;
|
"leftbottomcorner")
|
||||||
"powerbutton_two")
|
xdotool key BackSpace
|
||||||
sxmo_blinkled.sh blue && $TERMCMD -e "$SHELL"
|
exit 0
|
||||||
;;
|
;;
|
||||||
"powerbutton_three")
|
"powerbutton_one")
|
||||||
sxmo_blinkled.sh blue && $BROWSER
|
if echo "$WMCLASS" | grep -i "megapixels"; then
|
||||||
;;
|
key "space"
|
||||||
"volup_one")
|
else
|
||||||
sxmo_appmenu.sh
|
sxmo_keyboard.sh toggle
|
||||||
;;
|
fi
|
||||||
"volup_two")
|
exit 0
|
||||||
sxmo_appmenu.sh sys
|
;;
|
||||||
;;
|
"powerbutton_two")
|
||||||
"volup_three")
|
sxmo_blinkled.sh blue && $TERMCMD -e "$SHELL"
|
||||||
lock_screen
|
exit 0
|
||||||
;;
|
;;
|
||||||
"voldown_one")
|
"powerbutton_three")
|
||||||
xdotool key --clearmodifiers Super+space
|
sxmo_blinkled.sh blue && $BROWSER
|
||||||
;;
|
exit 0
|
||||||
"voldown_two")
|
;;
|
||||||
xdotool key --clearmodifiers Super+Return
|
"volup_one")
|
||||||
;;
|
sxmo_appmenu.sh
|
||||||
"voldown_three")
|
exit 0
|
||||||
sxmo_blinkled.sh red && sxmo_killwindow.sh
|
;;
|
||||||
;;
|
"volup_two")
|
||||||
"voldown_four")
|
sxmo_appmenu.sh sys
|
||||||
sxmo_blinkled.sh red & sxmo_killwindow.sh close
|
exit 0
|
||||||
;;
|
;;
|
||||||
"topleftcorner")
|
"volup_three")
|
||||||
sxmo_appmenu.sh sys &
|
lock_screen
|
||||||
;;
|
exit 0
|
||||||
"toprightcorner")
|
;;
|
||||||
sxmo_appmenu.sh scripts &
|
"voldown_one")
|
||||||
;;
|
key Super+space
|
||||||
"bottomleftcorner")
|
exit 0
|
||||||
lock_screen
|
;;
|
||||||
;;
|
"voldown_two")
|
||||||
"bottomrightcorner")
|
key Super+Return
|
||||||
sxmo_rotate.sh &
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
"voldown_three")
|
||||||
#fallback, just execute the command
|
sxmo_blinkled.sh red && sxmo_killwindow.sh
|
||||||
"$@"
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
"voldown_four")
|
||||||
fi
|
sxmo_blinkled.sh red & sxmo_killwindow.sh close
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"topleftcorner")
|
||||||
|
sxmo_appmenu.sh sys &
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"toprightcorner")
|
||||||
|
sxmo_appmenu.sh scripts &
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"bottomleftcorner")
|
||||||
|
lock_screen
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"bottomrightcorner")
|
||||||
|
sxmo_rotate.sh &
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -24,26 +24,32 @@ else
|
||||||
-g '1,DLUR,BL,*,sxmo_inputhandler.sh bottomleftcorner' \
|
-g '1,DLUR,BL,*,sxmo_inputhandler.sh bottomleftcorner' \
|
||||||
-g '1,ULDR,TL,*,sxmo_inputhandler.sh topleftcorner' \
|
-g '1,ULDR,TL,*,sxmo_inputhandler.sh topleftcorner' \
|
||||||
-g '1,URDL,TR,*,sxmo_inputhandler.sh toprightcorner' \
|
-g '1,URDL,TR,*,sxmo_inputhandler.sh toprightcorner' \
|
||||||
-g '1,LR,B,L,sxmo_inputhandler.sh enter' \
|
-g '1,LR,B,L,sxmo_inputhandler.sh rightbottomcorner' \
|
||||||
-g '1,RL,B,L,sxmo_inputhandler.sh back' \
|
-g '1,RL,B,L,sxmo_inputhandler.sh leftbottomcorner' \
|
||||||
-g '1,LR,L,*,sxmo_inputhandler.sh prevdesktop' \
|
-g '1,LR,L,*,sxmo_inputhandler.sh rightleftcorner' \
|
||||||
-g '1,RL,R,*,sxmo_inputhandler.sh nextdesktop' \
|
-g '1,RL,R,*,sxmo_inputhandler.sh leftrightcorner' \
|
||||||
-g '1,DU,L,*,P,sxmo_inputhandler.sh volup' \
|
-g '1,DU,L,*,P,sxmo_inputhandler.sh upleftcorner' \
|
||||||
-g '1,UD,L,*,P,sxmo_inputhandler.sh voldown' \
|
-g '1,UD,L,*,P,sxmo_inputhandler.sh downleftcorner' \
|
||||||
-g '1,LR,T,*,P,sxmo_inputhandler.sh brightnessup' \
|
-g '1,LR,T,*,P,sxmo_inputhandler.sh righttopcorner' \
|
||||||
-g '1,RL,T,*,P,sxmo_inputhandler.sh brightnessdown' \
|
-g '1,RL,T,*,P,sxmo_inputhandler.sh lefttopcorner' \
|
||||||
-g "1,DU,B,*,sxmo_inputhandler.sh showkeyboard" \
|
-g "1,DU,B,*,sxmo_inputhandler.sh upbottomcorner" \
|
||||||
-g "1,UD,B,*,sxmo_inputhandler.sh hidekeyboard" \
|
-g "1,UD,B,*,sxmo_inputhandler.sh downbottomcorner" \
|
||||||
-g "1,UD,T,*,sxmo_inputhandler.sh showmenu" \
|
-g "1,UD,T,*,sxmo_inputhandler.sh downtopcorner" \
|
||||||
-g "1,DU,T,*,sxmo_inputhandler.sh hidemenu" \
|
-g "1,DU,T,*,sxmo_inputhandler.sh uptopcorner" \
|
||||||
-g "2,UD,T,*,sxmo_inputhandler.sh showsysmenu" \
|
-g "2,UD,T,*,sxmo_inputhandler.sh twodowntopcorner" \
|
||||||
-g "2,UD,B,*,sxmo_inputhandler.sh closewindow" \
|
-g "2,UD,B,*,sxmo_inputhandler.sh twodownbottomcorner" \
|
||||||
-g "3,UD,B,*,sxmo_inputhandler.sh killwindow" \
|
-g "r,UD,B,*,sxmo_inputhandler.sh threedownbottomcorner" \
|
||||||
-g '2,RL,*,*,sxmo_inputhandler.sh moveprevdesktop' \
|
-g '1,DU,R,*,P,sxmo_inputhandler.sh uprightcorner' \
|
||||||
-g '2,LR,*,*,sxmo_inputhandler.sh movenextdesktop' \
|
-g '1,UD,R,*,P,sxmo_inputhandler.sh downrightcorner' \
|
||||||
-g '1,DU,R,*,P,sxmo_inputhandler.sh scrollup_short' \
|
-g '1,LR,R,S,sxmo_inputhandler.sh rightrightcorner_short' \
|
||||||
-g '1,UD,R,*,P,sxmo_inputhandler.sh scrolldown_short' \
|
-g '1,RL,L,S,sxmo_inputhandler.sh leftrightcorner_short' \
|
||||||
-g '1,LR,R,S,sxmo_inputhandler.sh scrollright_short' \
|
-g '1,RL,*,*,sxmo_inputhandler.sh left' \
|
||||||
-g '1,RL,L,S,sxmo_inputhandler.sh scrollleft_short' \
|
-g '1,LR,*,*,sxmo_inputhandler.sh right' \
|
||||||
|
-g '1,DU,*,*,sxmo_inputhandler.sh up' \
|
||||||
|
-g '1,UD,*,*,sxmo_inputhandler.sh down' \
|
||||||
|
-g '2,RL,*,*,sxmo_inputhandler.sh twoleft' \
|
||||||
|
-g '2,LR,*,*,sxmo_inputhandler.sh tworight' \
|
||||||
|
-g '2,DU,*,*,sxmo_inputhandler.sh twoup' \
|
||||||
|
-g '2,UD,*,*,sxmo_inputhandler.sh twodown' \
|
||||||
>"$CACHEDIR/lisgd.log" 2>&1 &
|
>"$CACHEDIR/lisgd.log" 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue