i3: Add volume notif and improve backlight notif

This commit is contained in:
Sijmen 2018-11-26 12:13:44 +01:00
parent a9ef3cb1c8
commit 6e4ffa9d03
3 changed files with 43 additions and 10 deletions

View file

@ -1,20 +1,20 @@
#!/usr/bin/fish
xbacklight $argv[1..-1]
set file /tmp/notify-brightness.id
set age (find "$file" -cmin -0.2)
set brightness (xbacklight -get)
set bar (seq -s "─" 0 (math $brightness / 3) | tr -d '[:digit:]')
set percentage (printf '%44s%d%%' '' "$brightness")
set body "$percentage\n $bar"
set title ' Brightness'
set file /tmp/notify-brightness.id
set age (find "$file" -cmin -0.025)
if [ -n "$age" ]
dunstify -r (cat "$file") "Brightness" "$body"
dunstify -r (cat "$file") -t 1500 "$title" "$body"
touch "$file"
else
set id (dunstify -p "Brightness" "$body")
set id (dunstify -p -t 1500 "$title" "$body")
echo $id > "$file"
chmod 600 "$file"
end

View file

@ -138,12 +138,12 @@ bindsym XF86MonBrightnessDown exec --no-startup-id ~/.config/i3/backlight.
bindsym Shift+XF86MonBrightnessUp exec --no-startup-id ~/.config/i3/backlight.fish -inc 2
bindsym Shift+XF86MonBrightnessDown exec --no-startup-id ~/.config/i3/backlight.fish -dec 2
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5%
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5%
bindsym Shift+XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +2%
bindsym Shift+XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -2%
bindsym XF86AudioRaiseVolume exec --no-startup-id ~/.config/i3/volume.fish -i 5
bindsym XF86AudioLowerVolume exec --no-startup-id ~/.config/i3/volume.fish -d 5
bindsym Shift+XF86AudioRaiseVolume exec --no-startup-id ~/.config/i3/volume.fish -i 2
bindsym Shift+XF86AudioLowerVolume exec --no-startup-id ~/.config/i3/volume.fish -d 2
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle
bindsym XF86AudioMute exec --no-startup-id ~/.config/i3/volume.fish -t
bindsym Shift+XF86AudioMute exec --no-startup-id pavucontrol
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute 1 toggle

33
config/i3/volume.fish Executable file
View file

@ -0,0 +1,33 @@
#!/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 title "$icon Volume"
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