refactor(rofi): use executable helpers #166

Merged
alexion merged 1 commits from refactor/rofi-command-paths into main 2026-10-11 17:49:37 -04:00

View File

@@ -6,19 +6,17 @@
}: }:
# rofi as the desktop launcher and dmenu-style menu frontend. # rofi as the desktop launcher and dmenu-style menu frontend.
let let
user = config.user.name;
# A session menu built on the same themed rofi, so the power actions look # A session menu built on the same themed rofi, so the power actions look
# like every other menu the launcher drives. # like every other menu the launcher drives.
powerMenu = pkgs.writeShellScript "rofi-power-menu" '' powerMenu = pkgs.writeShellScript "rofi-power-menu" ''
chosen=$(printf '%s\n' Lock Suspend 'Log out' Reboot 'Shut down' \ chosen=$(printf '%s\n' Lock Suspend 'Log out' Reboot 'Shut down' \
| ${pkgs.rofi}/bin/rofi -dmenu -i -p Power) | ${lib.getExe pkgs.rofi} -dmenu -i -p Power)
case "$chosen" in case "$chosen" in
Lock) ${pkgs.systemd}/bin/loginctl lock-session ;; Lock) ${lib.getExe' pkgs.systemd "loginctl"} lock-session ;;
Suspend) ${pkgs.systemd}/bin/systemctl suspend ;; Suspend) ${lib.getExe' pkgs.systemd "systemctl"} suspend ;;
'Log out') ${pkgs.systemd}/bin/loginctl terminate-session "$XDG_SESSION_ID" ;; 'Log out') ${lib.getExe' pkgs.systemd "loginctl"} terminate-session "$XDG_SESSION_ID" ;;
Reboot) ${pkgs.systemd}/bin/systemctl reboot ;; Reboot) ${lib.getExe' pkgs.systemd "systemctl"} reboot ;;
'Shut down') ${pkgs.systemd}/bin/systemctl poweroff ;; 'Shut down') ${lib.getExe' pkgs.systemd "systemctl"} poweroff ;;
esac esac
''; '';
in in
@@ -26,12 +24,34 @@ in
options.modules.desktop.session.rofi.enable = lib.mkEnableOption "the rofi launcher"; options.modules.desktop.session.rofi.enable = lib.mkEnableOption "the rofi launcher";
config = lib.mkIf config.modules.desktop.session.rofi.enable { config = lib.mkIf config.modules.desktop.session.rofi.enable {
home-manager.users.${config.user.name} = hm: {
# Stylix supplies the Nord theme.
programs.rofi = {
enable = true;
font = lib.mkForce "JetBrains Mono 12";
# Application launch is the only mode, kept minimal so the prompt opens
# as fast as rofi can read the desktop entries.
# Icons are off: resolving one per entry is the bulk of drun's startup.
extraConfig = {
modi = "drun";
show-icons = false;
};
theme.window = {
border = hm.config.lib.formats.rasi.mkLiteral "2px";
border-color = hm.config.lib.formats.rasi.mkLiteral "#FFFFFF";
border-radius = hm.config.lib.formats.rasi.mkLiteral "8px";
};
};
};
registry.keybind.${config.networking.hostName} = { registry.keybind.${config.networking.hostName} = {
rofi-launcher = { rofi-launcher = {
keys = "SUPER + R"; keys = "SUPER + R";
action = { action = {
kind = "exec"; kind = "exec";
command = "${pkgs.rofi}/bin/rofi -show drun"; command = "${lib.getExe pkgs.rofi} -show drun";
}; };
}; };
@@ -43,21 +63,5 @@ in
}; };
}; };
}; };
home-manager.users.${user} = {
# No theme is set here: Stylix's rofi target supplies the Nord one.
programs.rofi = {
enable = true;
# Application launch is the only mode, kept minimal so the prompt opens
# as fast as rofi can read the desktop entries.
# Icons are off: resolving one per entry is the bulk of drun's startup.
extraConfig = {
modi = "drun";
show-icons = false;
};
};
};
}; };
} }