diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2024-09-06 10:34:05 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2024-09-06 10:34:05 +0800 |
| commit | 01abbff07781d55101f5a347634de49631709579 (patch) | |
| tree | 6069e2ea6e007ff932cdfa917d922b9b1c186230 /hyprvol | |
| parent | 582c7ad0569e4bc52a86b38e9a51f07f41842e15 (diff) | |
more hyprland scripts
Diffstat (limited to 'hyprvol')
| -rwxr-xr-x | hyprvol | 82 |
1 files changed, 82 insertions, 0 deletions
@@ -0,0 +1,82 @@ +#!/bin/bash + +# Icons +iDIR='/usr/share/archcraft/icons/dunst' +notify_cmd='notify-send -u low' + +# Get Volume +get_volume() { + echo "`pulsemixer --get-volume | cut -d' ' -f1`" +} + +# Notify +notify_user() { + current="$(get_volume)" + if [[ "$current" -eq "0" ]]; then + icon="$iDIR/volume-mute.png" + elif [[ ("$current" -ge "0") && ("$current" -le "40") ]]; then + icon="$iDIR/volume-low.png" + elif [[ ("$current" -ge "40") && ("$current" -le "60") ]]; then + icon="$iDIR/volume-mid.png" + elif [[ ("$current" -ge "60") ]]; then + icon="$iDIR/volume-high.png" + fi + if $($HOME/scripts/sysutil.sh getSound screenshot); then $HOME/scripts/sysutil.sh playSound audio-volume-change.oga & fi + ${notify_cmd} -i "$icon" "Volume : $current%" +} + +# Increase Volume +inc_volume() { + [[ `pulsemixer --get-mute` == 1 ]] && pulsemixer --unmute + wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ && notify_user +} + +# Decrease Volume +dec_volume() { + [[ `pulsemixer --get-mute` == 1 ]] && pulsemixer --unmute + wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- && notify_user +} + +# Toggle Mute +toggle_mute() { + if [[ `pulsemixer --get-mute` == 0 ]]; then + wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle & ${notify_cmd} -i "$iDIR/volume-mute.png" "Mute" + else + current="$(get_volume)" + if [[ "$current" -eq "0" ]]; then + icon="$iDIR/volume-mute.png" + elif [[ ("$current" -ge "0") && ("$current" -le "40") ]]; then + icon="$iDIR/volume-low.png" + elif [[ ("$current" -ge "40") && ("$current" -le "60") ]]; then + icon="$iDIR/volume-mid.png" + elif [[ ("$current" -ge "60") ]]; then + icon="$iDIR/volume-high.png" + fi + pulsemixer --toggle-mute & ${notify_cmd} -i "$icon" "Unmute" + fi +} + +# Toggle Mic +toggle_mic() { + ID="`pulsemixer --list-sources | grep 'Default' | cut -d',' -f1 | cut -d' ' -f3`" + if [[ `pulsemixer --id $ID --get-mute` == 0 ]]; then + pulsemixer --id ${ID} --toggle-mute && ${notify_cmd} -i "$iDIR/microphone-mute.png" "Microphone Switched OFF" + else + pulsemixer --id ${ID} --toggle-mute && ${notify_cmd} -i "$iDIR/microphone.png" "Microphone Switched ON" + fi +} + +# Execute accordingly +if [[ "$1" == "--get" ]]; then + get_volume +elif [[ "$1" == "--inc" ]]; then + inc_volume +elif [[ "$1" == "--dec" ]]; then + dec_volume +elif [[ "$1" == "--toggle" ]]; then + toggle_mute +elif [[ "$1" == "--toggle-mic" ]]; then + toggle_mic +else + echo $(get_volume)% +fi |
