nixos-config/user/sway/swayidle.nix

51 lines
1.1 KiB
Nix
Raw Permalink Normal View History

{
config,
pkgs,
lib,
...
}:
2023-02-25 17:19:48 -03:00
let
2024-06-05 01:18:48 -03:00
inherit (config.my)
key
accent
font
theme
;
2023-02-25 17:19:48 -03:00
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"
2024-03-15 23:09:46 -03:00
${pkgs.systemd}/bin/systemctl --user restart \
kdeconnect.service kdeconnect-indicator.service
2023-02-27 16:39:31 -03:00
'';
2023-02-25 17:19:48 -03:00
}
];
};
}