aboutsummaryrefslogtreecommitdiff
path: root/linux/rofi/applets/android/volume.sh
diff options
context:
space:
mode:
authorjakob.stendahl <jakob.stendahl@infomedia.dk>2024-01-23 11:13:18 +0100
committerjakob.stendahl <jakob.stendahl@infomedia.dk>2024-01-23 11:13:18 +0100
commit72efe134f645a5212f875c153dd8db4a64cbe968 (patch)
treed23229285071bf381515657b94919852ebf426c9 /linux/rofi/applets/android/volume.sh
parente33d5f8d10d34e5a3a4bb292015961dd574f4c93 (diff)
downloaddotfiles-72efe134f645a5212f875c153dd8db4a64cbe968.tar.gz
dotfiles-72efe134f645a5212f875c153dd8db4a64cbe968.zip
changes
Diffstat (limited to 'linux/rofi/applets/android/volume.sh')
-rwxr-xr-xlinux/rofi/applets/android/volume.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/linux/rofi/applets/android/volume.sh b/linux/rofi/applets/android/volume.sh
new file mode 100755
index 0000000..429db8c
--- /dev/null
+++ b/linux/rofi/applets/android/volume.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+## Author : Aditya Shakya
+## Mail : adi1090x@gmail.com
+## Github : @adi1090x
+## Twitter : @adi1090x
+
+dir="$HOME/.config/rofi/applets/android"
+rofi_command="rofi -theme $dir/three.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="Mu..."
+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
+