From bb788dddf67c67d8ccd8f365187fea4d470a5d11 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Mon, 21 Oct 2019 20:09:02 +0100 Subject: Added volume module --- modules/volume | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 modules/volume (limited to 'modules/volume') diff --git a/modules/volume b/modules/volume new file mode 100755 index 0000000..27bb7dd --- /dev/null +++ b/modules/volume @@ -0,0 +1,21 @@ +#!/bin/bash + +# Prints out the volume percentage + +VOLUME_ON_ICON='' +VOLUME_MUTED_ICON='' + +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 ' ') + + if [ "${curStatus}" = 'yes' ] + then + echo "$VOLUME_MUTED_ICON $volume%" + else + echo "$VOLUME_ON_ICON $volume%" + fi +} + +get_volume -- cgit v1.2.3