Created
November 24, 2012 22:15
-
-
Save vixus0/4141617 to your computer and use it in GitHub Desktop.
Statusbar script for lemonboy's bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
wm=monsterwm | |
ff="/tmp/$RANDOM.monsterwm.fifo" | |
tags=('\ue010' '\ue011' '\ue012' '\ue013' '\ue062') | |
layouts=('\ue002' '\ue001' '\ue003' '\ue005' '\ue006') | |
bs="\\\\u6\\\\b6\\\\f8 " | |
br=" \\\\ur\\\\br\\\\fr" | |
[[ -p $ff ]] || mkfifo -m 600 "$ff" | |
function statusbar { | |
# Date | |
date=$(date +"%H:%M %Y-%m-%d") | |
# Memory usage | |
mem=$(free -m | awk '/buffers\/cache/ {print $3 MB}') | |
# Volume | |
vol=$(amixer get Master | egrep -o '[0-9]{1,3}%' | sed -e 's/%//') | |
mut=$(amixer get Master | grep "\[on\]") | |
ismute="\\\\f3" | |
[ -z $mut ] && ismute="\\\\f2" | |
# Music status | |
music="$(mpc current -f "%artist% - %title%")" | |
if [ -z "$music" ]; then music="stopped" mstat="\ue057" | |
else | |
mstat="$(mpc | sed -rn '2s/\[([[:alpha:]]+)].*/\1/p')" | |
[ "$mstat" == "paused" ] && mstat="\ue059" || mstat="\ue0aa" | |
fi | |
# HDD | |
root=$(df -h|awk '/root/ {print $5}') | |
home=$(df -h|awk '/home/ {print $5}') | |
echo "\\\\c $bs\ue04d$br \\\\f6$mstat\\\\fr $music \\\\r$bs\ue05d$br $ismute$vol $bs\ue09f$br $root $bs\ue0b2$br $home $bs\ue020$br $mem \\\\b2\\\\u2 \\\\f6\ue015\\\\f3 $date " | |
} | |
while read -t 1 -r wmout || true; do | |
if [[ $wmout =~ ^(([[:digit:]]+:)+[[:digit:]]+ ?)+$ ]]; then | |
read -ra desktops <<< "$wmout" | |
tmp= | |
for desktop in "${desktops[@]}"; do | |
IFS=':' read -r d w m c u <<< "$desktop" | |
# Tags labels | |
label=${tags[$d]} | |
# Current desktop color and enclosing char (yes/no) | |
((c)) && fg="2" bg="3" lc="\\\\u6 " rc=" \\\\ur" && layout=${layouts[$m]} || fg="1" bg="0" lc=" " rc=" " | |
# Has windows ? | |
((w)) && ((! c)) && fg="3" lc="\\\\ur " rc=" \\\\ur" | |
# Urgent windows ? | |
((u)) && fg="3" bg="4" lc="\\\\u3 " rc=" \\\\ur" | |
tmp+="\\\\f$fg\\\\b$bg$lc$label$rc\\\\fr\\\\br" | |
done | |
# Merge the clients indications and the tile mode | |
tmp+=" \\\\u2\\\\b2\\\\f3 $layout$br" | |
fi | |
echo -e "$tmp $(statusbar)" | tee /tmp/barout | |
done < "$ff" | bar & | |
#while :; do "$wm" || break; done | tee -a "$ff" | |
$wm > "$ff" | |
rm $ff | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment