2015-05-29 21:08:06 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-06-05 01:04:15 +02:00
|
|
|
cd $(dirname $0)
|
|
|
|
|
2015-05-29 21:08:06 +02:00
|
|
|
icon_color="#A0A57E"
|
|
|
|
icon() { echo -n "%{F$icon_color}"; printf '%b' "\ue$1"; echo -n "%{F-}"; }
|
|
|
|
|
|
|
|
icon_music=$(icon 05c)
|
|
|
|
icon_music_paused=$(icon 059)
|
|
|
|
icon_services=$(icon 040)
|
|
|
|
icon_diskspace=$(icon 0ab)
|
|
|
|
icon_wifi=$(icon 048)
|
|
|
|
icon_battery=$(icon 033)
|
|
|
|
icon_battery_charging=$(icon 042)
|
|
|
|
icon_clock=$(icon 018)
|
|
|
|
|
|
|
|
color_service_running="#A0A57E"
|
|
|
|
color_service_stopped="#C37561"
|
|
|
|
color_battery_good="white"
|
|
|
|
color_battery_low="#C37561"
|
|
|
|
|
|
|
|
music() {
|
2015-06-05 01:04:15 +02:00
|
|
|
info=$(mpc current -f '[%title%]')
|
2015-05-29 21:08:06 +02:00
|
|
|
icon=$icon_music
|
2015-06-05 01:04:15 +02:00
|
|
|
if [ -n "$info" ]; then
|
|
|
|
if [ -n "$(mpc status | grep paused)" ]; then
|
|
|
|
icon=$icon_music_paused
|
|
|
|
fi
|
|
|
|
echo -n "%{A:I "music 20":}$icon $info%{A}"
|
|
|
|
else
|
|
|
|
echo -n "$icon (-)"
|
2015-05-29 21:08:06 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
serviceinfo() {
|
|
|
|
service=$1
|
|
|
|
text=$2
|
|
|
|
systemctl is-active -q $service
|
|
|
|
if [ "$?" -eq 0 ]; then
|
|
|
|
echo -n "%{F$color_service_running}$text%{F-}"
|
|
|
|
else
|
|
|
|
echo -n "%{F$color_service_stopped}$text%{F-}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
services() {
|
|
|
|
echo -n "$icon_services $(serviceinfo zomnet z) $(serviceinfo docker d)"
|
|
|
|
}
|
|
|
|
|
|
|
|
diskspace() {
|
2015-06-05 01:04:15 +02:00
|
|
|
info=$(df -h / | awk '{if($6 == "/") { print $5 }}')
|
|
|
|
echo -n "%{A:I "filesystem 30":}$icon_diskspace $info%{A}"
|
2015-05-29 21:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi() {
|
2015-06-05 01:04:15 +02:00
|
|
|
info=$(wicd-cli --wireless --status | perl -e 'foreach $line (<>) { if($line =~ /Connected to (.+) at .+IP: ([0-9.]+)/ ) { print $1; break; } elsif($line =~ /Connecting to wireless network \"(.+)\"/) { print $1 . " - connecting"; break; } }')
|
2015-05-29 21:08:06 +02:00
|
|
|
if [ -z "$info" ]; then
|
|
|
|
info="(-)"
|
|
|
|
fi
|
2015-06-05 01:04:15 +02:00
|
|
|
echo -n "%{A:I "network 1061":}$icon_wifi $info%{A}"
|
2015-05-29 21:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
battery() {
|
|
|
|
level=$(acpi -b | awk -F, 'BEGIN { s=0 } { s+=$2 } END { print int(s/NR) }')
|
2015-06-05 01:04:15 +02:00
|
|
|
charging=$(acpi -a | grep on-line)
|
|
|
|
|
|
|
|
icon=$icon_battery
|
2015-05-29 21:08:06 +02:00
|
|
|
if [ -n "$charging" ]; then
|
2015-06-05 02:43:17 +02:00
|
|
|
icon=$icon_battery_charging
|
2015-05-29 21:08:06 +02:00
|
|
|
fi
|
2015-06-05 01:04:15 +02:00
|
|
|
info="%{F$color_battery_good}$level%%{F-}"
|
2015-05-29 21:08:06 +02:00
|
|
|
if [ "$level" -lt 20 ]; then
|
|
|
|
echo -n "%{F$color_battery_low}$level%%{F-}"
|
|
|
|
fi
|
2015-06-05 01:04:15 +02:00
|
|
|
|
|
|
|
echo -n "%{A:I "battery 1061":}$icon $info%{A}"
|
2015-05-29 21:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
clock() {
|
2015-06-05 01:04:15 +02:00
|
|
|
info=$(date +"%H:%M")
|
|
|
|
echo -n "%{A:I "clock 1061":}$icon_clock $info%{A}"
|
|
|
|
}
|
|
|
|
|
|
|
|
run_handler() {
|
|
|
|
while read type param; do
|
|
|
|
case $type in
|
|
|
|
I)
|
|
|
|
pkill dzen2
|
|
|
|
./barinfo.sh $param &
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2015-05-29 21:08:06 +02:00
|
|
|
}
|
|
|
|
|
2015-06-05 01:04:15 +02:00
|
|
|
|
2015-05-29 21:08:06 +02:00
|
|
|
while true; do
|
|
|
|
echo "%{l} $(music) $(services) $(diskspace)%{r}$(wifi) $(battery) $(clock) "
|
|
|
|
sleep 1
|
2015-06-05 01:04:15 +02:00
|
|
|
done | lemonbar -g 1366x15 -f "Terminus:size=8","Stlarch:size=6:style=regular" -B "#88000000" | run_handler
|
2015-05-29 21:08:06 +02:00
|
|
|
|