wm-helpers: add volume cap and unmute
This commit is contained in:
parent
c172b999fc
commit
1d62744fce
@ -1,16 +1,32 @@
|
|||||||
{ pkgs, ...}:
|
{ pkgs, lib, cap-volume ? true, unmute ? true, ...}:
|
||||||
let
|
let
|
||||||
keysetting = pkgs.writeShellScriptBin "keysetting" ''
|
keysetting = pkgs.writeShellScriptBin "keysetting"
|
||||||
|
''
|
||||||
wpctl=${pkgs.wireplumber}/bin/wpctl
|
wpctl=${pkgs.wireplumber}/bin/wpctl
|
||||||
notify_send=${pkgs.libnotify}/bin/notify-send
|
notify_send=${pkgs.libnotify}/bin/notify-send
|
||||||
brightnessctl=${pkgs.brightnessctl}/bin/brightnessctl
|
brightnessctl=${pkgs.brightnessctl}/bin/brightnessctl
|
||||||
|
cut=${pkgs.coreutils}/bin/cut
|
||||||
|
grep=${pkgs.gnugrep}/bin/grep
|
||||||
|
tr=${pkgs.coreutils}/bin/tr
|
||||||
|
bc=${pkgs.bc}/bin/bc
|
||||||
|
|
||||||
|
cap_volume=${pkgs.coreutils}/bin/${lib.boolToString cap-volume}
|
||||||
|
unmute=${pkgs.coreutils}/bin/${lib.boolToString unmute}
|
||||||
|
|
||||||
notify-send () {
|
notify-send () {
|
||||||
$notify_send -h string:x-canonical-private-synchronous:keysetting "$@"
|
$notify_send -h string:x-canonical-private-synchronous:keysetting "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getvol () {
|
||||||
|
echo "$(wpctl get-volume @DEFAULT_SINK@ | $tr -dc '[:digit:].')*100/1" | $bc
|
||||||
|
}
|
||||||
|
|
||||||
notifyvol () {
|
notifyvol () {
|
||||||
notify-send "$(wpctl get-volume @DEFAULT_SINK@)"
|
message="Volume: $(getvol)%"
|
||||||
|
if $wpctl get-volume @DEFAULT_SINK@ | $grep MUTED > /dev/null ; then
|
||||||
|
message="$message [MUTED]"
|
||||||
|
fi
|
||||||
|
notify-send "$message"
|
||||||
}
|
}
|
||||||
|
|
||||||
setvol () {
|
setvol () {
|
||||||
@ -18,6 +34,28 @@ let
|
|||||||
notifyvol
|
notifyvol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
volup () {
|
||||||
|
if $unmute ; then
|
||||||
|
$wpctl set-mute @DEFAULT_SINK@ 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $cap_volume && [[ $(( $(getvol) + 5 )) -gt 100 ]] ; then
|
||||||
|
setvol 1
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
setvol 5%+
|
||||||
|
# notifyvol
|
||||||
|
}
|
||||||
|
|
||||||
|
voldown () {
|
||||||
|
if $unmute ; then
|
||||||
|
$wpctl set-mute @DEFAULT_SINK@ 0
|
||||||
|
fi
|
||||||
|
setvol 5%-
|
||||||
|
# notifyvol
|
||||||
|
}
|
||||||
|
|
||||||
notifybright () {
|
notifybright () {
|
||||||
notify-send "Brightness: $(($($brightnessctl g)*100/$($brightnessctl m)))%"
|
notify-send "Brightness: $(($($brightnessctl g)*100/$($brightnessctl m)))%"
|
||||||
}
|
}
|
||||||
@ -27,8 +65,8 @@ let
|
|||||||
notifybright
|
notifybright
|
||||||
}
|
}
|
||||||
case "$1" in
|
case "$1" in
|
||||||
volumeup) setvol 5%+ ;;
|
volumeup) volup ;;
|
||||||
volumedown) setvol 5%- ;;
|
volumedown) voldown ;;
|
||||||
mute) $wpctl set-mute @DEFAULT_SINK@ toggle; notifyvol;;
|
mute) $wpctl set-mute @DEFAULT_SINK@ toggle; notifyvol;;
|
||||||
monup) setbright 5%+;;
|
monup) setbright 5%+;;
|
||||||
mondown) setbright 5%-;;
|
mondown) setbright 5%-;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user