-
Notifications
You must be signed in to change notification settings - Fork 0
/
i3_mouse_move.sh
executable file
·97 lines (81 loc) · 1.96 KB
/
i3_mouse_move.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
# path: /home/klassiker/.local/share/repos/i3/i3_mouse_move.sh
# author: klassiker [mrdotx]
# github: https://github.com/mrdotx/i3
# date: 2024-03-05T07:46:38+0100
# speed up script by using standard c
LC_ALL=C
LANG=C
# i3 helper
. i3_helper.sh
script=$(basename "$0")
help="$script [-h/--help] -- move mouse pointer to the edge of the monitor
Usage:
$script [nw/ne/se/sw] [notification]
Settings:
[nw/ne/se/sw] = position to move the mouse pointer
[notification] = if the value is specified, suppress notification
Examples:
$script ne
$script ne 0"
get_mouse_location() {
eval "$(xdotool getmouselocation --shell)"
printf "%sx%s" "$X" "$Y"
}
move_mouse() {
[ -z "$1" ] \
&& printf "%s\n" "$help" \
&& return 1
resolution=$(xrandr \
| head -n1 \
| cut -d" " -f8,10 \
| tr -d ","
)
resolution_x=${resolution%% *}
resolution_y=${resolution##* }
case "$1" in
nw)
position_icon=""
x=0
y=0
;;
ne)
position_icon=""
x="$resolution_x"
y=0
;;
se)
position_icon=""
x="$resolution_x"
y="$resolution_y"
;;
sw)
position_icon=""
x=0
y="$resolution_y"
;;
esac
case "$2" in
"")
title="mouse"
message="mouse pointer moved [$position_icon]"
message="$message\nfrom $(get_mouse_location)"
i3_notify 0 "$title" "$message"
xdotool mousemove "$x" "$y"
sleep .5
i3_notify 2500 "$title" "$message to $(get_mouse_location)"
;;
*)
xdotool mousemove "$x" "$y"
;;
esac
}
case "$1" in
-h | --help)
printf "%s\n" "$help"
exit
;;
*)
move_mouse "$1" "$2"
;;
esac