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.