-
Notifications
You must be signed in to change notification settings - Fork 2
/
panel
executable file
·111 lines (94 loc) · 3.19 KB
/
panel
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/sh
#
# lemonbar by jastronaut
#
# get settings
. ~/bin/panel_config
function printDate()
{
date '+%a %b %d %H:%M'
}
function launchKeyboard()
{
echo -e "${AC}onboard${AB} $KEYB ${AE}"
}
function volume()
{
vol=$(amixer get Master | grep % | sed -n 1p | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
if [ $vol = '0%' ];
then echo -e "%{F$LABEL}VOL MUTED%{F-}"
else
echo -e "%{F$LABEL}VOL%{F-} $vol"
fi
}
function brightness
{
echo -e "%{F$LABEL}LUM%{F-} $(xbacklight -get | sed 's/\..*//')"
}
function battery()
{
bat=$(acpi -b | grep -P -o '[0-9]+(?=%)')
ch_state=$(acpi -b | cut -c12-19)
ch=""
if [[ $ch_state = "Charging" ]]; then
ch='*'
fi
if [ $bat -le 100 ] && [ $bat -ge 80 ]; then
echo -e "%{F$LABEL}BAT %{F-}%{F$PINK}$FULL $FULL $FULL $FULL $FULL%{F-}%{F$GRE} $bat%%{F-}%{F$YEL}$ch%{F-}"
elif [ $bat -lt 80 ] && [ $bat -ge 60 ]; then
echo -e "%{F$LABEL}BAT %{F-}%{F$PINK}$FULL $FULL $FULL $FULL%{F-} $EMPTY%{F$GRE} $bat%%{F-}%{F$YEL}$ch%{F-}"
elif [ $bat -lt 60 ] && [ $bat -ge 40 ]; then
echo -e "%{F$LABEL}BAT %{F-}%{F$PINK}$FULL $FULL $FULL%{F-} $EMPTY $EMPTY%{F$GRE} $bat%%{F-}%{F$YEL}$ch%{F-}"
elif [ $bat -lt 40 ] && [ $bat -ge 20 ]; then
echo -e "%{F$LABEL}BAT %{F-}%{F$PINK}$FULL $FULL%{F-} $EMPTY $EMPTY $EMPTY%{F$GRE} $bat%%{F-}%{F$YEL}$ch%{F-}"
else
echo -e "%{F$LABEL}BAT %{F-} %{F$PINK}$FULL%{F-} $EMPTY $EMPTY $EMPTY $EMPTY%{F$PINK} $bat%%{F-}%{F$YEL}$ch%{F-}"
fi
}
function mpd()
{
cur_song="$(basename "$(mpc current -f "%artist% - %title%")" | cut -c1-50)"
cur_album="$(mpc current -f "%album%")"
if [ -z "$cur_song" ];
then echo "Stopped"
else
paused=$(mpc | grep paused)
[ -z "$paused" ] && toggle="${AC}mpc pause${AB}pause${AE}" ||
toggle="${AC}mpc play${AB}play${AE}"
prev="${AC}mpc prev${AB}${ICO_PREV}${AE}"
next="${AC}mpc next${AB}${ICO_NEXT}${AE}"
echo "$cur_song %{F$LABEL}$prev $toggle $next%{F-}"
fi
}
# change desktops and show current desktop
function desk()
{
#number of currently active workspace
cur=$( xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}' )
#incremented by 1, because 0th member in $wss is the whole array(useless)
cur=$((cur+1))
#gives array of all active workspaces' labels
wss=$( xprop -root _NET_DESKTOP_NAMES | cut -c34-100 | tr -d '"' | tr -d ',' )
#number of active workspaces
wss_count=${#wss[@]}
#Label of the current workspace(could possibly be shortened by using $wss, since the beginning is the same)
cur_ws=$( xprop -root _NET_DESKTOP_NAMES | cut -c34-100 | tr -d '"' | tr -d ',' | awk '{print $($cur)}' )
#A counter used to indicate when we reached the active workspace(there are probably better ways)
declare -i n=1
#Iterates thru $wss array and prints the labels in one line(\c) while indicating the current one
for x in $wss;
do
if [ "$cur" == "$n" ]
then
echo -e "${AC}$moveto $x${AB}%{U$ACCCENT}%{+u} $x %{-u} ${AE}\c"
else
echo -e "${AC}$moveto $x${AB} $x ${AE}\c"
fi
n=$((n+1))
done
}
# print out the stuff in the grossest manner possible
while :; do
echo -e "%{l} $(desk) $(mpd)%{c}$(printDate)%{r}$(launchKeyboard) $(brightness) $(volume) $(battery) "
sleep 0.75
done | lemonbar -g ${PW}x${PH}+${PX}+${PY} -f "$FONT" -f "$ICO_FONT" -u 4px -F "$FG" -B "$BG" -p | sh