46 lines
1.3 KiB
Fish
Executable file
46 lines
1.3 KiB
Fish
Executable file
#!/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.5) | tr -d '[:digit:]')
|
|
|
|
if [ $muted = 'true' ]
|
|
set body (printf '%41sMuted')
|
|
else
|
|
set percentage (printf '%16s%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 'Headphones'
|
|
end
|
|
|
|
set title "$icon Volume ($name)"
|
|
|
|
set file /tmp/notify-volume.id
|
|
set age (find "$file" -cmin -0,025)
|
|
if [ -n "$age" ]
|
|
notify-send.sh -r (cat "$file") -t 1500 "$title" "$body"
|
|
touch "$file"
|
|
else
|
|
set id (notify-send.sh -p -t 1500 "$title" "$body")
|
|
echo $id > "$file"
|
|
chmod 600 "$file"
|
|
end
|