diff options
| author | Alec Goncharow <algo@cloudflare.com> | 2022-02-20 11:50:35 -0500 |
|---|---|---|
| committer | Alec Goncharow <algo@cloudflare.com> | 2022-02-20 11:50:35 -0500 |
| commit | f5abca7278f3ac0c7358e6f30db8a15da45a1e3b (patch) | |
| tree | 96889e1a2cc2367b8461414ae7c94d9050b84890 /.config/rofi/applets/menu/volume.sh | |
| parent | 3e0c8208ccbead65cd434fe730223a7ab854c377 (diff) | |
| parent | 72cf398a6292fa56d57e82caa4d21570e5573294 (diff) | |
Merge branch 'desktop' of github.com:AlecGoncharow/dotfiles into desktop
Diffstat (limited to '.config/rofi/applets/menu/volume.sh')
| -rwxr-xr-x | .config/rofi/applets/menu/volume.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/.config/rofi/applets/menu/volume.sh b/.config/rofi/applets/menu/volume.sh new file mode 100755 index 0000000..7e4a0d8 --- /dev/null +++ b/.config/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 + |
