-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbspwm-taskbar-2
executable file
·65 lines (55 loc) · 1.82 KB
/
bspwm-taskbar-2
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
#!/bin/sh
# A bspwm taskbar that shows each window of the current desktop, for use with
# polybar or lemonbar. Each window gets assigned a one-symbol label, which you
# can use to jump to it.
program="$(realpath $0)"
# Foreground & background for focused & unfocused windows
ff="#ffffff"
bf="#302925"
fu="#302925"
bu="#e9e2d2"
icon(){
case $(xprop -id $1 WM_CLASS | cut -d'"' -f4) in
Firefox-esr) echo " " ;;
URxvt) echo " " ;;
TelegramDesktop) echo " " ;;
esac
}
title(){
xdotool getwindowname $1 | awk -v len=40 '{ sub(/— Mozilla Firefox$/, "", $0); if (length($0) > len) print "…" substr($0, length($0)-len+1, length($0)); else print; }'
}
# Produce statusline at current moment
statusline(){
# Current / max desktops
echo -n "%{R} $(bspc query -D | grep -n $(bspc query -D -d) | cut -f1 -d:)"
echo -n "/$(bspc query -D | wc -l) %{F-}%{B-}"
i=1
for win in $(bspc query -N -n '.window'); do
local title="$(title $win)"
local icon="$(icon $win)"
echo -n "%{A1:bspc node $win --focus:}"
if bspc query -N -n "$win.!local" > /dev/null; then
echo -n " %{F$bf}$icon$title"
elif bspc query -N -n $win.focused > /dev/null; then
echo -n " %{F$bf}%{F$ff}%{B$bf}$icon$title%{B-}%{F$bf}"
else
echo -n " %{F$bu}%{F$fu}%{B$bu}$icon$title%{B-}%{F$bu}"
fi
echo -n "%{A1}"
i=$((i+1))
done
echo
}
# If an argument was provided, assume it was a function we want to execute
if [ ! -z "$1" ]; then
"$@"
exit $?
# Otherwise, assume we are monitoring to produce a statusline
else
bspc subscribe report | while read line; do
statusline
done
# | lemonbar \
# -f "-*-cozette-medium-r-*--13-*" \
# -B '#ffffff' -F '#000000' | sh
fi