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的合成器。
要知道更多关于rofi的东西和它的用法,看rofi(1)的帮助页面。
配置
目前有三种设置配置选项的方法:
- 本地配置。一般来说,依赖于XDG,在
~/.config/rofi/config.rasi
里。 - Xresources:一种将key value保留在Xserver中的方法。
- 命令行选项。
所以
$ 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
时将命令的输出直接写入配置文件。
#
, e.g. rofi -combi-modi window#drun#ssh
.图标
可以使图标和相应的条目一起显示。假设你已经安装了papirus-icon-theme包,使用-show-icons
并使用-icon-theme
定义图标,那么可以通过以下操作来让rofi显示图标:
$ 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
.
社区主题
Rofi 有一些官方主题,并且有很多用户主题。您可以在 rofi-themes 仓库中找到它们。
加载一个离线主题,或者下载 .rasi 类型文件,并将其放在~/.config/rofi/example.rasi
。
使用如下命令使用主题:
$ rofi options -theme example
或者,您可以在配置文件中的 configuration { }
块外:
@theme "example"
Tips and tricks
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"
whereSHELL
is your shell (e.g. bash, zsh). This allows you to enter the command on the inputbar followed byShift+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 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.