From 94e19036c7ecf496121eba625f3224211692e9cc Mon Sep 17 00:00:00 2001 From: NullBite <me@nullbite.com> Date: Mon, 21 Oct 2024 15:06:28 +0200 Subject: [PATCH] home: autostart xdg implementation (plasma only) TODO make this more generic --- home/sessions/default.nix | 1 + home/sessions/plasma.nix | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 home/sessions/plasma.nix diff --git a/home/sessions/default.nix b/home/sessions/default.nix index 6e75512..38f1999 100644 --- a/home/sessions/default.nix +++ b/home/sessions/default.nix @@ -2,5 +2,6 @@ { imports = [ ./hyprland + ./plasma.nix ]; } diff --git a/home/sessions/plasma.nix b/home/sessions/plasma.nix new file mode 100644 index 0000000..2ee1877 --- /dev/null +++ b/home/sessions/plasma.nix @@ -0,0 +1,35 @@ +{ pkgs, config, lib, osConfig ? {}, ... }: +let + inherit (lib) mkOption mkEnableOption; + cfg = config.nixfiles.sessions.plasma; +in +{ + options.nixfiles.sessions.plasma = { + enable = lib.mkOption { + description = "Whether to enable the Plasma session home configuration."; + type = with lib.types; bool; + default = osConfig.nixfiles.sessions.plasma.enable or false; + example = true; + }; + }; + config = lib.mkIf cfg.enable { + + # TODO make this a generic implementation + home.packages = let + startupScript = pkgs.writeShellScript "autostart-script" + (lib.concatStringsSep "\n" + (builtins.map (x: "sh -c ${lib.escapeShellArg x} &") config.nixfiles.common.wm.autostart)); + + name = "home-manager-autostart"; + desktopFilePkg = pkgs.makeDesktopItem { + inherit name; + desktopName = "Home Manager Autostart"; + exec = startupScript; + }; + autostartPkg = pkgs.runCommand name {} '' + mkdir -p $out/etc/xdg/autostart + ln -s "${desktopFilePkg}/share/applications/${name}.desktop" "$out/etc/xdg/autostart/" + ''; + in [ autostartPkg ]; + }; +}