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/ | # based on https://github.com/carrot69/keep-presence/ | ||||||
| 
 | 
 | ||||||
| test -n "$XJIGGLER_ACTION_DELAY" \ | test -n "$XJIGGLER_DELAY_ACTION" \ | ||||||
| 	|| XJIGGLER_ACTION_DELAY=300	# seconds | 	|| XJIGGLER_DELAY_ACTION=300	# seconds | ||||||
| test -n "$XJIGGLER_DETECTION_DELAY" \ | test -n "$XJIGGLER_DELAY_DETECTION" \ | ||||||
| 	|| XJIGGLER_DETECTION_DELAY=60	# seconds | 	|| XJIGGLER_DELAY_DETECTION=60	# seconds | ||||||
|  | test -n "$XJIGGLER_MOUSE_DIRECTION" \ | ||||||
|  | 	|| XJIGGER_MOUSE_DIRECTION=CIRCULAR # "CIRCULAR" "DIAGONAL" | ||||||
| test -n "$XJIGGLER_MOUSE_DISTANCE" \ | test -n "$XJIGGLER_MOUSE_DISTANCE" \ | ||||||
| 	|| XJIGGLER_MOUSE_DISTANCE=1	# pixels | 	|| XJIGGLER_MOUSE_DISTANCE=1	# pixels | ||||||
| 
 | 
 | ||||||
| @ -17,7 +19,7 @@ getmouselocation(){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| jiggle(){ | jiggle(){ | ||||||
| 	case "$XJIGGLER_mousedirection" in | 	case "$XJIGGLER_MOUSE_DIRECTION" in | ||||||
| 	up)	xdotool mousemove_relative 0 -"$XJIGGLER_MOUSE_DISTANCE" | 	up)	xdotool mousemove_relative 0 -"$XJIGGLER_MOUSE_DISTANCE" | ||||||
| 		return	;; | 		return	;; | ||||||
| 	right)	xdotool mousemove_relative "$XJIGGLER_MOUSE_DISTANCE" 0 | 	right)	xdotool mousemove_relative "$XJIGGLER_MOUSE_DISTANCE" 0 | ||||||
| @ -26,6 +28,10 @@ jiggle(){ | |||||||
| 		return	;; | 		return	;; | ||||||
| 	left)	xdotool mousemove_relative -"$XJIGGLER_MOUSE_DISTANCE" 0 | 	left)	xdotool mousemove_relative -"$XJIGGLER_MOUSE_DISTANCE" 0 | ||||||
| 		return	;; | 		return	;; | ||||||
|  | 	DIAGONAL)	xdotooltool mousemove_relative | ||||||
|  | 				"$XJIGGLER_MOUSE_DISTANCE" | ||||||
|  | 				"$XJIGGLER_MOUSE_DISTANCE" | ||||||
|  | 		return	;; | ||||||
| 	*) | 	*) | ||||||
| 		false	;; | 		false	;; | ||||||
| 	esac | 	esac | ||||||
| @ -47,27 +53,41 @@ printdebug(){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| rotatemousedirection(){ | rotatemousedirection(){ | ||||||
| 	case "$XJIGGLER_mousedirection" in | 	case "$XJIGGLER_MOUSE_DIRECTION" in | ||||||
| 	up)	XJIGGLER_mousedirection=right;	return; ;; | 	up)	XJIGGLER_MOUSE_DIRECTION=right;	return; ;; | ||||||
| 	right)	XJIGGLER_mousedirection=down;	return;	;; | 	right)	XJIGGLER_MOUSE_DIRECTION=down;	return;	;; | ||||||
| 	down)	XJIGGLER_mousedirection=left;	return;	;; | 	down)	XJIGGLER_MOUSE_DIRECTION=left;	return;	;; | ||||||
| 	*)	XJIGGLER_mousedirection=up;	return; ;; | 	DIAGONAL)	return;	;; | ||||||
|  | 	*)	XJIGGLER_MOUSE_DIRECTION=up;	return; ;; | ||||||
| 	esac | 	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 | getmouselocation; pushmouselocation | ||||||
| 
 | 
 | ||||||
| while true | while true | ||||||
| do | do | ||||||
| 
 | 
 | ||||||
| 	sleep "$XJIGGLER_DETECTION_DELAY" | 	sleep "$XJIGGLER_DELAY_DETECTION" | ||||||
| 	getmouselocation | 	getmouselocation | ||||||
| 	if test "$XJIGGLER_lastX" = "$XJIGGLER_X" \ | 	if test "$XJIGGLER_lastX" = "$XJIGGLER_X" \ | ||||||
| 			&& test "$XJIGGLER_lastY" = "$XJIGGLER_Y" | 			&& test "$XJIGGLER_lastY" = "$XJIGGLER_Y" | ||||||
| 	then	# no movement | 	then	# no movement | ||||||
| 		test "$(printf '%s\n%s\n-\np\n' "$XJIGGLER_T" \ | 		test "$(printf '%s\n%s\n-\np\n' "$XJIGGLER_T" \ | ||||||
| 					"$XJIGGLER_lastT" \ | 					"$XJIGGLER_lastT" \ | ||||||
| 				| dc)" -gt "$XJIGGLER_ACTION_DELAY" \ | 				| dc)" -gt "$XJIGGLER_DELAY_ACTION" \ | ||||||
| 			|| continue	# hasn't been long enough | 			|| continue	# hasn't been long enough | ||||||
| 		rotatemousedirection; jiggle | 		rotatemousedirection; jiggle | ||||||
| 		printf '%s: Jiggled:\n' "$0" | 		printf '%s: Jiggled:\n' "$0" | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user