blob: 901bb28049b89ce6ea6d948563e74f1128861781 (
plain)
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
|
#!/bin/bash
DIR=$(dirname $(realpath $0))
WINDOW_ID_CONKY=/tmp/conky_window_id
WINDOW_ID_TOP=/tmp/polybar_top_window_id
WINDOW_ID_EXPANDED=/tmp/polybar_expanded_window_id
conky_launch() {
# Hacky X11 magic to make Conky appear above polybar
killall conky
# xdotool search can't find Conky's window but fortunately Conky outputs it
conky -c ~/.config/conky/config 2> /tmp/conky_out
# Extract the hex window id from Conky's output
HEX=$(awk '/drawing to created window/ {print $NF}' /tmp/conky_out | tr -d '()' | awk -Fx '{print $2}')
WIN_ID=$(( 16#$HEX )) # convert to decimal
xdotool windowunmap $WIN_ID
echo $WIN_ID > $WINDOW_ID_CONKY
}
polybar_launch() {
killall polybar
polybar top &
xdotool search --sync --pid $! > $WINDOW_ID_TOP
polybar expanded &
xdotool search --sync --pid $! > $WINDOW_ID_EXPANDED
bar_collapse
}
launch() {
# Temporarily disable conky until I update the config
# conky_launch
# sleep 0.2
polybar_launch
}
bar_expand() {
xdotool windowmap $(cat $WINDOW_ID_EXPANDED)
xdotool windowunmap $(cat $WINDOW_ID_TOP)
}
bar_collapse() {
xdotool windowunmap $(cat $WINDOW_ID_EXPANDED)
xdotool windowmap $(cat $WINDOW_ID_TOP)
}
rofi_open() {
options_close
bar_expand &
rofi -modi run -show run
bar_collapse
}
drun_open() {
bar_expand &
rofi -theme drun -modi drun -show drun -drun-categories Custom
bar_collapse
}
search_open() {
options_close
bar_expand &
rofi -theme window -modi window -show window
bar_collapse
}
options_open() {
bar_expand
$DIR/rofi_option_menu
bar_collapse
# echo "open" > /tmp/polybar_side_panel_state
# ID_CONKY=$(cat $WINDOW_ID_CONKY)
# xdotool windowmap $ID_CONKY
# xdotool windowraise $ID_CONKY
# ~/.config/i3/scripts/music_player show_applet
}
case "$1" in
rofi)
rofi_open;;
search)
search_open;;
drun)
drun_open;;
options)
options_open;;
launch)
launch;;
esac
|