dots

Personal dotfiles
git clone git://git.gormless.xyz/dots.git
Log | Files | Refs

health (759B)


      1 #!/bin/sh
      2 
      3 bat() {
      4 	bat=$(apm -l)
      5 	printf "$bat\n"
      6 }
      7 
      8 charge() {
      9 	[ "$(apm -a)" = "1" ]
     10 }
     11 
     12 temp() {
     13 	sysctl hw.sensors.cpu0.temp0 | cut -d= -f2 | cut -d. -f1
     14 }
     15 
     16 clock() {
     17 	date '+%a %Y %m/%d %I:%M %p'
     18 }
     19 
     20 if [ $# -gt 0 ]
     21 then
     22 	printf "TAG:notify\t\
     23 IMG:$HOME/var/theme/icons/system/health.png\t\
     24 $(clock)\t\
     25 Battery: %s%% (%s)\t\
     26 Temperature: %s°C\
     27 " "$(bat)" "$(charge && echo charging || echo draining)" "$(temp)"   >"$HOME/var/cache/xnotify"
     28 	exit 0
     29 fi
     30 
     31 while true
     32 do
     33 	! charge && [ "$(bat)" -lt 20 ] && echo "SEC:0	TAG:power	IMG:$HOME/var/theme/icons/system/power.png	Battery is low: $(bat)%"
     34 	[ "$(temp)" -gt 80 ] && echo "SEC:5	TAG:temp	IMG:$HOME/var/theme/icons/system/health.png	Temperature is at $(temp)°C"
     35 	sleep 60
     36 done >"$HOME/var/cache/xnotify"