Files
dotfiles/modules/desktop/rofi.nix
alexion af5922b681 fix(desktop): give calc its own key instead of combi (task 0024)
rofi-calc's live result only shows with the global -no-show-match flag,
which inside combi would unfilter the drun/run/window app search. Move
math evaluation to its own Super+C invocation carrying that flag, and
return combi to drun,run,window with emoji as the tab-away mode.
2026-07-22 16:10:10 -04:00

66 lines
2.1 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 and window share one prompt through combi.
# emoji is the separate mode the same window tabs to.
extraConfig = {
modi = "combi,emoji";
combi-modi = "drun,run,window";
show-icons = true;
};
};
# The launcher, a calculator and the session menu, each next to its tool.
# calc runs on its own key, not in combi.
# Its live result needs rofi's global -no-show-match flag, which would
# unfilter the combi prompt's own app search.
# $mod is defined by the compositor config these binds share.
wayland.windowManager.hyprland.settings.bind = [
"$mod, R, exec, ${rofiPkg}/bin/rofi -show combi"
"$mod, C, exec, ${rofiPkg}/bin/rofi -show calc -modi calc -no-show-match -no-sort"
"$mod SHIFT, X, exec, ${powerMenu}"
];
};
};
}