2023-02-25 17:19:48 -03:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (pkgs.uservars) key accent font theme;
|
|
|
|
inherit (theme) color;
|
2023-02-27 16:39:31 -03:00
|
|
|
|
|
|
|
asScript = filename: text: toString (pkgs.writeShellScript filename text);
|
2023-02-25 17:19:48 -03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
services.swayidle = {
|
|
|
|
timeouts = [
|
|
|
|
{
|
|
|
|
timeout = 360;
|
|
|
|
command = "${pkgs.swaylock}/bin/swaylock -f";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
timeout = 1800;
|
2023-02-27 16:39:31 -03:00
|
|
|
command = asScript "swayidle-suspend-monitors" ''
|
|
|
|
${pkgs.mpc_cli}/bin/mpc status | grep "^[playing]" > /dev/null || ${pkgs.sway}/bin/swaymsg "output * dpms off"
|
2023-02-25 17:19:48 -03:00
|
|
|
'';
|
2023-02-27 16:39:31 -03:00
|
|
|
resumeCommand = asScript "swayidle-wakeup-monitors" ''
|
2023-02-25 17:19:48 -03:00
|
|
|
${pkgs.sway}/bin/swaymsg "output * dpms on"
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
|
|
|
events = [
|
|
|
|
{
|
|
|
|
event = "before-sleep";
|
|
|
|
command = "${pkgs.swaylock}/bin/swaylock -f";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
event = "after-resume";
|
2023-02-27 16:39:31 -03:00
|
|
|
command = asScript "after-resume" ''
|
|
|
|
${pkgs.sway}/bin/swaymsg "output * dpms on"
|
|
|
|
'';
|
2023-02-25 17:19:48 -03:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|