From 5b7a4630eb91e7cd8b7d66e3f8dd5cab4d8e359a Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sun, 28 Apr 2024 17:27:50 -0400 Subject: [PATCH] hyprland/sway: pause media before sleep --- homeManagerModules/desktop/hypr/default.nix | 48 ++++++++++----------- homeManagerModules/desktop/sway/default.nix | 28 ++++++------ 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/homeManagerModules/desktop/hypr/default.nix b/homeManagerModules/desktop/hypr/default.nix index 0e59df1b..3718d2e6 100644 --- a/homeManagerModules/desktop/hypr/default.nix +++ b/homeManagerModules/desktop/hypr/default.nix @@ -81,30 +81,6 @@ editor = pkgs.vscodium + "/bin/codium"; terminal = pkgs.alacritty + "/bin/alacritty"; - # Hyprland desktop utilities - bar = pkgs.waybar + "/bin/waybar -s ${config.xdg.configHome}/waybar/hyprland-style.css"; - launcher = pkgs.fuzzel + "/bin/fuzzel"; - notifyd = pkgs.mako + "/bin/mako"; - wallpaperd = pkgs.hyprpaper + "/bin/hyprpaper"; - logout = pkgs.wlogout + "/bin/wlogout"; - # lock = pkgs.hyprlock + "/bin/hyprlock --immediate"; - # idled = pkgs.hypridle + "/bin/hypridle"; - - lock = pkgs.swaylock + ''/bin/swaylock''; - idled = - if config.alyraffauf.desktop.hyprland.autoSuspend - then '' - ${pkgs.swayidle}/bin/swayidle -w timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' resume '${pkgs.brightnessctl}/bin/brightnessctl -r' timeout 300 '${lock}' timeout 330 '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' resume '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on' timeout 900 '${pkgs.systemd}/bin/systemctl suspend' before-sleep '${lock}' - - '' - else '' - ${pkgs.swayidle}/bin/swayidle -w timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' resume '${pkgs.brightnessctl}/bin/brightnessctl -r' timeout 300 '${lock}' timeout 330 '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' resume '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on' before-sleep '${lock}' - - ''; - - hyprnome = pkgs.hyprnome + "/bin/hyprnome"; - hyprshade = pkgs.hyprshade + "/bin/hyprshade"; - # Media/hardware commands # brightness = "${pkgs.brightnessctl}/bin/brightnessctl"; # brightness_up = "${brightness} set 5%+"; @@ -127,6 +103,30 @@ media_next = "${media} next"; media_prev = "${media} previous"; + # Hyprland desktop utilities + bar = pkgs.waybar + "/bin/waybar -s ${config.xdg.configHome}/waybar/hyprland-style.css"; + launcher = pkgs.fuzzel + "/bin/fuzzel"; + notifyd = pkgs.mako + "/bin/mako"; + wallpaperd = pkgs.hyprpaper + "/bin/hyprpaper"; + logout = pkgs.wlogout + "/bin/wlogout"; + # lock = pkgs.hyprlock + "/bin/hyprlock --immediate"; + # idled = pkgs.hypridle + "/bin/hypridle"; + + lock = pkgs.swaylock + ''/bin/swaylock''; + idled = + if config.alyraffauf.desktop.hyprland.autoSuspend + then '' + ${pkgs.swayidle}/bin/swayidle -w timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' resume '${pkgs.brightnessctl}/bin/brightnessctl -r' timeout 300 '${lock}' timeout 330 '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' resume '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on' timeout 900 '${pkgs.systemd}/bin/systemctl suspend' before-sleep '${media} pause' before-sleep '${lock}' + + '' + else '' + ${pkgs.swayidle}/bin/swayidle -w timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' resume '${pkgs.brightnessctl}/bin/brightnessctl -r' timeout 300 '${lock}' timeout 330 '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' resume '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on' before-sleep '${media} pause' before-sleep '${lock}' + + ''; + + hyprnome = pkgs.hyprnome + "/bin/hyprnome"; + hyprshade = pkgs.hyprshade + "/bin/hyprshade"; + screenshot = "${pkgs.hyprshot}/bin/hyprshot"; screenshot_folder = "~/pics/screenshots"; screenshot_screen = "${screenshot} -m output -o ${screenshot_folder}"; diff --git a/homeManagerModules/desktop/sway/default.nix b/homeManagerModules/desktop/sway/default.nix index 546bd27c..d3772199 100644 --- a/homeManagerModules/desktop/sway/default.nix +++ b/homeManagerModules/desktop/sway/default.nix @@ -69,6 +69,19 @@ editor = pkgs.vscodium + "/bin/codium"; terminal = pkgs.alacritty + "/bin/alacritty"; + brightness = "${pkgs.swayosd}/bin/swayosd-client"; + brightness_up = "${brightness} --brightness=raise"; + brightness_down = "${brightness} --brightness=lower"; + volume = "${pkgs.swayosd}/bin/swayosd-client"; + volume_up = "${volume} --output-volume=raise"; + volume_down = "${volume} --output-volume=lower"; + volume_mute = "${volume} --output-volume=mute-toggle"; + mic_mute = "${volume} --input-volume=mute-toggle"; + media = "${pkgs.playerctl}/bin/playerctl"; + media_play = "${media} play-pause"; + media_next = "${media} next"; + media_prev = "${media} previous"; + # Sway desktop utilities bar = pkgs.waybar + "/bin/waybar -s ${config.xdg.configHome}/waybar/sway-style.css"; launcher = pkgs.fuzzel + "/bin/fuzzel"; @@ -86,6 +99,7 @@ timeout 330 '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms off"' \ resume '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms on"' \ timeout 900 '${pkgs.systemd}/bin/systemctl suspend' \ + before-sleep '${media} pause' \ before-sleep '${lock}' '' else '' @@ -95,22 +109,10 @@ timeout 300 '${lock}' \ timeout 330 '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms off"' \ resume '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms on"' \ + before-sleep '${media} pause' \ before-sleep '${lock}' ''; - brightness = "${pkgs.swayosd}/bin/swayosd-client"; - brightness_up = "${brightness} --brightness=raise"; - brightness_down = "${brightness} --brightness=lower"; - volume = "${pkgs.swayosd}/bin/swayosd-client"; - volume_up = "${volume} --output-volume=raise"; - volume_down = "${volume} --output-volume=lower"; - volume_mute = "${volume} --output-volume=mute-toggle"; - mic_mute = "${volume} --input-volume=mute-toggle"; - media = "${pkgs.playerctl}/bin/playerctl"; - media_play = "${media} play-pause"; - media_next = "${media} next"; - media_prev = "${media} previous"; - screenshot = "${pkgs.shotman}/bin/shotman"; # screenshot_folder = "~/pics/screenshots"; # screenshot_screen = "${screenshot} ${screenshot_folder}/$(date +'%s_grim.png')";