#!/usr/bin/fish pamixer $argv[1..-1] set volume (pamixer --get-volume) set muted (pamixer --get-mute) set bar (seq -s "─" 0 (math $volume / 3) | tr -d '[:digit:]') if [ $muted = 'true' ] set body (printf '%41sMuted') else set percentage (printf '%44s%d%%' '' "$volume") set body "$percentage\n $bar" end set icon '' if [ $muted = 'true' ] set icon '' else if [ $argv[1] = '-d' ] set icon ' ' end set name ( \ pactl list | \ grep -A1000 'Name: '(pactl info | grep '^Default Sink' | cut -d' ' -f 3-)'$' | \ grep -m1 'Active Port' | \ cut -d' ' -f 3- \ ) if [ $name = 'analog-output-speaker' ] set name 'Speakers' else if [ $name = 'analog-output-headphones' ] set name 'Line-out' end set title "$icon Volume ($name)" set file /tmp/notify-volume.id set age (find "$file" -cmin -0.025) if [ -n "$age" ] dunstify -r (cat "$file") -t 1500 "$title" "$body" touch "$file" else set id (dunstify -p -t 1500 "$title" "$body") echo $id > "$file" chmod 600 "$file" end