Allow the inputhandler hook to override locked state inputs actions
The user may want to change completly the buttons actions in normal and locked mode. This allow this ! Btw, we also provide default inputhandler actions (as example) to help the user to build their own. Signed-off-by: Stacy Harper <contact@stacyharper.net> Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This commit is contained in:
parent
fe519a80b3
commit
b1403f983e
2 changed files with 91 additions and 9 deletions
82
configs/default_hooks/inputhandler
Normal file
82
configs/default_hooks/inputhandler
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
WMCLASS="$1"
|
||||||
|
WMNAME="$2"
|
||||||
|
ACTION="$3"
|
||||||
|
|
||||||
|
key() {
|
||||||
|
xdotool windowactivate "$WIN"
|
||||||
|
xdotool key --delay 50 --clearmodifiers "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
type() {
|
||||||
|
xdotool windowactivate "$WIN"
|
||||||
|
xdotool type --delay 50 --clearmodifiers "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
typeenter() {
|
||||||
|
type "$@"
|
||||||
|
xdotool key Return
|
||||||
|
}
|
||||||
|
|
||||||
|
# You must exit 0 if you handled the input to not trigger default behaviors
|
||||||
|
|
||||||
|
if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
|
||||||
|
# Here you could override locked input handlers
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Here you can handle normal input handler
|
||||||
|
|
||||||
|
exit 1 # Remove this in your user hook
|
||||||
|
|
||||||
|
# Here is an example of possible custom actions
|
||||||
|
# We already exited but you may adapt it for you own use cases
|
||||||
|
# Please share your recipes to the community :D
|
||||||
|
|
||||||
|
case "$WMCLASS" in
|
||||||
|
*"st-256color"*)
|
||||||
|
case "$WMNAME" in
|
||||||
|
*"weechat"*)
|
||||||
|
case "$ACTION" in
|
||||||
|
*"oneleft")
|
||||||
|
key Alt+a
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*"oneright")
|
||||||
|
key Alt+Shift+comma
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*"oneup")
|
||||||
|
key Page_Down
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*"onedown")
|
||||||
|
key Page_Up
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*"mpv"*)
|
||||||
|
case "$ACTION" in
|
||||||
|
"oneright")
|
||||||
|
key Left
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"oneleft")
|
||||||
|
key Right
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"upone")
|
||||||
|
key m
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"onedown")
|
||||||
|
key p
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
|
@ -35,6 +35,15 @@ typeenter() {
|
||||||
xdotool key Return
|
xdotool key Return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XPROPOUT="$(xprop -id "$(xdotool getactivewindow)")"
|
||||||
|
WMCLASS="$(echo "$XPROPOUT" | grep WM_CLASS | cut -d ' ' -f3-)"
|
||||||
|
WMNAME=$(echo "$XPROPOUT" | grep -E "^WM_NAME" | cut -d ' ' -f3-)
|
||||||
|
|
||||||
|
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!
|
||||||
|
"$XDG_CONFIG_HOME"/sxmo/hooks/inputhandler "$WMCLASS" "$WMNAME" "$@" && exit
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
|
if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
|
||||||
case "$ACTION" in
|
case "$ACTION" in
|
||||||
"volup_three")
|
"volup_three")
|
||||||
|
@ -54,15 +63,6 @@ if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
XPROPOUT="$(xprop -id "$(xdotool getactivewindow)")"
|
|
||||||
WMCLASS="$(echo "$XPROPOUT" | grep WM_CLASS | cut -d ' ' -f3-)"
|
|
||||||
WMNAME=$(echo "$XPROPOUT" | grep -E "^WM_NAME" | cut -d ' ' -f3-)
|
|
||||||
|
|
||||||
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!
|
|
||||||
"$XDG_CONFIG_HOME"/sxmo/hooks/inputhandler "$WMCLASS" "$WMNAME" "$@" && exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
#special context-sensitive handling
|
#special context-sensitive handling
|
||||||
case "$WMCLASS" in
|
case "$WMCLASS" in
|
||||||
*"st-256color"*)
|
*"st-256color"*)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue