swayidle: enable; pair with swaylock
This commit is contained in:
parent
6a3e632335
commit
bd27f3a015
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
# sane.gui.sxmo.enable = true;
|
# sane.gui.sxmo.enable = true;
|
||||||
sane.programs.sway.enableFor.user.colin = true;
|
sane.programs.sway.enableFor.user.colin = true;
|
||||||
|
sane.programs.swaylock.enableFor.user.colin = false; #< TODO: could the locker be made to accept virtual keyboard input?
|
||||||
sane.programs.sane-input-handler.enableFor.user.colin = true;
|
sane.programs.sane-input-handler.enableFor.user.colin = true;
|
||||||
sane.programs.blueberry.enableFor.user.colin = false; # bluetooth manager: doesn't cross compile!
|
sane.programs.blueberry.enableFor.user.colin = false; # bluetooth manager: doesn't cross compile!
|
||||||
sane.programs.mercurial.enableFor.user.colin = false; # does not cross compile
|
sane.programs.mercurial.enableFor.user.colin = false; # does not cross compile
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
./supertuxkart.nix
|
./supertuxkart.nix
|
||||||
./sway
|
./sway
|
||||||
./sway-autoscaler
|
./sway-autoscaler
|
||||||
|
./swayidle.nix
|
||||||
./swaylock.nix
|
./swaylock.nix
|
||||||
./swaynotificationcenter.nix
|
./swaynotificationcenter.nix
|
||||||
./tangram.nix
|
./tangram.nix
|
||||||
|
|
|
@ -114,7 +114,7 @@ in
|
||||||
"sane-open-desktop"
|
"sane-open-desktop"
|
||||||
"splatmoji" # used by sway config
|
"splatmoji" # used by sway config
|
||||||
"sway-contrib.grimshot" # used by sway config
|
"sway-contrib.grimshot" # used by sway config
|
||||||
# "swayidle" # enable if you need it
|
"swayidle" # enable if you need it
|
||||||
"swaylock" # used by sway config
|
"swaylock" # used by sway config
|
||||||
"swaynotificationcenter" # notification daemon
|
"swaynotificationcenter" # notification daemon
|
||||||
"unl0kr" # greeter
|
"unl0kr" # greeter
|
||||||
|
|
64
hosts/common/programs/swayidle.nix
Normal file
64
hosts/common/programs/swayidle.nix
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.sane.programs.swayidle;
|
||||||
|
idleAction = with lib; types.submodule ({ config, name, ... }: {
|
||||||
|
options.enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
options.command = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = name;
|
||||||
|
};
|
||||||
|
options.desktop = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
options.delay = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
description = ''
|
||||||
|
how many seconds of idle time before triggering the command.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
config.command = lib.mkIf (config.desktop != null) "sane-open-desktop ${config.desktop}";
|
||||||
|
});
|
||||||
|
in
|
||||||
|
{
|
||||||
|
sane.programs.swayidle = {
|
||||||
|
configOption = with lib; mkOption {
|
||||||
|
default = {};
|
||||||
|
type = types.submodule {
|
||||||
|
options.actions = mkOption {
|
||||||
|
type = types.attrsOf idleAction;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
# sandboxing: TODO
|
||||||
|
services.swayidle = {
|
||||||
|
description = "swayidle: perform actions when sway session is idle";
|
||||||
|
after = [ "graphical-session.target" ];
|
||||||
|
wantedBy = [ "graphical-session.target" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = lib.escapeShellArgs (
|
||||||
|
[
|
||||||
|
"${cfg.package}/bin/swayidle"
|
||||||
|
"-w"
|
||||||
|
] ++ lib.flatten (
|
||||||
|
lib.mapAttrsToList
|
||||||
|
(_: { command, delay, enable, ... }: lib.optionals enable [
|
||||||
|
"timeout"
|
||||||
|
(builtins.toString delay)
|
||||||
|
command
|
||||||
|
])
|
||||||
|
cfg.config.actions
|
||||||
|
)
|
||||||
|
);
|
||||||
|
Type = "simple";
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = "20s";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -28,6 +28,11 @@ in
|
||||||
sandbox.whitelistWayland = true;
|
sandbox.whitelistWayland = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sane.programs.swayidle.config = lib.mkIf cfg.enabled {
|
||||||
|
actions.swaylock.desktop = "swaylock.desktop";
|
||||||
|
actions.swaylock.delay = 1800;
|
||||||
|
};
|
||||||
|
|
||||||
security.pam.services = lib.mkIf cfg.enabled {
|
security.pam.services = lib.mkIf cfg.enabled {
|
||||||
swaylock = {};
|
swaylock = {};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user