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
{
imports = [ ./theme.nix ./mako.nix ./swaylock.nix ];
imports = [ ./theme.nix ./mako.nix ./swaylock.nix ./swayidle.nix ];
config = {
programs.mako.enable = true;
services.swayidle.enable = true;
wayland.windowManager.sway =
let
mod = "Mod4";
@ -357,31 +359,6 @@ in
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 = {
enable = true;
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"'';
}
];
};
}