From b946c18a1232e9529b28348a131faeb7f85668a3 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sun, 10 Nov 2024 15:54:11 +0200 Subject: [PATCH] hyprland/uwsm: part 2 Switch from run-as-service (homebrew systemd-run wrapper) to `uwsm app`. This also involved writing a new plugin for anyrun to correctly handle applications by running them with `uwsm app`. It passes the path to the desktop ID entry, as this also gives `uwsm app` context about Comment, which is then used to populate the Description of the generated systemd unit. --- home/programs/wayland/hyprland/binds.nix | 23 ++++++----- home/terminal/programs/default.nix | 1 - home/terminal/programs/transient-services.nix | 38 ------------------- 3 files changed, 11 insertions(+), 51 deletions(-) delete mode 100644 home/terminal/programs/transient-services.nix diff --git a/home/programs/wayland/hyprland/binds.nix b/home/programs/wayland/hyprland/binds.nix index f9d9f8d4..7fc6e46b 100644 --- a/home/programs/wayland/hyprland/binds.nix +++ b/home/programs/wayland/hyprland/binds.nix @@ -1,4 +1,4 @@ -{lib, ...}: let +let # binds $mod + [shift +] {1..10} to [move to] workspace {1..10} workspaces = builtins.concatLists (builtins.genList ( x: let @@ -13,12 +13,11 @@ ) 10); - toggle = program: service: let + toggle = program: let prog = builtins.substring 0 14 program; - runserv = lib.optionalString service "run-as-service"; - in "pkill ${prog} || ${runserv} ${program}"; + in "pkill ${prog} || uwsm app -- ${program}"; - runOnce = program: "pgrep ${program} || ${program}"; + runOnce = program: "pgrep ${program} || uwsm app -- ${program}"; in { wayland.windowManager.hyprland.settings = { # mouse movements @@ -45,20 +44,20 @@ in { # utility # terminal - "$mod, Return, exec, run-as-service foot" + "$mod, Return, exec, uwsm app -- foot" # logout menu - "$mod, Escape, exec, ${toggle "wlogout" true} -p layer-shell" + "$mod, Escape, exec, ${toggle "wlogout"} -p layer-shell" # lock screen - "$mod, L, exec, pgrep hyprlock || hyprlock" + "$mod, L, exec, ${runOnce "hyprlock"}" # lock screen, to be used with the special key Fn+F10 on my keyboard - "$mod, I, exec, pgrep hyprlock || hyprlock" + "$mod, I, exec, ${runOnce "hyprlock"}" # select area to perform OCR on "$mod, O, exec, ${runOnce "wl-ocr"}" ", XF86Favorites, exec, ${runOnce "wl-ocr"}" # open calculator - ", XF86Calculator, exec, ${toggle "gnome-calculator" true}" + ", XF86Calculator, exec, ${toggle "gnome-calculator"}" # open settings - "$mod, U, exec, XDG_CURRENT_DESKTOP=gnome gnome-control-center" + "$mod, U, exec, XDG_CURRENT_DESKTOP=gnome ${runOnce "gnome-control-center"}" # move focus "$mod, left, movefocus, l" @@ -99,7 +98,7 @@ in { bindr = [ # launcher - "$mod, SUPER_L, exec, ${toggle "anyrun" true}" + "$mod, SUPER_L, exec, ${toggle "anyrun"}" ]; bindl = [ diff --git a/home/terminal/programs/default.nix b/home/terminal/programs/default.nix index 954b5702..9499a040 100644 --- a/home/terminal/programs/default.nix +++ b/home/terminal/programs/default.nix @@ -6,7 +6,6 @@ ./git.nix ./nix.nix ./skim.nix - ./transient-services.nix ./yazi ./xdg.nix ]; diff --git a/home/terminal/programs/transient-services.nix b/home/terminal/programs/transient-services.nix deleted file mode 100644 index cf4e7033..00000000 --- a/home/terminal/programs/transient-services.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: let - inherit (builtins) concatStringsSep mapAttrs toString; - - path = lib.optionalString (config.home.sessionPath != []) '' - export PATH=${concatStringsSep ":" config.home.sessionPath}:$PATH - ''; - - stringVariables = mapAttrs (_: toString) config.home.sessionVariables; - - variables = lib.concatStrings (lib.mapAttrsToList (k: v: '' - export ${k}="${toString v}" - '') - stringVariables); - - apply-hm-env = pkgs.writeShellScript "apply-hm-env" '' - ${path} - ${variables} - ${config.home.sessionVariablesExtra} - exec "$@" - ''; - - # runs processes as systemd transient services - run-as-service = pkgs.writeShellScriptBin "run-as-service" '' - exec ${pkgs.systemd}/bin/systemd-run \ - --slice=app-manual.slice \ - --property=ExitType=cgroup \ - --user \ - --wait \ - bash -lc "exec ${apply-hm-env} $@" - ''; -in { - home.packages = [run-as-service]; -}