dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

dwmblock-volume (1504B)


      1 #!/bin/sh
      2 # dwmblocks script for volume information
      3 sink="$(pactl get-default-sink)"
      4 source="$(pactl get-default-source)"
      5 case "$BUTTON" in
      6   1)
      7     pgrep -f pulsemixer || setsid -f "$TERMINAL" -e pulsemixer
      8     pkill -RTMIN+6 dwmblocks;;
      9   3)
     10     pactl -- set-source-mute "$source" toggle
     11     pkill -RTMIN+6 dwmblocks;;
     12   4)
     13     pactl -- set-sink-volume "$sink" +10%
     14     pkill -RTMIN+6 dwmblocks
     15     ;;
     16   5)
     17     pactl -- set-sink-volume "$sink" -10%
     18     pkill -RTMIN+6 dwmblocks
     19     ;;
     20   6) "$TERMINAL" -e "$EDITOR" "$0" ;;
     21 esac
     22 
     23 case $(pactl get-sink-mute "$sink") in
     24   "Mute: yes"*)
     25     volume_icon='🔇'
     26     ;;
     27   *)
     28     volume_icon='🔊'
     29     ;;
     30 esac
     31 volume="$(pactl get-sink-volume "$sink" \
     32   | head -n 1 \
     33   | awk -v volume_icon="$volume_icon" -F ' / ' '{
     34       gsub(" ", "", $2);
     35       gsub(" ", "", $4);
     36       if ($2 == $4) {
     37         printf("%s %s", volume_icon, $2);
     38       }
     39       else {
     40         printf("%s %s %s", volume_icon, $2, $4);
     41       }
     42     }')"
     43 
     44 case $(pactl get-source-mute "$source") in
     45   "Mute: yes"*)
     46     mic_icon=''
     47     ;;
     48   *)
     49     mic_icon='🎤'
     50     ;;
     51 esac
     52 
     53 pgrep -f nerd-dictation >/dev/null 2>&1 && recording=' ⏺'
     54 mic="$(pactl get-source-volume "$source" \
     55   | head -n 1 \
     56   | awk -v mic_icon="$mic_icon" -F ' / ' '{
     57       gsub(" ", "", $2);
     58       gsub(" ", "", $4);
     59       if (NF <= 4 || $2 == $4) {
     60         printf("%s %s", mic_icon, $2);
     61       }
     62       else {
     63         printf("%s %s %s", mic_icon, $2,$4);
     64       }
     65     }')"
     66 printf "%s %s%s" "$volume" "$mic" "$recording"