{ config, lib, pkgs, ... }: # rofi as the desktop launcher and dmenu-style menu frontend. let # A session menu built on the same themed rofi, so the power actions look # like every other menu the launcher drives. powerMenu = pkgs.writeShellScript "rofi-power-menu" '' chosen=$(printf '%s\n' Lock Suspend 'Log out' Reboot 'Shut down' \ | ${lib.getExe pkgs.rofi} -dmenu -i -p Power) case "$chosen" in Lock) ${lib.getExe' pkgs.systemd "loginctl"} lock-session ;; Suspend) ${lib.getExe' pkgs.systemd "systemctl"} suspend ;; 'Log out') ${lib.getExe' pkgs.systemd "loginctl"} terminate-session "$XDG_SESSION_ID" ;; Reboot) ${lib.getExe' pkgs.systemd "systemctl"} reboot ;; 'Shut down') ${lib.getExe' pkgs.systemd "systemctl"} poweroff ;; esac ''; in { options.modules.desktop.session.rofi.enable = lib.mkEnableOption "the rofi launcher"; 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; # 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"; }; }; }; registry.keybind.${config.networking.hostName} = { rofi-launcher = { keys = "SUPER + R"; action = { kind = "exec"; command = "${lib.getExe pkgs.rofi} -show drun"; }; }; rofi-power-menu = { keys = "SUPER + SHIFT + X"; action = { kind = "exec"; command = "${powerMenu}"; }; }; }; }; }