diff options
| -rw-r--r-- | TODO.org | 8 | ||||
| -rwxr-xr-x | modules/mpd | 24 | ||||
| -rwxr-xr-x | modules/volumebar | 35 |
3 files changed, 63 insertions, 4 deletions
@@ -11,15 +11,15 @@ Each module writes to stdout. * Todo List -Modules: -- MPD (archie) +Modules to Write: - Disk Usage - Mail - CPU Usage -- Volume Bar (archie) - Memory Usage -Finished Modules: +Working Modules: +- Volume Bar +- MPD - Backlight - Network - Volume diff --git a/modules/mpd b/modules/mpd new file mode 100755 index 0000000..5db0d64 --- /dev/null +++ b/modules/mpd @@ -0,0 +1,24 @@ +#!/bin/bash + +PREFIX_PLAY=' ' +PREFIX_PAUSE=' ' + +get_mpd() +{ + current_song=$(mpc current) + + if [[ "$current_song" = "" ]]; then + exit 0 + else + playpause=$(mpc | awk '/\[.*]/{split($0, a, " "); print a[1]}') + if [[ "$playpause" = "[playing]" ]]; then + current_song=$PREFIX_PLAY$current_song + elif [[ "$playpause" = "[paused]" ]]; then + current_song=$PREFIX_PAUSE$current_song + fi + fi + + echo $current_song +} + +get_mpd diff --git a/modules/volumebar b/modules/volumebar new file mode 100755 index 0000000..aab9cee --- /dev/null +++ b/modules/volumebar @@ -0,0 +1,35 @@ +#!/bin/bash + +# Prints out the volume percentage + +VOLUME_WIDTH=15 +VOLUME_SLIDER='|' +VOLUME_RAIL='-' +VOLUME_MUTED='muted' + +PREFIX='VOL' + +get_volume(){ + active_sink=$(pacmd list-sinks | awk '/* index:/{print $3}') + curStatus=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | awk '/muted/{ print $2}') + volume=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | grep 'volume:' | grep -E -v 'base volume:' | awk -F : '{print $3}' | grep -o -P '.{0,3}%'| sed s/.$// | tr -d ' ') + slider_position=$(( $volume / $VOLUME_WIDTH )) + + if [ "${curStatus}" = 'yes' ] + then + echo "$VOLUME_MUTED" + exit 0 + else + for i in $(seq 1 $slider_position); do + BAR=$BAR$VOLUME_RAIL + done + BAR=$BAR$VOLUME_SLIDER + for i in $(seq $slider_position $VOLUME_WIDTH); do + BAR=$BAR$VOLUME_RAIL + done + fi + + echo "$PREFIX$BAR" +} + +get_volume |
