1
1
Fork 0

hyprland: use uwsm to isolate exec scope

Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
Myned 2025-02-15 15:59:54 -06:00
parent a691050bc4
commit 6cde225c08
Signed by: Myned
GPG key ID: C7224454F7881A34
5 changed files with 238 additions and 212 deletions

View file

@ -17,9 +17,6 @@ with lib; let
hyprlock = getExe hm.programs.hyprlock.package; hyprlock = getExe hm.programs.hyprlock.package;
hyprpicker = getExe pkgs.hyprpicker; hyprpicker = getExe pkgs.hyprpicker;
inhibit = hm.home.file.".local/bin/inhibit".source; inhibit = hm.home.file.".local/bin/inhibit".source;
jq = getExe pkgs.jq;
kill = getExe' pkgs.procps "kill";
kitty = getExe hm.programs.kitty.package;
left = hm.home.file.".local/bin/left".source; left = hm.home.file.".local/bin/left".source;
loginctl = getExe' pkgs.systemd "loginctl"; loginctl = getExe' pkgs.systemd "loginctl";
nautilus = getExe pkgs.nautilus; nautilus = getExe pkgs.nautilus;
@ -34,16 +31,22 @@ with lib; let
steam = getExe config.programs.steam.package; steam = getExe config.programs.steam.package;
swayosd-client = getExe' pkgs.swayosd "swayosd-client"; swayosd-client = getExe' pkgs.swayosd "swayosd-client";
toggle = hm.home.file.".local/bin/toggle".source; toggle = hm.home.file.".local/bin/toggle".source;
uwsm = getExe pkgs.uwsm;
virt-manager = getExe config.programs.virt-manager.package; virt-manager = getExe config.programs.virt-manager.package;
vrr = hm.home.file.".local/bin/vrr".source; vrr = hm.home.file.".local/bin/vrr".source;
waydroid = getExe pkgs.waydroid; waydroid = getExe pkgs.waydroid;
window = hm.home.file.".local/bin/window".source; window = hm.home.file.".local/bin/window".source;
zoom = hm.home.file.".local/bin/zoom".source; zoom = hm.home.file.".local/bin/zoom".source;
command = command: "${uwsm} app -- ${command}";
in { in {
options.custom.desktops.hyprland.binds.enable = mkOption {default = false;}; options.custom.desktops.hyprland.binds = {
enable = mkOption {default = false;};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.${config.custom.username} = { home-manager.sharedModules = [
{
wayland.windowManager.hyprland.settings = let wayland.windowManager.hyprland.settings = let
# Reverse mods and key for alphabetical sorting # Reverse mods and key for alphabetical sorting
#?? key <"KEY"> <"MODS"|null> <"DISPATCHER"> <"PARAMS"|null> #?? key <"KEY"> <"MODS"|null> <"DISPATCHER"> <"PARAMS"|null>
@ -54,7 +57,11 @@ in {
}, ${key}, ${dispatcher}${ }, ${key}, ${dispatcher}${
if (isNull params) if (isNull params)
then "" then ""
else ", ${params}" else ", ${
if dispatcher == "exec"
then command params
else params
}"
}"; }";
dropdown = concatStringsSep " " [ dropdown = concatStringsSep " " [
@ -262,6 +269,7 @@ in {
(key "Super_L" "Super+Shift" "exec" config.custom.menus.search.show) (key "Super_L" "Super+Shift" "exec" config.custom.menus.search.show)
]; ];
}; };
}; }
];
}; };
} }

View file

