dotfiles/config/i3/volume.fish

47 lines
1.3 KiB
Fish
Raw Normal View History

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