hyprland/sway: pause media before sleep

This commit is contained in:
Aly Raffauf 2024-04-28 17:27:50 -04:00
parent 9c166735ac
commit 5b7a4630eb
2 changed files with 39 additions and 37 deletions

View file

@ -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}";

View file

@ -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')";