Files
dotfiles/modules/desktop/rofi.nix
alexion 05044de33e feat(desktop): fold calc into combi and rebind the power menu (task 0024)
Move the calc mode into the combi prompt so math results show inline
alongside apps, leaving emoji as the one tab-away mode. Rebind the
power menu from Super+Escape to Super+Shift+X, pairing it with lock on
Super+X. Shorten the layer fade-in so the launcher appears quicker.
2026-07-22 16:04:03 -04:00

62 lines
1.9 KiB
Nix

{
config,
lib,
pkgs,
...
}:
# rofi as the desktop launcher and dmenu-style menu frontend.
let
cfg = config.modules.desktop.rofi;
user = config.user.name;
# rofi carrying the plugins that back its calc and emoji modes.
rofiPkg = pkgs.rofi.override {
plugins = [
pkgs.rofi-calc
pkgs.rofi-emoji
];
};
# 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' \
| ${rofiPkg}/bin/rofi -dmenu -i -p Power)
case "$chosen" in
Lock) ${pkgs.systemd}/bin/loginctl lock-session ;;
Suspend) ${pkgs.systemd}/bin/systemctl suspend ;;
'Log out') ${pkgs.systemd}/bin/loginctl terminate-session "$XDG_SESSION_ID" ;;
Reboot) ${pkgs.systemd}/bin/systemctl reboot ;;
'Shut down') ${pkgs.systemd}/bin/systemctl poweroff ;;
esac
'';
in
{
options.modules.desktop.rofi.enable = lib.mkEnableOption "the rofi launcher";
config = lib.mkIf cfg.enable {
home-manager.users.${user} = {
# No theme is set here: Stylix's rofi target supplies the Nord one.
programs.rofi = {
enable = true;
package = rofiPkg;
# drun, run, window and calc share one prompt through combi.
# emoji is the separate mode the same window tabs to.
extraConfig = {
modi = "combi,emoji";
combi-modi = "drun,run,window,calc";
show-icons = true;
};
};
# The launcher and the session menu, kept next to the tool they drive.
# $mod is defined by the compositor config these binds share.
wayland.windowManager.hyprland.settings.bind = [
"$mod, R, exec, ${rofiPkg}/bin/rofi -show combi"
"$mod SHIFT, X, exec, ${powerMenu}"
];
};
};
}