circular or diagonal direction
This commit is contained in:
parent
4ac4de9799
commit
16adaa52f7
@ -3,10 +3,12 @@ set -e
|
||||
|
||||
# based on https://github.com/carrot69/keep-presence/
|
||||
|
||||
test -n "$XJIGGLER_ACTION_DELAY" \
|
||||
|| XJIGGLER_ACTION_DELAY=300 # seconds
|
||||
test -n "$XJIGGLER_DETECTION_DELAY" \
|
||||
|| XJIGGLER_DETECTION_DELAY=60 # seconds
|
||||
test -n "$XJIGGLER_DELAY_ACTION" \
|
||||
|| XJIGGLER_DELAY_ACTION=300 # seconds
|
||||
test -n "$XJIGGLER_DELAY_DETECTION" \
|
||||
|| XJIGGLER_DELAY_DETECTION=60 # seconds
|
||||
test -n "$XJIGGLER_MOUSE_DIRECTION" \
|
||||
|| XJIGGER_MOUSE_DIRECTION=CIRCULAR # "CIRCULAR" "DIAGONAL"
|
||||
test -n "$XJIGGLER_MOUSE_DISTANCE" \
|
||||
|| XJIGGLER_MOUSE_DISTANCE=1 # pixels
|
||||
|
||||
@ -17,7 +19,7 @@ getmouselocation(){
|
||||
}
|
||||
|
||||
jiggle(){
|
||||
case "$XJIGGLER_mousedirection" in
|
||||
case "$XJIGGLER_MOUSE_DIRECTION" in
|
||||
up) xdotool mousemove_relative 0 -"$XJIGGLER_MOUSE_DISTANCE"
|
||||
return ;;
|
||||
right) xdotool mousemove_relative "$XJIGGLER_MOUSE_DISTANCE" 0
|
||||
@ -26,6 +28,10 @@ jiggle(){
|
||||
return ;;
|
||||
left) xdotool mousemove_relative -"$XJIGGLER_MOUSE_DISTANCE" 0
|
||||
return ;;
|
||||
DIAGONAL) xdotooltool mousemove_relative
|
||||
"$XJIGGLER_MOUSE_DISTANCE"
|
||||
"$XJIGGLER_MOUSE_DISTANCE"
|
||||
return ;;
|
||||
*)
|
||||
false ;;
|
||||
esac
|
||||
@ -47,27 +53,41 @@ printdebug(){
|
||||
}
|
||||
|
||||
rotatemousedirection(){
|
||||
case "$XJIGGLER_mousedirection" in
|
||||
up) XJIGGLER_mousedirection=right; return; ;;
|
||||
right) XJIGGLER_mousedirection=down; return; ;;
|
||||
down) XJIGGLER_mousedirection=left; return; ;;
|
||||
*) XJIGGLER_mousedirection=up; return; ;;
|
||||
case "$XJIGGLER_MOUSE_DIRECTION" in
|
||||
up) XJIGGLER_MOUSE_DIRECTION=right; return; ;;
|
||||
right) XJIGGLER_MOUSE_DIRECTION=down; return; ;;
|
||||
down) XJIGGLER_MOUSE_DIRECTION=left; return; ;;
|
||||
DIAGONAL) return; ;;
|
||||
*) XJIGGLER_MOUSE_DIRECTION=up; return; ;;
|
||||
esac
|
||||
}
|
||||
|
||||
usage(){
|
||||
printf 'Usage: %s (-ch)\n' "$0">&2
|
||||
exit 64 # sysexits(3) EX_USAGE
|
||||
}
|
||||
|
||||
while getopts :ch OPTION
|
||||
do
|
||||
case "$OPTION" in
|
||||
c) XJIGGLER_MOUSE_DIRECTION=circular ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
getmouselocation; pushmouselocation
|
||||
|
||||
while true
|
||||
do
|
||||
|
||||
sleep "$XJIGGLER_DETECTION_DELAY"
|
||||
sleep "$XJIGGLER_DELAY_DETECTION"
|
||||
getmouselocation
|
||||
if test "$XJIGGLER_lastX" = "$XJIGGLER_X" \
|
||||
&& test "$XJIGGLER_lastY" = "$XJIGGLER_Y"
|
||||
then # no movement
|
||||
test "$(printf '%s\n%s\n-\np\n' "$XJIGGLER_T" \
|
||||
"$XJIGGLER_lastT" \
|
||||
| dc)" -gt "$XJIGGLER_ACTION_DELAY" \
|
||||
| dc)" -gt "$XJIGGLER_DELAY_ACTION" \
|
||||
|| continue # hasn't been long enough
|
||||
rotatemousedirection; jiggle
|
||||
printf '%s: Jiggled:\n' "$0"
|
||||
|
Loading…
Reference in New Issue
Block a user