Difference between revisions of "Rofi"

From ArchWiki
Jump to navigation Jump to search
m (Rofi expects theme-name in quotes in configuration-file)
m (→‎Configuration: Added information about icons)
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
 
[[ja:Rofi]]
 
[[ja:Rofi]]
 
[[pl:Rofi]]
 
[[pl:Rofi]]
 +
[[ru:Rofi]]
 
{{Related articles start}}
 
{{Related articles start}}
 
{{Related|List of applications/Other#Application launchers}}
 
{{Related|List of applications/Other#Application launchers}}
Line 25: Line 26:
 
So
 
So
  
  rofi -combi-modi window,drun,ssh -theme solarized -font "hack 10" -show combi
+
  $ rofi -combi-modi window,drun,ssh -theme solarized -font "hack 10" -show combi
  
 
can be expressed in a config file like this (New theme format):
 
can be expressed in a config file like this (New theme format):
Line 39: Line 40:
  
 
{{Note|i3 users be aware that putting commas in i3 config can cause issues. To bind a key to launch rofi, either use a config file or replace the commas with {{ic|#}} eg {{ic|rofi -combi-modi window#drun#ssh}}}}
 
{{Note|i3 users be aware that putting commas in i3 config can cause issues. To bind a key to launch rofi, either use a config file or replace the commas with {{ic|#}} eg {{ic|rofi -combi-modi window#drun#ssh}}}}
 +
 +
=== Icons ===
 +
 +
It is possible to use icons to display with their corresponding entries. Assuming you have {{pkg|papirus-icon-theme}} installed, with {{ic|-show-icons}} and defining the icon theme with {{ic|-icon-theme}}, you can have rofi diplay icons and do the following:
 +
 +
$ rofi -combi-modi window,drun,ssh -theme solarized -font "hack 10" -show combi -icon-theme "Papirus" -show-icons
  
 
==Rofi as dmenu replacement==
 
==Rofi as dmenu replacement==

Latest revision as of 20:30, 10 May 2020

Rofi is a window switcher, run dialog, ssh-launcher and dmenu replacement that started as a clone of simpleswitcher, written by Sean Pringle and later expanded by Dave Davenport.

Installation

Install the rofi package.

Configuration

There are currently four methods of setting configuration options:

  • Local configuration. Normally, depending on XDG, in ~/.config/rofi/config. This uses the Xresources format.
  • New theme format, which can have a configuration block. ~/.config/rofi/config.rasi
  • Xresources: A method of storing key values in the Xserver.
  • Command line options
Note: Xresources format will be obsolete in future rofi versions

So

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

can be expressed in a config file like this (New theme format):

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

To get a full list of options for config.rasi file run rofi -dump-config. You can write the output of the command directly to your config file while running rofi -dump-config > ~/.config/rofi/config.rasi

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

Icons

It is possible to use icons to display with their corresponding entries. Assuming you have papirus-icon-theme installed, with -show-icons and defining the icon theme with -icon-theme, you can have rofi diplay icons and do the following:

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

Rofi as dmenu replacement

If called as dmenu (via a symlink), rofi acts like dmenu. You may want to install rofi-dmenuAUR, which symlinks dmenu to rofi. 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 \
		 -lines 2 -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:

  • configure the PATH variable in ~/.profile (instead of e.g. ~/.bashrc) and then logout and re-login to your window manager/desktop environment
  • define -run-shell-command '{terminal} -e \\"{cmd}; read -n 1 -s"'. 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 -font \\"DejaVu 9\\" -run-shell-command '{terminal} -e \\" {cmd}; read -n 1 -s\\"'"

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

See the official rofi-themes repository for a list of custom themes.

Download one of the .rasi themes and place it in ~/.config/rofi/example.rasi. Then load up the theme on the command line or in a config file:

 rofi <options> -theme example

or in your configuration file

 rofi.theme:    example