Skip to content

Instantly share code, notes, and snippets.

@retzkek
Created November 19, 2012 23:08
Show Gist options
  • Save retzkek/4114703 to your computer and use it in GitHub Desktop.
Save retzkek/4114703 to your computer and use it in GitHub Desktop.
Simple xsetroot script for dwm with battery level and date
#!/bin/sh
export DISPLAY=:0
BATT=$(/usr/bin/awk '/rate/ {rate=$3} \
/charging state/ {charge=$3} \
/rem/ { rem=$3 } \
END { if (charge=="charging") { state="charge" } \
else if (charge=="charged") { state="full" } \
else { state=sprintf("%2.1f hr",rem/rate) } \
printf("%3.1f%% (%s)",rem/50,state) }' \
/proc/acpi/battery/BAT0/state)
DATE=$(/bin/date +"%a %b %d %H:%M")
ROOT="$BATT $DATE"
#echo $ROOT
xsetroot -name "$ROOT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment