Qball's Weblog

Rofi updates

Tags Rofi 

Rofi recently got some nice updates. They are mostly tweaks to make things work just a bit better but in total they are a good improvement.

Custom Modi’s

In Rofi you can switch between the following modi’s: window switcher, run dialog, ssh dialog. The latest changes allow you to specify the set of active modi, so if you do not use the ssh dialog you can disable it. Simple change, but very useful. In addition I made an option to add switchers using simple bash scripts. It is like the dmenu mode, but then more integrated.

Say I want to add a modi that allows me to quickly switch between the available i3 desktops (instead of windows). You first specify (either via Xresources or command line) the new switcher:

rofi.switchers: window,run,ssh,Workspace:i3_switch_workspace_script.sh

Workspace is the name it shows as prompt, i3_switch_workspace_script.sh is the script that gets called.

The i3_switch_workspace_script.sh is as follow:


if [ -z $@ ]
function gen_workspaces()
    i3-msg -t get_workspaces | tr ',' '\n' | grep "name" | sed 's/"name":"\(.*\)"/\1/g' | sort -n

echo empty; gen_workspaces

    if [ x"empty" = x"${WORKSPACE}" ]
        i3_empty_workspace.sh >/dev/null
    elif [ -n "${WORKSPACE}" ]
        i3-msg workspace "${WORKSPACE}" >/dev/null

Rofi will first call the script with no arguments, this will make it generate the list of available workspaces. Once the user selected an entry, Rofi calls the script again and passes the selected item as argument. (the above script can be found in Rofi’s git Examples/ directory).

More advanced scripts can be made that have sub-menu’s, an example of this is the domo_rofi_script.sh in the repository. If you the user selects a command, the script returns a new set of options, Rofi will list this until the script returns nothing, indicating it is done.

To quicker switch between the different modi, the user can press alt-4 to switch to the 4th modi directly.

Pango support

This is a change that won’t affect much for most users, but fixes a lot of issues people had that uses ‘complex’ character sets. Because of the switch to pango the following things now work as they should:

There are of course some downsides:

A video demonstrating (made by Rafi) can be found here

Other fixes and additions

Dmenu compatibility.

Disable levenshtein sorting when in dmenu mode.

Dmenu incompatibility

I also broke dmenu compatibly by added a shift-enter mode. This outputs the selected line, but redraws the menu with the next entry selected. This way a script can make the user select multiple items more efficiently. Clerk uses this.


Several small (1 pixel) offsets and other issues where fixed. So the overall look should be a bit better.

comments powered by Disqus