dotfiles

config files for my linux setup
git clone git://edryd.org/dotfiles
Log | Files | Refs | README

dwmstatus.sh (930B)


      1 #!/usr/bin/env bash
      2 
      3 while true; do
      4 	status=""
      5 	if [ -r ~/.dwm.msg ]; then
      6 		while read line; do
      7 			status+=" $line"
      8 			xsetroot -name "$(echo -e "$status")"
      9 			sleep 1
     10 		done < ~/.dwm.msg
     11 	else
     12 		song=$(basename "$(cmus-remote -Q | grep file | cut -d ' ' -f 2-)" .mp3)
     13 		ramused=$(free -m  | grep Mem | awk '{print $3}')
     14 		ramtotal=$(free -m | grep Mem | awk '{print $2}')
     15 		cpuperc=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
     16 		temp=$(curl -s wttr.in | head -4 | tail -1 | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | rev | sed -e 's/^[ \t]*//' | cut -d " " -f 1,2 | rev | tr -d " ")
     17 
     18 		if [[ $(cmus-remote -Q | grep status) == "status playing" ]]; then
     19 			status+="$song"
     20 		fi
     21 		status+="$cpuperc"
     22 		status+="$(echo "$ramused"*100/"$ramtotal" | bc)%"
     23 		status+="$temp"
     24 		status+="$(date +"%b %d %I:%M")"
     25 
     26 		xsetroot -name "$(echo -e "$status")"
     27 		sleep 1
     28 	fi
     29 done
     30