show dunst notifications on sound change

current_state
Christian Ott 2 years ago
parent f6e569da7c
commit ca25ef4696
  1. 33
      hyperland/default.nix

@ -1,11 +1,34 @@
{ config, pkgs, username, ... }: { config, pkgs, username, ... }:
let
volumeChange = pkgs.writeShellScript "volume-change" ''
# FROM: https://github.com/jsimonrichard/nix-config/blob/master/modules/my-config/desktop/hyprland/home-manager/desktop/hyprland/keybinds.nix
# Arbitrary but unique message tag
msgTag="dunst-sound"
# Change the volume using alsa(might differ if you use pulseaudio)
wpctl $@ > /dev/null
# Query wpctl for the current volume and whether or not the speaker is muted
volume="$(wpctl get-volume $2 | awk '{print $2 * 100}')"
mute="$(wpctl get-volume $2 | awk '{print $3}')"
if [[ $volume == 0 || "$mute" == "[MUTED]" ]]; then
# Show the sound muted notification
dunstify -a "volumeChange" -u low -i audio-volume-muted -h string:x-dunst-stack-tag:$msgTag "Volume muted"
else
# Show the volume notification
dunstify -a "volumeChange" -u low -i audio-volume-high -h string:x-dunst-stack-tag:$msgTag \
-h int:value:"$volume" "Volume: $volume%"
fi
'';
in
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
dunst dunst
waybar waybar
swww swww
rofi rofi
brightnessctl
# (pkgs.waybar.overrideAttrs (oldAttrs: { # (pkgs.waybar.overrideAttrs (oldAttrs: {
# mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ]; # mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ];
# })) # }))
@ -104,6 +127,8 @@
"$mod, l, exec, hyprlock" # Add a keybinding to lock the screen "$mod, l, exec, hyprlock" # Add a keybinding to lock the screen
"$mod, C, exec, codium" "$mod, C, exec, codium"
"$mod, E, exec, hyprctl dispatch exit" "$mod, E, exec, hyprctl dispatch exit"
",XF86MonBrightnessDown, exec, brightnessctl s 5%-"
",XF86MonBrightnessUp, exec, brightnessctl s +5%"
] ]
++ ( ++ (
# workspaces # workspaces
@ -130,13 +155,15 @@
# t -> transparent, cannot be shadowed by other binds. # t -> transparent, cannot be shadowed by other binds.
# i -> ignore mods, will ignore modifiers. # i -> ignore mods, will ignore modifiers.
binde = [ binde = [
", XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ --limit 1.3" ", XF86AudioRaiseVolume, exec, ${volumeChange} set-volume @DEFAULT_AUDIO_SINK@ 5%+ --limit 1.3"
"CTRL, XF86AudioRaiseVolume, exec, ${volumeChange} set-volume @DEFAULT_AUDIO_SOURCE@ 5%+ --limit 1"
]; ];
bindle = [ bindle = [
", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" ", XF86AudioLowerVolume, exec, ${volumeChange} set-volume @DEFAULT_AUDIO_SINK@ 5%-"
"CTRL, XF86AudioLowerVolume, exec, ${volumeChange} set-volume @DEFAULT_AUDIO_SOURCE@ 5%-"
]; ];
bindl = [ bindl = [
", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" ", XF86AudioMute, exec, ${volumeChange} set-mute @DEFAULT_AUDIO_SINK@ toggle"
]; ];
}; };
} }
Loading…
Cancel
Save

Powered by TurnKey Linux.