What is rofi?
Rofi is a popup list displayer which will display a list of whatever you want and do whatever you want with the selection you make from the prompted list.
Rofi started as a clone of simpleswitcher, written by Sean Pringle - a popup window switcher roughly based on superswitcher. Simpleswitcher laid the foundations, and therefore Sean Pringle deserves most of the credit for this tool. Rofi (renamed, as it lost the simple property) has been extended with extra features, like an application launcher and ssh-launcher, and can act as a drop-in dmenu replacement, making it a very versatile tool.
– Rofi - GitHub
Some use cases of Rofi
Below I am proving some functionalities I use regularly with the help of Rofi. You can find all my dotfiles related to rofi in this link
Manage your configuration files
I use the git bare repository method to manage my dotfiles which is explained here. To manager your dotfiles, you have to create a folder where your .git
directory will stay. After that, type the three commands below. I have considered my .git
directory to be in ~/.dots-git
directory.
|
|
After doing this, you can add a config file to manage with git with the following command.
|
|
You can also put your configs to a repository online by setting up a remote. Google if you don’t know how to manage git repositories.
In a fresh installation, you can download and run the below command from an online gist and all your settings will come back to the new machine!
|
|
Okay, as now you know how to manage your dots with git, lets setup rofi to quickly see and open your managed dotfiles. Below is the script:
|
|
The main idea behind this is the command dotfiles ls-tree -r master --name-only
which will print all the files in your git repository. The rest is pretty much simple to understand.
Use rofi as OCR
I am currently learning Japanese. So I often need to see the meaning of an article from a book written in English or Japanese. For this, I use tesseract and its language model dependencies. You will also need scrot to take screenshots of your desired portion of screen and imagemagick for some image processing. If you are using Arch Linux, go ahead and install them with one liner.
|
|
Then, all you need is to write a small script and assign it a keybinding.
|
|
This script will first prompt the language you want to do OCR on, then start scrot screen clipping mode. Then it will do the ORC and copy the text in your clipboard.
Super useful plugins
Rofi is already mighty by itself as it can display a list to run any application in from you desktop files or commandline programs. It can also switch focus to a open window regardless of which workspace/desktop the window is in, as long as your window manager implements Window Manager Specification Project. But to enhance its functionality beyond just a application launcher, you can add tons of plugins taken from the internet (or make one yourself). Below are the plugins I use in my daily driver machine most of which are taken straight from the AUR. Below is the image of my main rofi interface.
I achieved this by using the following launch script and some theming with rasi.
|
|
1. rofi-calc
Bring the calculator up straight hitting a shortcut key. And don’t think this lightweight calculator will do just some addition and substitution. It can do advanced calculations like the below one.
> solve(x*x/pi = 3 acres) to km
solve(((x * x) / pi) = (3 * acre), x) = 6.1758176 km
> fibonacci(133) to hex
fibonacci(133) = 0x90540BE2616C26F81F876B9
> 50m*2kg/50h to ?N
(50 meter (2 kilogram)) / (50 hour) = 555.55556 μNs
It can do this, because it uses libqalculate as the backend.
2. rofi-dmenu
A lot of program sometimes use dmenu for querying user or display things. If you have rofi installed, there is actually no reason to keep dmenu just for those applications because rofi can do everything dmenu does. But, well, the programs will look for dmenu anyways. So you can just manually create an alias for rofi -dmenu
to use rofi as an in-place replacement for dmenu. Or, what I do is install this Arch package which does exactly this.
3. rofi-file-browser-extended
Yes, Rofi can be used as a file browser. If you want to quickly open up a file from not so deep directory in you home, you do not need to open up a heavy file manager (e.g. Nautilus/Thunar). Just use super + space
(or whatever you like) to open up file browser and open a file. But as the name says, it is just a file browser, not a file manager. So you cannot copy/cut/paste your files or do such like things.
4. rofi-greenclip
Greenclip is a simple clipboard manager which has functionality to save your clipboard and manage them in your own way. Rofi-greenclip is an extension of rofi for the interfacing of greenclip. You can see your clipboard history and copy any text among those.
5. rofi-search
Rofi-search is a interactive web searching shortcut supporting Google and Duckduckgo. You can just search first from rofi and then open up your desired website only on your favorite browser. I did not include this with my default rofi access menu because it serves a bit different purpose than doing things in the desktop. So it has a separate keybinding in my machine. I use the below script to use in a keybinding.
|
|
6. rofi-top
Rofi-top shows top in your rofi. Thats it. I have put a keybinding like this in my sxhkdrc.
|
|
As you can see, I can clearly tell that my google-chrome is eating up all my memory for opening 4 tabs 😄 alongside the VSCode behind this picture.
7. rofimoji
The last extension is what I use the most while writing an article or code. I have also specified a separate keybinding for this extension. Whenever I need an emoji, I search it in rofi and rofi automatically takes it into the clipboard and also puts one emoji of that into the focused text area.
Conclusion
I have read in the internet someone sarcastically saying to just use rofi to make a desktop environment. But to be honest, with some major tweaking of the code, it is not much far from impossible. If you use rofi in a cool way, please share it in the comments so I also can use it.