How to use and install Rofi on Linux tutorial

Rofi is a free and open source application typically used in the context of very minimal graphical environments on Linux (simple windows manager like i3, instead of full fledged desktop environments like GNOME or KDE). Rofi has multiple functions: it can work as a window switcher, an application launcher or a run dialog, and can be used as a replacement for dmenu. In this tutorial we see how to install it on some of the most used Linux distributions, and how to use it.

In this tutorial you will learn:

  • How to install Rofi on Linux
  • What are the Rofi modes enabled by default
  • How to configure Rofi via configuration file
  • How to interactively select a Rofi theme
How to use and install Rofi on Linux tutorial
How to use and install Rofi on Linux tutorial

Software requirements and conventions used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Distribution independent
Software rofi
Other Root privileges only for software installation
Conventions # – requires given linux-commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux-commands to be executed as a regular non-privileged user


Installing Rofi on our favorite Linux distribution is very easy, since the application is available in the official repositories of the most used ones. To install the application on Fedora (version 1.6.1 is available on Fedora 34), for example, we can use the dnf package manager:

$ sudo dnf install rofi

On Debian and its derivatives, instead, we can use the apt-get command to achieve the same result:

$ sudo apt-get update && sudo apt-get install rofi

The version of rofi currently on Debian stable (bullseye) is 1.5.4-1.

Finally, on Archlinux, which is the only rolling distribution among the ones mentioned in this tutorial, we must use the pacman package manager:

$ sudo pacman -Sy rofi

Let’s see how Rofi works!

Rofi modes

As we already said, there are many modes Rofi can work in. The following are usually enabled by default on a common installation:

  • window
  • run
  • ssh

To launch Rofi in a specific mode, all we have to do is to use the following syntax:

$ rofi -show {mode}

Where {mode} is the name of the mode we want to use.

The window mode

The Rofi window mode can be used to obtain a list of the currently active windows in the X server (Rofi doesn’t work with wayland), and switch between them. To invoke Rofi with this functionality we run:

$ rofi -show window

The following window should appear on the screen once the command is executed:

Rofi running in “window” mode
Rofi running in “window” mode

The first thing we can notice is that we have an input field we can use to filter the application by writing their name. We can see the output in the window is divided in three columns: in the first one the workspace in which the window is active is displayed; in the second we have the name of the application itself, and in the third one, its title. Once we select a row and press enter the focus will be switched on the related application window.

The run mode

The run mode of Rofi can be used to obtain a list of the executables available in our $PATH and launch them easily. To invoke Rofi in the “run” mode, we run:

$ rofi -show run
Rofi running in “run” mode
Rofi running in “run” mode

Just like in “window” mode, we have an input field we can use to filter the elements in the list. To launch an application, we just select it and press enter.

The same field can also be used to manually enter a specific command which will be executed. Say for example we want to run Firefox in “private mode”; we have to invoke the application with the --private-window option and pass the URL we want to open as argument to the command. We would write:

Execute a custom command in run mode
Execute a custom command in run mode

The ssh mode

The “ssh” mode of Rofi is very useful, especially if we often use ssh to access remote systems. When the application is launched in this mode, it creates a list of remote hosts based on the content of the ~/.ssh/config and the ~/.ssh/known_hosts files, and allow us to ssh into them quickly. To invoke Rofi in “ssh” mode we run:

$ rofi -show ssh
Rofi running in ssh mode
Rofi running in ssh mode

As we can see in the screenshot above, once again the filter input can be used to quickly filter the entries in the list. It can also be used to manually type the user/address to connect to. For example, suppose i want to access the host with IP as the “egdoc” user. I would write:

Manual ssh access with rofi
Manual ssh access with rofi

Other Rofi modes

The ones we talked about until now are only the modes of Rofi which are usually enabled by default. Other modes exist:

  • windowcd
  • drun
  • keys
  • script
  • combi

We will not talk about these modes here, but you can easily gather information about them in the Rofi manual page. We only say that these modes can be enabled at runtime via the -modi options which accepts a string where the modes name to enable are separated by a comma. For example to enable the run, window, ssh and keys modes we would run:

$ rofi -modi "run,window,ssh,keys" -show run

The other method we can use to enable a specific set of modes (modi in the Rofi terminology) is by the application configuration file. We see how to do it in the next section.

Rofi configuration

There are many files we can use to configure Rofi, among the others, in order of evaluation:

  • The system-wide configuration file: /erc/rofi.conf
  • The per-user Xresources configuration file: $HOME/.Xresources
  • The per-user Rofi configuration file: $HOME/config/rofi/config

Rofi options can be also configured at runtime by using the dedicated option flags.

Configuration syntax

There are basically two syntax styles we can use to configure Rofi. The first is the traditional, Xresources-style syntax, which is considered deprecated in the recent versions of the application. We can obtain a template configuration where this syntax is used, using the following command:

$ rofi -dump-xresources > rofi-example-config

Here are some options configured in it:

! "Enabled modi" Set from: Default
! rofi.modi:                           window,run,ssh
! "Window width" Set from: Default
! rofi.width:                          50
! "Number of lines" Set from: Default
! rofi.lines:                          15
! "Number of columns" Set from: Default
! rofi.columns:                        1
! "Font to use" Set from: Default
! rofi.font:                           mono 12

From version 1.4 Rofi supports a new configuration format. To obtain a template configuration file where this syntax is used we can run:

$ rofi -dump-config > config.rasi

As you can observe, we redirected the output of the command to a file named config.rasi. The file name we used is mandatory if the new configuration syntax must be used. Here is an excerpt of the content of the template file:

/* modi: "window,run,ssh";*/
/*  width: 50;*/
/*  lines: 15;*/
/*  columns: 1;*/
/*  font: "mono 12";*/

In both configuration templates all lines are commented, and the relevant ones should be uncommented to become effective. It is also possible to migrate from the old the new configuration syntax using a dedicated command:

$ rofi -upgrade-config

Choosing the Rofi theme interactively

The Rofi interface can be themed. The easier way to specify what theme should be used is by the dedicated option in the configuration file. There is, however, a dedicated command which let us visualize a preview of a selected theme and optionally apply it:

$ rofi-theme-selector
The rofi theme selector
The rofi theme selector

As clearly described in the windows itself, we can visualize a preview of one of the themes reported in the list by selecting it and pressing enter. Here is an example with the “solarized” theme:

Rofi solarized theme preview
Rofi solarized theme preview

Even in this case we can use the input field to filter the available themes. To confirm we want to use a selected theme we can press Alt+e, to exit the theme chooser we can use the Esc key, instead.


In this tutorial we learned how to install Rofi on Linux distributions, and the basics of its usage. The application has many functionalities: it can be used as an applications launcher, a windows switcher or as a quick way to access ssh hosts. We saw how to invoke Rofi in the different modes enabled by default and some usage examples, how to configure it via configuration file and, finally, how to choose a theme interactively. To know more about the application, please take a look at its manual!

Comments and Discussions
Linux Forum