mirror of
https://github.com/alyraffauf/nixcfg.git
synced 2024-11-23 05:03:55 -05:00
home: switch hyprland and sway to new swayidle systemd service
This commit is contained in:
parent
78491e655c
commit
650ce2c546
|
@ -15,6 +15,7 @@
|
|||
./mako
|
||||
./nemo
|
||||
./rofi
|
||||
./swayidle
|
||||
./swaylock
|
||||
./thunar
|
||||
./tmux
|
||||
|
|
63
homeManagerModules/apps/swayidle/default.nix
Normal file
63
homeManagerModules/apps/swayidle/default.nix
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.ar.home;
|
||||
hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl";
|
||||
swaymsg = lib.getExe' config.wayland.windowManager.sway.package "swaymsg";
|
||||
|
||||
in {
|
||||
config = lib.mkIf config.ar.home.apps.swayidle.enable {
|
||||
services.swayidle = {
|
||||
enable = true;
|
||||
|
||||
events = [
|
||||
{
|
||||
event = "before-sleep";
|
||||
command = "${lib.getExe pkgs.playerctl} pause";
|
||||
}
|
||||
{
|
||||
event = "before-sleep";
|
||||
command = "${pkgs.swaylock}/bin/swaylock";
|
||||
}
|
||||
{
|
||||
event = "lock";
|
||||
command = "${pkgs.swaylock}/bin/swaylock";
|
||||
}
|
||||
];
|
||||
|
||||
timeouts =
|
||||
[
|
||||
{
|
||||
timeout = 120;
|
||||
command = "${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r";
|
||||
}
|
||||
{
|
||||
timeout = 600;
|
||||
command = "${pkgs.swaylock}/bin/swaylock";
|
||||
}
|
||||
]
|
||||
++ lib.optional cfg.desktop.autoSuspend {
|
||||
timeout = 600;
|
||||
command = "sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend'";
|
||||
}
|
||||
++ lib.optional (!cfg.desktop.autoSuspend)
|
||||
{
|
||||
timeout = 600;
|
||||
command = "${pkgs.swaylock}/bin/swaylock";
|
||||
}
|
||||
++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.hyprland.enable)
|
||||
{
|
||||
timeout = 630;
|
||||
command = "${hyprctl} dispatch dpms off' resume '${hyprctl} dispatch dpms on'";
|
||||
}
|
||||
++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.sway.enable)
|
||||
{
|
||||
timeout = 630;
|
||||
command = "${swaymsg} \"output * dpms off\"' resume '${swaymsg} \"output * dpms on\"";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -26,28 +26,6 @@ in {
|
|||
fi
|
||||
'';
|
||||
|
||||
idleD = let
|
||||
timeouts =
|
||||
["timeout 120 '${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r'"]
|
||||
++ (
|
||||
if cfg.desktop.autoSuspend
|
||||
then ["timeout 600 'sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend'"]
|
||||
else [
|
||||
"timeout 600 '${lib.getExe pkgs.swaylock}'"
|
||||
"timeout 630 '${hyprctl} dispatch dpms off' resume '${hyprctl} dispatch dpms on'"
|
||||
]
|
||||
);
|
||||
|
||||
beforeSleeps =
|
||||
lib.optionals cfg.desktop.autoSuspend
|
||||
[
|
||||
"before-sleep '${lib.getExe pkgs.playerctl} pause'"
|
||||
"before-sleep '${lib.getExe pkgs.swaylock}'"
|
||||
];
|
||||
in
|
||||
pkgs.writeShellScript "hyprland-idled"
|
||||
"${lib.getExe pkgs.swayidle} -w lock '${lib.getExe pkgs.swaylock}' ${lib.strings.concatStringsSep " " (timeouts ++ beforeSleeps)}";
|
||||
|
||||
tablet = pkgs.writeShellScript "hyprland-tablet" ''
|
||||
STATE=`${lib.getExe pkgs.dconf} read /org/gnome/desktop/a11y/applications/screen-keyboard-enabled`
|
||||
|
||||
|
|
|
@ -131,7 +131,6 @@ in {
|
|||
(lib.getExe pkgs.wayland-pipewire-idle-inhibit)
|
||||
(lib.getExe' pkgs.playerctl "playerctld")
|
||||
(lib.getExe' pkgs.swayosd "swayosd-server")
|
||||
scripts.idleD
|
||||
]
|
||||
++ lib.lists.optional (cfg.desktop.redShift)
|
||||
"${lib.getExe pkgs.gammastep} -l 33.74:-84.38"
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.ar.home;
|
||||
swaymsg = lib.getExe' config.wayland.windowManager.sway.package "swaymsg";
|
||||
in {
|
||||
idleD = let
|
||||
timeouts =
|
||||
["timeout 120 '${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r'"]
|
||||
++ (
|
||||
if cfg.desktop.autoSuspend
|
||||
then ["timeout 600 'sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend'"]
|
||||
else [
|
||||
"timeout 600 '${lib.getExe pkgs.swaylock}'"
|
||||
"timeout 630 '${swaymsg} \"output * dpms off\"' resume '${swaymsg} \"output * dpms on\"'"
|
||||
]
|
||||
);
|
||||
|
||||
beforeSleeps =
|
||||
lib.optionals cfg.desktop.autoSuspend
|
||||
[
|
||||
"before-sleep '${lib.getExe pkgs.playerctl} pause'"
|
||||
"before-sleep '${lib.getExe pkgs.swaylock}'"
|
||||
];
|
||||
in
|
||||
pkgs.writeShellScript "sway-idled"
|
||||
"${lib.getExe pkgs.swayidle} -w lock '${lib.getExe pkgs.swaylock}' ${lib.strings.concatStringsSep " " (timeouts ++ beforeSleeps)}";
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
...
|
||||
}: let
|
||||
cfg = config.ar.home;
|
||||
scripts = import ./scripts.nix {inherit config lib pkgs;};
|
||||
helpers = import ../wayland/helpers.nix {inherit config lib pkgs;};
|
||||
modifier = "Mod4";
|
||||
in {
|
||||
|
@ -159,7 +158,6 @@ in {
|
|||
startup =
|
||||
[
|
||||
{command = "${pkgs.mate.mate-polkit}/libexec/polkit-mate-authentication-agent-1";}
|
||||
{command = "${scripts.idleD}";}
|
||||
{command = lib.getExe pkgs.autotiling;}
|
||||
{command = lib.getExe pkgs.mako;}
|
||||
{command = lib.getExe pkgs.wayland-pipewire-idle-inhibit;}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
kitty.enable = lib.mkDefault true;
|
||||
mako.enable = lib.mkDefault true;
|
||||
rofi.enable = lib.mkDefault true;
|
||||
swayidle.enable = lib.mkDefault true;
|
||||
swaylock.enable = lib.mkDefault true;
|
||||
waybar.enable = lib.mkDefault true;
|
||||
};
|
||||
|
|
|
@ -62,6 +62,7 @@ in {
|
|||
};
|
||||
|
||||
rofi.enable = lib.mkEnableOption "Rofi launcher.";
|
||||
swayidle.enable = lib.mkEnableOption "Swayidle idle daemon.";
|
||||
swaylock.enable = lib.mkEnableOption "Swaylock screen locker.";
|
||||
|
||||
thunar.enable = lib.mkOption {
|
||||
|
|
Loading…
Reference in a new issue