-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove_window_monitor.sh
More file actions
executable file
·47 lines (35 loc) · 1.06 KB
/
move_window_monitor.sh
File metadata and controls
executable file
·47 lines (35 loc) · 1.06 KB
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
#!/bin/bash
# screen width (the effective resolution! just set yours here.)
screen_width1=1920
screen_width2=1920
# active window
window=`xdotool getactivewindow`
# get active window size and position
x=`xwininfo -id $window | grep "Absolute upper-left X" | awk '{print $4}'`
w=`xwininfo -id $window | grep "Width" | awk '{print $2}'`
maximized=false
# window on left monitor
if [ "$x" -lt "$screen_width1" ]; then
if [ "$w" -eq "$screen_width1" ]; then
maximized=true
fi
if $maximized; then
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
fi
wmctrl -r :ACTIVE: -e 0,$screen_width1,-1,-1,-1
if $maximized; then
wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
fi
# window on right monitor
else
if [ "$w" -eq "$screen_width2" ]; then
maximized=true
fi
if $maximized; then
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
fi
wmctrl -r :ACTIVE: -e 0,0,-1,-1,-1
if $maximized; then
wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
fi
fi