dotfiles

My dotfiles for Arch Linux
git clone git://git.janispagel.de/dotfiles.git
Log | Files | Refs | README

statusbar (1047B)


      1 #!/bin/dash
      2 
      3 update_statusbar() {
      4 
      5 	if [ $(amixer get Master | tail -1 | cut -d' ' -f8 | tr -d '[' | tr -d ']') = 'on' ]
      6 	then
      7 		VOL="$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')"
      8 	else
      9 		VOL="muted"
     10 	fi
     11 	LOCALTIME=$(date +"%Y-%m-%d %R")
     12 	UTC=$(TZ=UTC date -Iseconds)
     13 	IP="$(for i in `ip r`; do echo $i; done | grep -A 1 src | tail -n1)"
     14 	if [ -d "/proc/sys/net/ipv4/conf/tun0" ]; then VPN="yes"; else VPN="no"; fi
     15 	#TEMP="$(($(cat /sys/class/thermal/thermal_zone0/temp) / 1000))°C"
     16 	BAT="$(acpi -b | awk '{ print $4 " " }' | tr -d ',' | tr -d ' ')"
     17 	CURRENT_SONG="$(mpc --format "[[%composer%|%artist%][ - %album%][ - %title%] | [%file%]]" current)"
     18 	VERSION="dwm-6.2"
     19 
     20 	xsetroot -name " 🕓 $LOCALTIME | 🔊 $VOL |   $IP | 🚆 $VPN |   $TEMP |   $BAT | 🎼 $CURRENT_SONG | $VERSION"
     21 }
     22 
     23 
     24 CURRENTSTATUS=$(pgrep -x statusbar | wc -l)
     25 if [ "$CURRENTSTATUS" -ge "3" ]
     26 then
     27 	xsetroot -name "$VERSION"
     28 	killall statusbar
     29 else
     30 	trap update_statusbar USR1
     31 	while true
     32 	do
     33 		update_statusbar
     34 		sleep 30 &
     35 		wait
     36 	done
     37 fi