aboutsummaryrefslogtreecommitdiff
path: root/Common/rofi/applets/menu/volume.sh
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2021-09-04 12:04:53 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2021-09-04 12:04:53 +0200
commit65b7f91e51d90e93c3d7c6704c0a8265467a8ea7 (patch)
tree88301071c7f1840b502f33cbd3b0f7c5e81b0c66 /Common/rofi/applets/menu/volume.sh
parenta77563ee1044ffa03f7c49e457a5f7c9f943188f (diff)
parente6df7072ab32493a561fc678eacc119b57981827 (diff)
downloaddotfiles-65b7f91e51d90e93c3d7c6704c0a8265467a8ea7.tar.gz
dotfiles-65b7f91e51d90e93c3d7c6704c0a8265467a8ea7.zip
Merge branch 'master' of https://github.com/JakobS1n/dotfiles
Diffstat (limited to 'Common/rofi/applets/menu/volume.sh')
-rwxr-xr-xCommon/rofi/applets/menu/volume.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/Common/rofi/applets/menu/volume.sh b/Common/rofi/applets/menu/volume.sh
new file mode 100755
index 0000000..7e4a0d8
--- /dev/null
+++ b/Common/rofi/applets/menu/volume.sh
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+
+## Author : Aditya Shakya
+## Mail : adi1090x@gmail.com
+## Github : @adi1090x
+## Twitter : @adi1090x
+
+style="$($HOME/.config/rofi/applets/menu/style.sh)"
+
+dir="$HOME/.config/rofi/applets/menu/configs/$style"
+rofi_command="rofi -theme $dir/volume.rasi"
+
+## Get Volume
+#VOLUME=$(amixer get Master | tail -n 1 | awk -F ' ' '{print $5}' | tr -d '[]%')
+MUTE=$(amixer get Master | tail -n 1 | awk -F ' ' '{print $6}' | tr -d '[]%')
+
+active=""
+urgent=""
+
+if [[ $MUTE == *"off"* ]]; then
+ active="-a 1"
+else
+ urgent="-u 1"
+fi
+
+if [[ $MUTE == *"off"* ]]; then
+ active="-a 1"
+else
+ urgent="-u 1"
+fi
+
+if [[ $MUTE == *"on"* ]]; then
+ VOLUME="$(amixer get Master | tail -n 1 | awk -F ' ' '{print $5}' | tr -d '[]%')%"
+else
+ VOLUME="Mute"
+fi
+
+## Icons
+ICON_UP=""
+ICON_DOWN=""
+ICON_MUTED=""
+
+options="$ICON_UP\n$ICON_MUTED\n$ICON_DOWN"
+
+## Main
+chosen="$(echo -e "$options" | $rofi_command -p "$VOLUME" -dmenu $active $urgent -selected-row 0)"
+case $chosen in
+ $ICON_UP)
+ amixer -Mq set Master,0 5%+ unmute && notify-send -u low -t 1500 "Volume Up $ICON_UP"
+ ;;
+ $ICON_DOWN)
+ amixer -Mq set Master,0 5%- unmute && notify-send -u low -t 1500 "Volume Down $ICON_DOWN"
+ ;;
+ $ICON_MUTED)
+ amixer -q set Master toggle
+ ;;
+esac
+