I've been using quick launchers like kupfer or ulauncher for a while, but I needed to switch to something else because kupfer tends to crash from time to time (Ubuntu 20.04) and ulauncher is a memory hog with lots of plugins (https://github.com/Ulauncher/Ulauncher/issues/590).
I've looked around and rofi looks like a great little launcher - with the added bonus that it runs only when you launch it (it's not resident in memory).
For best features it should be installed from git, not apt (instructions here: https://github.com/davatorium/rofi/blob/next/INSTALL.md). First prepare the build environment. You'll need to enable deb-src in your /etc/apt/sources.list for this to work. Make sure you have the correct distribution (in case you did a do-release-upgrade you may have wrong deb-src entries commented out): https://unix.stackexchange.com/questions/537537/how-to-put-some-source-uris-in-your-sources-list
git clone https://github.com/davatorium/rofi
cd rofi
git submodule update --init
autoreconf -i
mkdir build && cd build
../configure --disable-check
make
sudo make install
Now you can test it out by running a command such as this:
You should see a window like in the screenshot
Now, how about adding Firefox tab support? There is a project for it here https://gitlab.com/ddl37.nz/rofi-firefox-tabs, but I couldn't get it to work (the server part).
So, I tired brotab integration. Brotab is a project that exposes (and allows you to switch to) Firefox tabs from the CLI (https://pypi.org/project/brotab/).
Install it with:
It also needs a Firefox (or Chrome, or Brave) extension to be installed in the browser side: https://addons.mozilla.org/en-US/firefox/addon/brotab/
Once you install and enable the extension you should be able to see a listing of your open tabs by running
There is an integration example between rofi and brotab over at brotab's github page: https://github.com/balta2ar/brotab/issues/5 and we'll try to implement it.
Copy the lua code from this post https://github.com/balta2ar/brotab/issues/5#issuecomment-631165782 to ~/.config/brotab_modi.lua:
$ cat ~/.config/brotab_modi.lua
#!/usr/bin/lua
local bp = require("lua-shepi")
local rofi_markup = print("\0markup-rows\x1ftrue\n")
local function GetTabs(sin, sout, serr)
local delim = print("\x00delim\x1f\x0f")
local markup_s = '%s\n<span foreground="#6B838E">%s\n</span><span foreground="#44555D"><small><i>%s</i></small></span>\x0f'
local pipe_in = sin:read("a")
for line in pipe_in:gmatch("([^\n]*)\n") do
local id, title, url = line:match("([^\t]+)\t([^\t]+)\t([^\t]+)")
local result = string.format(markup_s, title, url:match("https?://[www%.]*(.*)"), id)
local prune_s = result:gsub("&", "&")
sout:write(prune_s)
end
end
args = {...}
local pipe = bp.bt("list") | bp.tac("-s", "\n") | bp.fun(GetTabs)
if not args[1] then
io.write(pipe())
else
os.execute(string.format("bt activate %s", args[1]:match("<i>(.-)</i>")))
end
You will need to install lua and lua-shepi packages:
sudo apt-get install lua5.3 lua5.3-dev luarocks
sudo luarocks install lua-shepi
Now you can try to run rofi to list your tabs (adjust for the file path):
rofi -modi brotab:/home/$USER/.config/brotab_modi.lua -show brotab
Now, we need to combine the brotab functionality with all the other rofi features. Let's try this command:
rofi -combi-modi window,brotab:/home/$USER/.config/brotab_modi.lua,drun,ssh,run -theme gruvbox-dark-hard -font "hack 10" -show combi -icon-theme "Papirus" -show-icons
Now you can search through open windows, open tabs, menu entries, programs and ssh entries and quickly launch them. We can save the configuration to a file and bind rofi to a key combination, so that it will be launched on demand:
mkdir ~/.config/rofi
rofi -combi-modi window,brotab:/home/$USER/.config/brotab_modi.lua,drun,ssh,run -theme gruvbox-dark-hard -font "hack 10" -show combi -icon-theme "Papirus" -show-icons -dump-config > ~/.config/rofi/config.rasi
You can bind it to any key combination you like. I use Win+Space. In XFCE go to Settings Manager -> Keyboard -> Application Shortcuts and add a new shortcut. The command to run is just:
rofi -show combi
Comments