From 952fde19cf50986c6729dfdc57d507e6d864fa9c Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Thu, 25 Jan 2024 12:17:47 +0800 Subject: [PATCH] nixos/programs/sessiond: add session example --- modules/nixos/programs/sessiond/default.nix | 82 ++++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/modules/nixos/programs/sessiond/default.nix b/modules/nixos/programs/sessiond/default.nix index 6806aa0a..11b35208 100644 --- a/modules/nixos/programs/sessiond/default.nix +++ b/modules/nixos/programs/sessiond/default.nix @@ -89,6 +89,84 @@ in }; modules = [ ./submodules/session-type.nix ]; }); + example = lib.literalExpression '' + { + "com.example.Beepeedobolyuessemm" = { + description = "Simple desktop environment featuring bspwm"; + desktopNames = [ "Beepeedobolyuessemm" ]; + + settings = { + Idle = { + Inputs = [ "motion" "button-press" "key-press" ]; + IdleSec = 120; + }; + + Lock = { + OnIdle = true; + OnSleep = true; + MuteAudio = true; + }; + + Hook = [ + { + Trigger = "Idle"; + ExecStart = "''${lib.getExe' pkgs.betterlockscreen "betterlockscreen"} --off 240"; + } + ]; + }; + + components = { + window-manager = { + description = "Window manager"; + + serviceUnit = { + # This is required for sessiond to recognize which unit is the + # window manager. + aliases = [ "window-manager.service" ]; + + script = ''' + ''${lib.getExe' pkgs.bspwm "bspwm"} -c ''${./config/bspwm/bspwmrc} + '''; + + serviceConfig = { + ExecStopPost = "''${lib.getExe' sessiondPkg "sessionctl"} stop"; + OOMScoreAdjust = -1000; + }; + }; + + targetUnit = { + requires = [ "sessiond-session.target" ]; + partOf = [ "sessiond-session.target" ]; + wantedBy = [ "sessiond-session.target" ]; + }; + }; + + hotkey-daemon = { + description = "Hotkey daemon"; + + serviceUnit = { + documentation = [ "man:sxhkd(1)" ]; + + script = ''' + ''${lib.getExe' pkgs.sxhkd "sxhkd"} -c ''${./config/sxhkd/bindings} + '''; + + serviceConfig = { + ExecReload = "''${lib.getExe' pkgs.coreutils "kill"} -SIGUSR1 $MAINPID"; + ExecStopPost = "''${lib.getExe' sessiondPkg "sessionctl"} stop"; + OOMScoreAdjust = -1000; + }; + }; + + targetUnit = { + after = [ "display-manager.service" ]; + partOf = [ "sessiond-session.target" ]; + }; + }; + }; + }; + } + ''; description = '' A set of desktop sessions to be configured with sessiond. Each of the attribute name will be used as the identifier of the desktop @@ -117,8 +195,8 @@ in systemd.packages = [ cfg.package ]; systemd.user.units = lib.mkMerge sessionSystemdUnits; - # We're disabling the upstream sessiond service since there can be multiple - # sessiond sessions here. + # We're disabling the upstream sessiond service since we have our own set + # of sessiond sessions here. systemd.user.services.sessiond.enable = false; }; }