Cool things you can do with Rofi
Rofi comes with modi for your open windows, ssh connections, binaries in path, and desktop files.
There are also multiple projects that use Rofi as a general UI like rofi-pass.
All those nice features already make it super useful by default, but why not make your life even easier by adding more modi?
Since we can already search all ssh connections, it works nicely when you also add all the other connection types, such as VNC connections or even RDP connections that you make frequently.
A simple modi that lists files in a directory and executes them will look like this:
#!/usr/bin/sh remote_files=$(ls -1 ~/remote/) if [ "$@" ] then coproc ( xterm -e ~/remote/"$@" > /dev/null 2>&1 ) exit; else for remote_file_scripts in $remote_files do echo "$remote_file_scripts" done fi exit 0
Add this to your rofi modi and combi in
rofi.modi: combi,run,window,drun,ssh,remote:~/.config/rofi/remote.sh rofi.combi-modi: window,run,ssh,remote
and put your VNC shell scripts in the ~/remote/ dir. My connection files usually look like this:
#!/bin/bash vncviewer 10.0.0.22 -passwd <(vncpasswd -f <<<$(pass show devices/kvm-stahl | head -n1))
(yes, it takes passwords directly from pass, isn't it comfy?)
Now when you search your rofi combi, it will also show all the scripts from that directory.
Another thing i am doing, is tightly integrating rofi with my browser and bookmarks manager.
Fortunately, vimb stores all its browsing history in
~/.config/vimb/history so its as simple as cat'ing it out.
For bookmarks i use
shiori in json mode to get the urls. I used to parse it with
shiori print -j | jq '. .url' | tr -d '"' but turns out
jq is slow as shit and its way better to just do some grepping and seding.
So, rofi script to integrate with a browser would look like this:
#!/usr/bin/sh mybookmarks="$(shiori print -j | grep '\"url\"' | tr -d '[:blank:]' | sed -e s/\"url\":\"/\/g -e s/\",//g)" myhistory="$(tac ~/.config/"$BROWSER"/history | cut -f 1 | uniq)" if [ "$@" ] then coproc ( "$BROWSER" "$@" > /dev/null 2>&1 ) exit; else echo "$myhistory" "$mybookmarks" fi exit 0
After adding it to modi and combi:
rofi.modi: combi,run,browse:~./config/vimb/vimb.sh,window,drun,ssh,remote:~/.config/rofi/remote.sh rofi.combi-modi: window,run,ssh,remote,browse
not only can you now directly search your entire browsing history and bookmarks, you can also select the browse modi and enter a URL or query to launch the browser immediately.
With qutebrowser, it was slightly harder to get the browsing history, but its still possible by querying its sqlite database
sqlite3 ~/.local/share/qutebrowser/history.sqlite .dump – everything is pretty much the same from there.