diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2012-07-08 04:00:15 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2012-07-08 04:00:45 +0200 |
commit | 3c6cf7ee3eb1cd768072b21c569a69428bf3ce4c (patch) | |
tree | 44309ce9656e4c8a157c7ce6d4c5af7fd7903ce7 /bin | |
download | dzen2-config-3c6cf7ee3eb1cd768072b21c569a69428bf3ce4c.tar.gz dzen2-config-3c6cf7ee3eb1cd768072b21c569a69428bf3ce4c.tar.xz dzen2-config-3c6cf7ee3eb1cd768072b21c569a69428bf3ce4c.zip |
inital commit
Diffstat (limited to 'bin')
-rw-r--r-- | bin/bat.sh | 40 | ||||
-rw-r--r-- | bin/clock.sh | 25 | ||||
-rw-r--r-- | bin/dzen2_pgrp.sh | 21 | ||||
-rw-r--r-- | bin/mem.sh | 21 | ||||
-rw-r--r-- | bin/sound.sh | 25 |
5 files changed, 132 insertions, 0 deletions
diff --git a/bin/bat.sh b/bin/bat.sh new file mode 100644 index 0000000..e546209 --- /dev/null +++ b/bin/bat.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +STATEFILE='/proc/acpi/battery/BAT0/state' # battery's state file +INFOFILE='/proc/acpi/battery/BAT0/info' # battery's info file + +while true +do + BAT_FULL=`cat $INFOFILE | grep "last full" |cut -d " " -f 9`; + STATUS=`cat $STATEFILE | grep charging |cut -d " " -f 12`; + RCAP=`cat $STATEFILE | grep remaining |cut -d " " -f 8`; + + RPERCT=`expr $RCAP \* 100`; + RPERC=`expr $RPERCT / $BAT_FULL`; + + echo -n '^p(10)' + + if [ $RPERC -ge 100 ] + then + RPERC=100 + fi + + # draw the bar and pipe everything into dzen + COLOR="#999" + IMAGE="power-ac" + + if [ "$STATUS" == "discharging" ] + then + if [ $RPERC -le 20 ] + then + COLOR="#f00" + IMAGE="power-bat-empty" + else + IMAGE="power-bat-full" + fi + fi + + echo $RPERC | gdbar -h 6 -w 50 -fg "${COLOR}" -bg '#444' -l "^i(/home/alex/.dzen2/icons/${IMAGE}.xbm) " -nonl + echo " ${RPERC}%" + sleep 5; +done diff --git a/bin/clock.sh b/bin/clock.sh new file mode 100644 index 0000000..5b54a6a --- /dev/null +++ b/bin/clock.sh @@ -0,0 +1,25 @@ +#!/bin/sh +OLD_TODAY=0 + +while /bin/true +do + echo "^tw() ^fg(#ff0000)`date`" + + TODAY=$(expr `date +'%d'` + 0) + + if [ $TODAY -ne $OLD_TODAY ] + then + MONTH=`date +'%m' | sed "s/^0//"` + YEAR=`date +'%Y'` + [ $MONTH -eq 12 ] && YEAR=$(($YEAR + 1)) + OLD_TODAY=$TODAY + + echo "^cs()" + echo + cal -m | sed "s/$/ /;s/^\(.\{20\}\).*$/\1/" | sed -u -re "s/(^|[ ])($TODAY)($|[ ])/\1^fg(#ff0000)\2^fg()\3/" + echo " " + cal -m $((($MONTH % 12) +1)) $YEAR | sed "s/$/ /;s/^\(.\{20\}\).*$/\1/" + fi + + sleep 1 +done diff --git a/bin/dzen2_pgrp.sh b/bin/dzen2_pgrp.sh new file mode 100644 index 0000000..0473db8 --- /dev/null +++ b/bin/dzen2_pgrp.sh @@ -0,0 +1,21 @@ +#!/bin/sh +DIR="${HOME}/.dzen2/" + +cat $* | dzen2 -xs 1 -x 0 -w 1223 -ta l -fn '-*-terminus-medium-r-normal-*-12-*-*-*-*-*-*-*' -bg black -e 'button1=none' & +MAIN=$! + +sh "${DIR}/bin/bat.sh" | dzen2 -xs 1 -x 1360 -w 120 -fn '-*-terminus-medium-r-normal-*-12-*-*-*-*-*-*-*' -bg black -e 'button1=none' & + +sh "${DIR}/bin/clock.sh" | dzen2 -xs 1 -x 1480 -w 200 -fn '-*-terminus-medium-r-normal-*-12-*-*-*-*-*-*-*' -bg black -l 17 -p -sa c -e 'button1=exec:xscreensaver-command -lock;button3=exec:xcalendar;button2=exec:xscreensaver-command -prefs;onstart=collapse;entertitle=uncollapse,unhide;leavetitle=collapse' & + +gcpubar -fg '#999' -bg '#444' -w 50 -h 7 -l "^i(${DIR}/icons/cpu.xbm) " | sed -u 's/#D56F6C/#ff0000/' | dzen2 -xs 1 -x 1240 -w 120 -fn '-*-terminus-medium-r-normal-*-12-*-*-*-*-*-*-*' -bg black -e 'button1=none' & + +sh "${DIR}/bin/sound.sh" | dzen2 -xs 1 -x 1223 -tw 17 -w 100 -fn '-*-terminus-medium-r-normal-*-12-*-*-*-*-*-*-*' -bg black -sa c -l 1 -e 'entertitle=uncollapse,unhide;leavetitle=collapse;button1=exec:amixer -q -c0 set Master toggle;button2=exec:pavucontrol;button3=exec:amixer -c0 -- set Master playback 80%;button4=exec:amixer -c0 -- set Master playback 2%+;button5=exec:amixer -c0 -- set Master playback 2%-' & + +# kill bars on new RandR config +( ${DIR}/bin/xrandr-notify && kill ${MAIN} ) & + +wait $MAIN + +# kill all +kill -TERM -$$ diff --git a/bin/mem.sh b/bin/mem.sh new file mode 100644 index 0000000..decc2fd --- /dev/null +++ b/bin/mem.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +AWKS='/MemTotal/ {mtotal=$2}; +/MemFree/ {mfree=$2}; +/Active/ {mactive=$2}; +/^Cached/ {mcached=$2}; +/SwapTotal/ {swtotal=$2}; +/SwapFree/ {swfree=$2}; +END { + print mtotal-mfree " " mtotal; + print mactive " " mtotal; + print mcached " " mtotal; + print swtotal-swfree " " swtotal; }' + +echo "$AWKS" +#while echo ' ^tw()Mem: +#Active: +#Cached: +#Swap : ' | paste -d ' ' - < (awk "$AWKS" /proc/meminfo | gdbar -fg '#aecf96' -bg '#37383a' -w 50 -h 7); do +#sleep 5 +#done diff --git a/bin/sound.sh b/bin/sound.sh new file mode 100644 index 0000000..036b1c0 --- /dev/null +++ b/bin/sound.sh @@ -0,0 +1,25 @@ +function print_mute { + local stat VOL MUTE + + stat=$(amixer -c0 get Master | grep "Front Left:") + VOL=$(sed 's/^.*\[\(.*\)%\].*$/\1/g' <<< "${stat}") + MUTE=$(sed 's/^.*\[\([^\[]*\)\]$/\1/g' <<< "${stat}") +# VOL=$(amixer -c0 get Master | grep " 0:" | awk '{ print $6 }') + +# VOL=$(aumix -d /dev/mixer -q l | grep vol | awk '{ print $3 }') +# MUTE=${VOL} + if [ "${MUTE}" == "off" -o "${MUTE}" == "0" ] + then + echo "^tw()^fg(#FF0000)^i(/home/alex/.dzen2/icons/vol-mute.xbm)" + else + echo "^tw()^fg()^i(/home/alex/.dzen2/icons/vol-hi.xbm)" + fi + + echo "$(echo "$VOL" | tail -n 1)" | gdbar -h 6 -w 50 -fg '#999' -bg '#444' +} + +print_mute +inotifywait -q -m /dev/snd/controlC0 -e ACCESS | while read i +do + print_mute +done |