rofi

sunday, 31 january 2016

refactoring the dmenu scripts afforded revisiting rofi, a dmenu substitute. It didn’t get much of a look previously as it didn’t work out of the box when simply dropped into my dmenu wrapper. Back then, all my dmenu scripts called a dmenu wrapper—actually 2 wrappers, one for a horizontal ribbon menu and the other a drop down list menu.

The refactoring exercise revealed, amongst other things, what was incorrectly handled during my first attempts with rofi—my herbstluftwm dynamic monitor resizing affected rofi’s fullscreen mode and shell expansions rendered the fonts unreadable.

To circumvent the fullscreen limitations—rofi uses the virtual monitor size for fullscreen—I resorted to adjusting the padding, lines and fontsize for each of the monitors I was concerned with which allowed me to configure rofi to overlay the monitor in transparency mode in the absence of the fullscreen option..

if query primary ;then if query rez =2560 ;then padding=410 fontsize=18 lines=12 elif query rez =1440 ;then padding=200 fontsize=14 lines=10 elif query rez -1440 ;then padding=110 fontsize=14 lines=7 fi else # 1680 secondary monitor padding=230 fontsize=16 lines=10 fi

Refer to the herbstluftwm functions in the dotfiles for the query actions which determine what monitor resolution rofi is dealing with in my multihead setup.

Rofi projects dmenu

rofi

the dmenu wrapper function accepts a prompt, selection and optional parameters. Rofi adds a number of enhancements to dmenu, including the initial highlight selection. A common parameter passed by the dmenu script objects is the -no-custom option which restricts the input selection to the menu items.

dmenu() { if [ “$1” ] ;then prompt=”$1 “ shift fi if [ “$1” ] ;then if [ “${1%%-*}” != ‘’ ] ;then select=”$1” shift fi fi rofi -bg black -bc black -bw 0 -fg ‘#FDF6E3’ -hlbg black -hlfg ‘#25C0EF’ -font “PragmataPro $fontsize” -opacity 85 -eh 2 -separator-style none -hide-scrollbar -lines $lines -width 100 -fixed-num-lines -padding $padding -dmenu -p “$prompt────── “ -i -mesg ‘ ‘ -select “$select” $@ }

An empty -mesg message line adds just a touch of visual separation between the input prompt and the pick list, eliminating the need for the line separator for (IMO) a cleaner look.

dmenu

the final dmenu wrapper calls the dmenu objects..

export ... ... dmenu()

<span class="center"> ‧ &nbsp;&nbsp;‧ &nbsp;&nbsp;• &nbsp;&nbsp;‧ &nbsp;&nbsp;‧</span>

if [ $(basename $0) = dmenu ] ;then msg=$1 shift if [ -e ${0%/dmenu}/functions/dmenu/$msg ] ;then . ${0%/dmenu}/functions/dmenu/$msg $@ else usage $0 fi pgrep herbstluftwm >/dev/null && [ $fullscreen ] && toggle fullscreen fi

The dmenu scripts are also refactored under $HOME/bin/ and $HOME/bin/functions/dmenu/ to create a library of dmenu objects (which can be found in the dotfiles)..

Command Object
dmenu abook, alarm, bookmarks, browser, calc, compose, configs, dict, ebooks, edit, files, folders, halt, history, journals, logs, man, monitor, movies, music, pacnews, pass, radio, references, run, screensaver, scripts, series, systemd, test, thesaurus, zshelp, zshist

The result is a beautifully consistent presentation that can be hot-keyed (or run from the command line) and integrates my window manager workflow..

Rofi session dmenu

»»  weechat

comment ?