swayidle: auto screenoff

This commit is contained in:
Colin 2024-03-07 10:59:44 +00:00
parent 1cdc3b8bda
commit fd4842ab5b
2 changed files with 12 additions and 1 deletions

View File

@ -40,6 +40,7 @@
sane.programs.sway.enableFor.user.colin = true;
sane.programs.swaylock.enableFor.user.colin = false; #< not usable on touch
sane.programs.schlock.enableFor.user.colin = true;
sane.programs.swayidle.config.actions.screenoff.delay = 150;
sane.programs.sane-input-handler.enableFor.user.colin = true;
sane.programs.blueberry.enableFor.user.colin = false; # bluetooth manager: doesn't cross compile!
sane.programs.mercurial.enableFor.user.colin = false; # does not cross compile

View File

@ -1,4 +1,4 @@
{ config, lib, ... }:
{ config, lib, pkgs, ... }:
let
cfg = config.sane.programs.swayidle;
idleAction = with lib; types.submodule ({ config, name, ... }: {
@ -22,6 +22,10 @@ let
};
config.command = lib.mkIf (config.desktop != null) "sane-open-desktop ${config.desktop}";
});
screenOff = pkgs.writeShellScriptBin "screen-off" ''
swaymsg -- output '*' power false
swaymsg -- input type:touch events disabled
'';
in
{
sane.programs.swayidle = {
@ -35,9 +39,15 @@ in
};
};
config.actions.screenoff = {
command = "${screenOff}/bin/screen-off";
delay = lib.mkDefault 1500; # 1500s = 25min
};
sandbox.method = "bwrap";
sandbox.whitelistDbus = [ "user" ]; #< might need system too, for inhibitors
sandbox.whitelistWayland = true;
sandbox.extraRuntimePaths = [ "sway-ipc.sock" ];
services.swayidle = {
description = "swayidle: perform actions when sway session is idle";