From 5f0c129b63b487d2c4c6d7483466fcc62b955745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Sat, 25 Feb 2023 17:19:48 -0300 Subject: [PATCH] swayidle: extract config from sway --- user/sway/default.nix | 29 +++-------------------------- user/sway/swayidle.nix | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 user/sway/swayidle.nix diff --git a/user/sway/default.nix b/user/sway/default.nix index 5a3863f..70d95ec 100644 --- a/user/sway/default.nix +++ b/user/sway/default.nix @@ -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"; diff --git a/user/sway/swayidle.nix b/user/sway/swayidle.nix new file mode 100644 index 0000000..697a1cc --- /dev/null +++ b/user/sway/swayidle.nix @@ -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"''; + } + ]; + }; +}