Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 112 lines (94 sloc) 3.19 KB
#!/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
You can’t perform that action at this time.