-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbspc-pip
executable file
·79 lines (68 loc) · 1.74 KB
/
bspc-pip
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
#!/usr/bin/env bash
# Definition of picture-in-picture mode
# 1. Should be a video player
# 2. Should be stickied
# 3. Should be floating
# 4. Should be on top layer (above)
is_video() {
# Check for WM_NAME
local wmname=$(xprop WM_NAME -id $(xdotool getactivewindow) \
| cut -d'=' -f2 \
| tr '[:upper:]' '[:lower:]')
case "${wmname}" in
*firefox* | *mpv*)
local is_video=true
;;
*)
local is_video=false
esac
echo $is_video
}
is_in_pip_mode() {
# Check for floating status
bspc query -N -n focused.floating > /dev/null
if [ $? -eq 0 ]; then
local is_floating=true
else
local is_floating=false
fi
# Check for sticky status
bspc query -N -n focused.sticky > /dev/null
if [ $? -eq 0 ]; then
local is_sticky=true
else
local is_sticky=false
fi
# Check if layer is above
bspc query -N -n focused.above > /dev/null
if [ $? -eq 0 ]; then
local is_above=true
else
local is_above=false
fi
if ($(is_video) && $is_floating && $is_sticky && $is_above); then
echo true
else
echo false
fi
}
if ($(is_video)); then
if ! ($(is_in_pip_mode)); then
bspc node --state floating
bspc node --flag sticky=on
bspc node --layer above
resolution=($(getRes))
monitor_width=${resolution[0]}
monitor_height=${resolution[1]}
wanted_width="$((monitor_width / 3))"
wanted_height="$((monitor_height / 3))"
cur_width="$(returnWindowInfo.sh w)"
cur_height="$(returnWindowInfo.sh h)"
diff_width="$(( cur_width - wanted_width ))"
diff_height="$(( cur_height - wanted_height ))"
bspc node -z bottom_right "-$diff_width" "-$diff_height"
~/.bin/bspc-smartmove top-right
else
bspc node -t ~floating -g sticky=off -l normal
fi
fi