Rofi (简体中文)

From ArchWiki

Rofi 是一个窗口选择器,运行对话框,ssh启动器和 dmenu 的替代品。它最初是由Sean Pringle编写,并由Dave Davenport扩展的simpleswitcher的克隆。



在主分支中合并对Wayland的支持已经无限期的延迟了[1]。对于Wayland的支持,安装rofi-lbonn-waylandAUR或开发版本的rofi-lbonn-wayland-gitAUR来代替。 请注意,这些包需要支持 Layer Shell protcol 的 Wayland 合成器。这包括基于wlroots的合成器,如Sway,以及一些基于Mir的合成器,但不包括mutter,例如Gnome的合成器。




  • 本地配置。一般来说,依赖于XDG,在~/.config/rofi/config.rasi里。
  • Xresources:一种将key value保留在Xserver中的方法。
  • 命令行选项。
Note: Xresources方法自rofi 1.6.0起已过时,可能随时停止工作。


$ rofi -combi-modi window,drun,ssh -theme solarized -font "hack 10" -show combi


configuration {
 modi: "window,drun,ssh,combi";
 font: "hack 10";
 combi-modi: "window,drun,ssh";
@theme "solarized"

为了得到完整的config.rasi文件的选项列表,运行rofi -dump-config命令来了解。您可以在运行rofi -dump-config > ~/.config/rofi/config.rasi时将命令的输出直接写入配置文件。

Note: i3 users be aware that putting commas in the i3 configuration file can cause issues. To bind a key to launch rofi, either use a configuration file or replace the commas with #, e.g. rofi -combi-modi window#drun#ssh.



$ rofi -combi-modi window,drun,ssh -theme solarized -font "hack 10" -show combi -icon-theme "Papirus" -show-icons

Custom themes

You can preview and apply themes for rofi with

$ rofi-theme-selector

Customizations may be saved to your .Xresources file (requires the xorg-xrdb package). To apply changes, reload .Xresources with xrdb -load ~/.Xresources.

Contributed themes

Rofi comes with several official themes, and more user themes can be found at the rofi-themes repository.

Load up an official theme, or download a .rasi user theme and place it in ~/.config/rofi/example.rasi on the command line:

$ rofi options -theme example

Alternatively, in your configuration file outside of the configuration { } block:

@theme "example"

Tips and tricks

Rofi as dmenu replacement

If called as dmenu (via a symlink), rofi acts like dmenu. Then, programs that call dmenu from a script (like passmenu from pass) will use rofi instead of dmenu.

If you prefer the look of dmenu, this approximates it:

rofi -show run -modi run -location 1 -width 100 \
		 -l 1 -line-margin 0 -line-padding 1 \
		 -separator-style none -font "mono 10" -columns 9 -bw 0 \
		 -disable-history \
		 -hide-scrollbar \
		 -color-window "#222222, #222222, #b1b4b3" \
		 -color-normal "#222222, #b1b4b3, #222222, #005577, #b1b4b3" \
		 -color-active "#222222, #b1b4b3, #222222, #007763, #b1b4b3" \
		 -color-urgent "#222222, #b1b4b3, #222222, #77003d, #b1b4b3" \
		 -kb-row-select "Tab" -kb-row-tab ""

Execute shell commands from rofi

If you want the ability to run shell commands or use your own scripts directly from rofi with seeing the output, then ensure following:

  • Define -run-shell-command '{terminal} -e SHELL -ic "{cmd} && read" where SHELL is your shell (e.g. bash, zsh). This allows you to enter the command on the inputbar followed by Shift+Enter. The terminal stays open until the next keypress.

This is an example with the recommended escaping sequence for i3:

bindsym $mod+d exec --no-startup-id rofi -show drun -run-shell-command '{terminal} -e zsh -ic "{cmd} && read"'

Unicode selection integration

Install rofimoji for a Unicode emoji/character picker integrated with rofi. See the project's README for usage and configuration.

Rofi as power management menu

Rofi can be used to perform power management operation with systemd. Clone rofi-power-menu repository. To launch it, you have to tell rofi where to find rofi-power-menu executable. For example, if the executable is in $HOME/.rofi-power-menu:

rofi -show p -modi p:$HOME/.rofi-power-menu

You can also put the executable in the PATH, and pass only its name.

To show default symbols, you may need to install ttf-nerd-fonts-symbols[损坏的链接:replaced by ttf-nerd-fonts-symbols-2048-em].

For more information, read the README file in the repository.