From 782a7be91d5a0cf64d6ab65ac6ec444b4d1f7404 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 15 Mar 2023 14:02:15 +0100 Subject: [PATCH] Set up a launcher --- home/common-linux.nix | 2 ++ home/common.nix | 2 +- home/kagami-pc-home.nix | 1 - home/modules/linux/graphical/default.nix | 25 +++++++++++++++++++++++ home/modules/programs/my-sway/default.nix | 7 +++++-- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/home/common-linux.nix b/home/common-linux.nix index d0e59fc..f9e3479 100644 --- a/home/common-linux.nix +++ b/home/common-linux.nix @@ -38,6 +38,8 @@ with lib; { "${config.home.homeDirectory}/.config/nixpkgs" ]; + systemd.user.startServices = "sd-switch"; + # Bluetooth controls services.mpris-proxy.enable = true; diff --git a/home/common.nix b/home/common.nix index b2700f8..63eb078 100644 --- a/home/common.nix +++ b/home/common.nix @@ -79,7 +79,7 @@ home.sessionPath = [ # Sometimes we want to install custom scripts here - "~/.local/bin" + "${config.home.homeDirectory}/.local/bin" ]; # Programs diff --git a/home/kagami-pc-home.nix b/home/kagami-pc-home.nix index 1207f42..3f0ca1f 100644 --- a/home/kagami-pc-home.nix +++ b/home/kagami-pc-home.nix @@ -16,7 +16,6 @@ # More packages home.packages = (with pkgs; [ # CLI stuff - python zip # TeX texlive.combined.scheme-full diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix index 1644ddb..7dcd99f 100644 --- a/home/modules/linux/graphical/default.nix +++ b/home/modules/linux/graphical/default.nix @@ -6,6 +6,8 @@ let birdtray = pkgs.birdtray.overrideAttrs (attrs: { cmakeFlags = [ "-DOPT_THUNDERBIRD_CMDLINE=${pkgs.thunderbird}/bin/thunderbird" ]; }); + + alwaysStartup = with pkgs; [ birdtray ]; in { imports = [ ./x11.nix ./wayland.nix ./alacritty.nix ]; @@ -20,6 +22,11 @@ in description = "Path to the wallpaper file"; default = ""; }; + startup = mkOption { + type = types.listOf types.package; + description = "List of packages to include in ~/.config/autostart"; + default = [ ]; + }; }; config = mkIf (cfg.type != null) { # Packages @@ -100,6 +107,24 @@ in # Set up Java font style _JAVA_OPTIONS = "-Dawt.useSystemAAFontSettings=lcd"; }; + + xdg.configFile = + let + f = pkg: { + name = "autostart/${pkg.name}.desktop"; + value = { + source = + let + srcFile = pkgs.runCommand "${pkg.name}-startup" { } '' + mkdir -p $out + cp $(ls -d ${pkg}/share/applications/*.desktop | head -n 1) $out/${pkg.name}.desktop + ''; + in + "${srcFile}/${pkg.name}.desktop"; + }; + }; + in + listToAttrs (map f (cfg.startup ++ alwaysStartup)); # IBus configuration # dconf.settings."desktop/ibus/general" = { # engines-order = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ]; diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index 174d2c1..1b0ad0a 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -129,7 +129,7 @@ in { command = "systemctl --user restart waybar"; always = true; } # Startup programs { command = "${cfg.browser}"; } - { command = "birdtray"; } + { command = "env PYTHONPATH=$(python -m site --user-site) ${pkgs.ulauncher}/bin/ulauncher --hide-window --no-window-shadow"; } ] ++ (if cfg.discord != null then [ { command = "${cfg.discord}"; } ] ++ lib.lists.optional @@ -177,7 +177,6 @@ in "${mod}+e" = "layout toggle split"; # Floating "${mod}+Shift+space" = "floating toggle"; - "${mod}+space" = "focus mode_toggle"; # Scratchpad "${mod}+Shift+minus" = "move scratchpad"; # Resize @@ -187,6 +186,8 @@ in "${mod}+Shift+c" = "reload"; "${mod}+Shift+e" = "exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'"; + # Launcher + "${mod}+space" = "exec ${pkgs.ulauncher}/bin/ulauncher-toggle"; } // { ## Splits "${mod}+v" = "split v"; @@ -651,6 +652,8 @@ in qt5.qtwayland # For waybar font-awesome + # For launcher + ulauncher ]); }