@ -13,7 +13,8 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
custom.desktops = mkIf config.custom.full { custom = {
desktops = mkIf config.custom.full {
hyprland = { hyprland = {
binds.enable = true; binds.enable = true;
keywords.enable = true; keywords.enable = true;
@ -29,11 +30,20 @@ in {
}; };
}; };
programs = {
uwsm.enable = true;
};
};
# https://wiki.hyprland.org # https://wiki.hyprland.org
# https://github.com/hyprwm/Hyprland # https://github.com/hyprwm/Hyprland
programs.hyprland = { programs.hyprland = {
enable = true; enable = true;
package = hm.wayland.windowManager.hyprland.finalPackage; package = hm.wayland.windowManager.hyprland.finalPackage;
# BUG: Some apps launched via exec cause session to end, wrap in uwsm to isolate scope
# https://github.com/Vladimir-csp/uwsm/issues/45
#?? uwsm app -- COMMAND
withUWSM = true; withUWSM = true;
}; };

View file

@ -15,7 +15,10 @@ with lib; let
modprobe = getExe' pkgs.kmod "modprobe"; modprobe = getExe' pkgs.kmod "modprobe";
nautilus = getExe pkgs.nautilus; nautilus = getExe pkgs.nautilus;
sway-audio-idle-inhibit = getExe pkgs.sway-audio-idle-inhibit; sway-audio-idle-inhibit = getExe pkgs.sway-audio-idle-inhibit;
uwsm = getExe pkgs.uwsm;
virsh = getExe' config.virtualisation.libvirtd.package "virsh"; virsh = getExe' config.virtualisation.libvirtd.package "virsh";
command = command: "${uwsm} app -- ${command}";
in { in {
options.custom.desktops.hyprland.keywords = { options.custom.desktops.hyprland.keywords = {
enable = mkOption {default = false;}; enable = mkOption {default = false;};
@ -87,26 +90,25 @@ in {
# https://wiki.hyprland.org/Configuring/Keywords/#executing # https://wiki.hyprland.org/Configuring/Keywords/#executing
exec = [ exec = [
"${left} --init --scroll kensington-orbit-wireless-tb-mouse" # Enforce left-pawed state (command "${left} --init --scroll kensington-orbit-wireless-tb-mouse") # Enforce left-pawed state
]; ];
# https://wiki.hyprland.org/Configuring/Keywords/#executing
exec-once = exec-once =
[ [
sway-audio-idle-inhibit # Inhibit idle while audio is playing (command sway-audio-idle-inhibit) # Inhibit idle while audio is playing
"${audio} --init" # Enforce audio profile state (command "${audio} --init") # Enforce audio profile state
config.custom.menus.clipboard.clear-silent # Clear clipboard history (command config.custom.menus.clipboard.clear-silent) # Clear clipboard history
# HACK: Launch hidden GTK windows to reduce startup time # HACK: Launch hidden GTK windows to reduce startup time
"[workspace special:hidden silent] ${loupe}" "[workspace special:hidden silent] ${command loupe}"
"[workspace special:hidden silent] ${nautilus}" "[workspace special:hidden silent] ${command nautilus}"
] ]
++ optionals config.custom.wallpaper [ ++ optionals config.custom.wallpaper [
"wallpaper" (command wallpaper)
] ]
# HACK: Delay driver initialization to work around reset issues
++ optionals config.custom.settings.vm.passthrough.blacklist [ ++ optionals config.custom.settings.vm.passthrough.blacklist [
"${virsh} list | ${grep} ${config.custom.settings.vm.passthrough.guest} || sudo ${modprobe} ${config.custom.settings.vm.passthrough.driver}" # HACK: Delay driver initialization to work around reset issues
(command "${virsh} list | ${grep} ${config.custom.settings.vm.passthrough.guest} || sudo ${modprobe} ${config.custom.settings.vm.passthrough.driver}")
]; ];
}; };
} }

View file

@ -8,6 +8,9 @@ with lib; let
cfg = config.custom.desktops.hyprland.plugins; cfg = config.custom.desktops.hyprland.plugins;
hyprctl = getExe' config.programs.hyprland.package "hyprctl"; hyprctl = getExe' config.programs.hyprland.package "hyprctl";
uwsm = getExe pkgs.uwsm;
command = command: "${uwsm} app -- ${command}";
in { in {
options.custom.desktops.hyprland.plugins = { options.custom.desktops.hyprland.plugins = {
enable = mkOption {default = false;}; enable = mkOption {default = false;};
@ -47,9 +50,9 @@ in {
# https://github.com/hyprwm/hyprland-plugins/tree/main/hyprbars#buttons-config # https://github.com/hyprwm/hyprland-plugins/tree/main/hyprbars#buttons-config
#?? hyprbars-button = COLOR, SIZE, ICON, EXEC #?? hyprbars-button = COLOR, SIZE, ICON, EXEC
hyprbars-button = [ hyprbars-button = [
"rgb(dc322f), 16,, ${hyprctl} dispatch killactive" # Close "rgb(dc322f), 16,, ${command "${hyprctl} dispatch killactive"}" # Close
"rgb(d33682), 16,, ${hyprctl} dispatch fullscreen 1" # Maximize "rgb(d33682), 16,, ${command "${hyprctl} dispatch fullscreen 1"}" # Maximize
"rgb(6c71c4), 16,, minimize" # Minimize "rgb(6c71c4), 16,, ${command minimize}" # Minimize
]; ];
}; };

View file

@ -15,8 +15,11 @@ with lib; let
libreoffice = getExe config.custom.programs.libreoffice.package; libreoffice = getExe config.custom.programs.libreoffice.package;
loupe = getExe pkgs.loupe; loupe = getExe pkgs.loupe;
steam = getExe config.programs.steam.package; steam = getExe config.programs.steam.package;
uwsm = getExe pkgs.uwsm;
virt-manager = getExe pkgs.virt-manager; virt-manager = getExe pkgs.virt-manager;
waydroid = getExe pkgs.waydroid; waydroid = getExe pkgs.waydroid;
command = command: "${uwsm} app -- ${command}";
youtube-music = getExe pkgs.youtube-music; youtube-music = getExe pkgs.youtube-music;
in { in {
options.custom.desktops.hyprland.rules = { options.custom.desktops.hyprland.rules = {
@ -30,14 +33,14 @@ in {
# https://wiki.hyprland.org/Configuring/Workspace-Rules # https://wiki.hyprland.org/Configuring/Workspace-Rules
#?? workspace = WORKSPACE, RULES #?? workspace = WORKSPACE, RULES
workspace = [ workspace = [
"special:android, on-created-empty:${launch} --workspace special:android --empty ${waydroid} app launch com.YoStarEN.Arknights" "special:android, on-created-empty:${command "${launch} --workspace special:android --empty ${waydroid} app launch com.YoStarEN.Arknights"}"
"special:game, on-created-empty:${steam}" "special:game, on-created-empty:${command steam}"
"special:music, on-created-empty:${youtube-music}" "special:music, on-created-empty:${command youtube-music}"
"special:office, on-created-empty:${launch} --workspace special:office --empty --tile -- ${libreoffice}" "special:office, on-created-empty:${command "${launch} --workspace special:office --empty --tile -- ${libreoffice}"}"
"special:password, on-created-empty:${launch} --workspace special:password --empty ${_1password}" "special:password, on-created-empty:${command "${launch} --workspace special:password --empty ${_1password}"}"
"special:terminal, on-created-empty:${ghostty}" "special:terminal, on-created-empty:${command ghostty}"
"special:vm, on-created-empty:${launch} --workspace special:vm --empty ${virt-manager}" "special:vm, on-created-empty:${command "${launch} --workspace special:vm --empty ${virt-manager}"}"
"special:wallpaper, on-created-empty:${loupe} /tmp/wallpaper.png" "special:wallpaper, on-created-empty:${command "${loupe} /tmp/wallpaper.png"}"
]; ];
# https://wiki.hyprland.org/Configuring/Window-Rules # https://wiki.hyprland.org/Configuring/Window-Rules