Skip to content

Instantly share code, notes, and snippets.

@urcadox
Created October 21, 2011 19:41
Show Gist options
  • Save urcadox/1304738 to your computer and use it in GitHub Desktop.
Save urcadox/1304738 to your computer and use it in GitHub Desktop.
#!/bin/bash
#RAM
RAM=$(free -m | grep Mem: | awk '{print $3}')
let "ram = $RAM"
RAMBUFFER=$(free -m | grep Mem: | awk '{print $6}')
let "rambuffer = $RAMBUFFER"
RAMCACHE=$(free -m | grep Mem: | awk '{print $7}')
let "ramcache = $RAMCACHE"
let "ramused = ram-(rambuffer+ramcache)"
NETWORK=`/home/urcadox/.config/wmfs/netstat.sh`
# battery state
PERCENT=$((`cat /sys/class/power_supply/BAT0/charge_now`*100/`cat /sys/class/power_supply/BAT0/charge_full`))
if [ $PERCENT -gt 100 ]
then
let "PERCENT = 100"
fi
# Date
DATE=$(date '+%A %d %B - %H:%M:%S')
TRACK=`qdbus org.mpris.clementine /TrackList \
org.freedesktop.MediaPlayer.GetCurrentTrack`
PLAYING=`qdbus org.mpris.clementine /TrackList \
org.freedesktop.MediaPlayer.GetMetadata $TRACK \
| egrep "^(artist:|title:)" | sed -e "s/^.*: //g" \
| sed -e ':a;N;$!ba;s/\n/ - /g' | head -c 45`
PKG=`cat /tmp/nb_pkg_out-of-date`
VOL=`amixer get Master | grep 'Mono:' | cut -d '[' -f 2 | cut -d ']' -f 1`
if [ -n "`mpc | grep playing`" ]
then
PLAYING=$(mpc current)
wmfs -s "$PLAYING | Vol : $VOL | $NETWORK | RAM : $ramused MB | Pkg : $PKG | Bat. : $PERCENT% | $DATE"
elif [ "$TRACK" -ne "-1" ]
then
wmfs -s "$PLAYING | Vol : $VOL | $NETWORK | RAM : $ramused MB | Pkg : $PKG | Bat. : $PERCENT% | $DATE"
else
wmfs -s "$NETWORK | Vol : $VOL | Mem used : $ramused MB | Pkg : $PKG | Bat. : $PERCENT% | $DATE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment