summaryrefslogtreecommitdiff
path: root/common/modules/mango/swayidleNdLock.nix
diff options
context:
space:
mode:
Diffstat (limited to 'common/modules/mango/swayidleNdLock.nix')
-rw-r--r--common/modules/mango/swayidleNdLock.nix53
1 files changed, 53 insertions, 0 deletions
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";
+ }
+ ];
+ };
+ };
+}