swayidle: extract config from sway

This commit is contained in:
Leonardo Eugênio 2023-02-25 17:19:48 -03:00
parent ce4a6bb501
commit 5f0c129b63
2 changed files with 37 additions and 26 deletions

View file

@ -19,9 +19,11 @@ let
''; '';
in in
{ {
imports = [ ./theme.nix ./mako.nix ./swaylock.nix ]; imports = [ ./theme.nix ./mako.nix ./swaylock.nix ./swayidle.nix ];
config = { config = {
programs.mako.enable = true; programs.mako.enable = true;
services.swayidle.enable = true;
wayland.windowManager.sway = wayland.windowManager.sway =
let let
mod = "Mod4"; mod = "Mod4";
@ -357,31 +359,6 @@ in
exec swaymsg workspace 2 exec swaymsg workspace 2
''; '';
}; };
services.swayidle = {
enable = true;
timeouts = [
{
timeout = 360;
command = "${pkgs.swaylock}/bin/swaylock -f";
}
{
timeout = 1800;
command = ''
mpc status | grep "^[playing]" > /dev/null || ${pkgs.sway}/bin/swaymsg "output * dpms off"'';
resumeCommand = ''${pkgs.sway}/bin/swaymsg "output * dpms on"'';
}
];
events = [
{
event = "before-sleep";
command = "${pkgs.swaylock}/bin/swaylock -f";
}
{
event = "after-resume";
command = ''swaymsg "output * dpms on"'';
}
];
};
services.gammastep = { services.gammastep = {
enable = true; enable = true;
provider = "geoclue2"; provider = "geoclue2";

34
user/sway/swayidle.nix Normal file
View file

@ -0,0 +1,34 @@
{ config, pkgs, lib, ... }:
let
inherit (pkgs.uservars) key accent font theme;
inherit (theme) color;
in
{
services.swayidle = {
timeouts = [
{
timeout = 360;
command = "${pkgs.swaylock}/bin/swaylock -f";
}
{
timeout = 1800;
command = ''
mpc status | grep "^[playing]" > /dev/null || ${pkgs.sway}/bin/swaymsg "output * dpms off"
'';
resumeCommand = ''
${pkgs.sway}/bin/swaymsg "output * dpms on"
'';
}
];
events = [
{
event = "before-sleep";
command = "${pkgs.swaylock}/bin/swaylock -f";
}
{
event = "after-resume";
command = ''swaymsg "output * dpms on"'';
}
];
};
}