From 83f0f303a95277171b5f0d059959af9f4116cdb1 Mon Sep 17 00:00:00 2001 From: brustybee Date: Wed, 11 Mar 2026 13:48:40 +0530 Subject: add swaylock and swayidle and avoid x11 and wayland services clash --- common/modules/mango/swayidleNdLock.nix | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 common/modules/mango/swayidleNdLock.nix (limited to 'common/modules/mango/swayidleNdLock.nix') diff --git a/common/modules/mango/swayidleNdLock.nix b/common/modules/mango/swayidleNdLock.nix new file mode 100644 index 0000000..959ea45 --- /dev/null +++ b/common/modules/mango/swayidleNdLock.nix @@ -0,0 +1,53 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.beeMods.mango; + swaylock_cmd = "${pkgs.swaylock}/bin/swaylock -f -C ~/.config/swaylock/swaylock-colors"; +in +{ + config = lib.mkIf cfg.enable { + home.packages = with pkgs; [ + wlopm + swaylock + ]; + + services.swayidle = { + enable = true; + systemdTarget = "mango-session.target"; + + events = { + "before-sleep" = swaylock_cmd; + "lock" = swaylock_cmd; + }; + + timeouts = [ + # dim screen at 4:30 + { + timeout = 270; + command = "${pkgs.brightnessctl}/bin/brightnessctl g > /tmp/brightness_prev && ${pkgs.brightnessctl}/bin/brightnessctl set 10%"; + resumeCommand = "${pkgs.brightnessctl}/bin/brightnessctl set $(cat /tmp/brightness_prev || echo 100%)"; + } + # Lock at 5:00 + { + timeout = 300; + command = swaylock_cmd; + } + # Screen off at 10:00 + { + timeout = 600; + command = "${pkgs.wlopm}/bin/wlopm --off '*'"; + resumeCommand = "${pkgs.wlopm}/bin/wlopm --on '*'"; + } + # suspend at 15:00 + { + timeout = 900; + command = "systemctl suspend"; + } + ]; + }; + }; +} -- cgit v1.3.1