aboutsummaryrefslogtreecommitdiff
path: root/modules/volumebar
diff options
context:
space:
mode:
authorArchie Hilton (thytom) <archie.hilton1@gmail.com>2019-10-21 23:51:27 +0100
committerArchie Hilton (thytom) <archie.hilton1@gmail.com>2019-10-21 23:51:27 +0100
commite611703e037621493ead5a4c6d4debbdf4597904 (patch)
treecafd929b2e1ec9e1830056c34b5384a1a1feccdc /modules/volumebar
parent63399b33197214c10f2477ee400f2546edda920c (diff)
Added volumebar and mpd modules.
Diffstat (limited to 'modules/volumebar')
-rwxr-xr-xmodules/volumebar35
1 files changed, 35 insertions, 0 deletions
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