Rofi - window switcher, run dialog and dmenu replacement

Forum rules
General talk about software - if the program is not in the repos, please links to the developer's page or github.
User avatar
Theo
CLIt Licker
Posts: 394
Joined: Wed Nov 11, 2015 10:19 pm
Location: Nieuw-Buinen, Netherlands

Rofi - window switcher, run dialog and dmenu replacement

Unread post by Theo » Sat Dec 31, 2016 10:56 am

Not that there is much wrong with dmenu, but this seems to be a nice alternative.
More info, screenshots and downloads can be found at:

https://davedavenport.github.io/rofi/

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Rofi - window switcher, run dialog and dmenu replacement

Unread post by machinebacon » Sat Dec 31, 2016 11:09 am

good that you mention it, I never got it to work (Debian repos). Followed the manpage and the online docs. It just pops up a whiteish window and nothing happens on keypress. Does the version from the (sid) repos work for anyone here?
..gnutella..

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: Rofi - window switcher, run dialog and dmenu replacement

Unread post by dkeg » Sat Dec 31, 2016 3:09 pm

Does this work?

Code: Select all

rofi -show run -terminal urxvt -lines 5

Work hard; Complain less

User avatar
Snap
Sperminator
Posts: 189
Joined: Sun Oct 05, 2014 8:11 pm

Re: Rofi - window switcher, run dialog and dmenu replacement

Unread post by Snap » Sun Jan 01, 2017 4:59 am

It works ootb from the repos here. It only failed me when the default font is not in the system. I don't remember which one is it. Setting a new font solved the issue.

I just have two keystrokes for it. One running:

Code: Select all

rofi -combi-modi window,run -show combi
And the other doing a simpler dmenu-ish:

Code: Select all

rofi -show run
Modi can be cycled afterwards by hitting Shift+{Left,Right} They can be changed to more vi-like keystrokes.

This is the .Xresources section I ended up with:

Code: Select all

! rofi -----------------------------------------------------------------------

rofi.opacity:                        96
rofi.width:                          40
rofi.lines:                          15
rofi.columns:                        1
rofi.padding:                        1
rofi.font:                           snap 10
rofi.color-enabled:                  true
! States: 							 bg, 	  fg, 	   bgalt, 	hlbg, 	 hlfg
rofi.color-window:                   #000000, #000000, #000000
rofi.color-normal:                   #000000, #505050, #000000, #000000, #ffb964
rofi.color-active:                   #000000, #505050, #000000, #343434, #ffa922
rofi.color-urgent:                   #fdf6e3, #dc322f, #eee8d5, #dc322f, #fdf6e3
rofi.hide-scrollbar:                 true
! Separator style (none, dash, solid)
rofi.separator-style:                none
! Border width
rofi.bw:                             0

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Rofi - window switcher, run dialog and dmenu replacement

Unread post by machinebacon » Mon Mar 06, 2017 11:24 am

Thanks people, it works now. The problem was something in the Xresources (no idea what exactly, probably *.fonts) that made the rofi go white. It works with Snap's snippet.

otoh I don't see a big advantage over using dmenu(s) :)
..gnutella..

aaah
Oyster-Slurper
Posts: 21
Joined: Wed Mar 09, 2016 12:38 pm

Re: Rofi - window switcher, run dialog and dmenu replacement

Unread post by aaah » Thu Mar 09, 2017 11:33 am

I also didn't see why I should use it over dmenu, but after I started using this script I kind of like it more.
The script is handy for combining a number of things,
choosing apps to run like regular dmenu
running external scripts
running other rofi scripts
Anyway I cant remember where I got it!! but will post what I am using here.

Code: Select all

#!/usr/bin/env bash

declare -A LABELS
declare -A COMMANDS
browser='chromium --disk-cache-dir=/tmp/cache'
###
# List of defined 'bangs'
# Dont need to use ; in front if you dont want
###

# below command, type rr to use rofi like dmenu to list apps to launch

COMMANDS["rr"]="rofi -show run \"\${input}\""
LABELS["rr"]="rofi-run"

#############
# below a webbookmarks script is called
COMMANDS["rb"]=" '/home/dka/bin/rofi-scripts/rofi-bookmarks' \"\${input}\""
LABELS["rb"]="rofi-bookmarks"

#below test of running a script to run double commander
COMMANDS["dc"]="'/home/dka/bin/startdc'"
LABELS["dc"]=""

COMMANDS["iv"]="'/home/dka/bin/run-geeqie'"
LABELS["iv"]=""

#my open private folder script
COMMANDS["open-pf"]="  '/home/dka/bin/rofi-scripts/open-pf'"
LABELS["open-pf"]=""

COMMANDS["close-pf"]="  '/home/dka/bin/rofi-scripts/close-pf'"
LABELS["close-pf"]=""

# highlight a video link and run this script
COMMANDS["watchit"]="  '/home/dka/bin/rofi-scripts/watchit'"
LABELS["watchit"]=""

# call an address book script
COMMANDS["address-bk"]=" urxvt -e '/home/dka/bin/rofi-scripts/address-bk'"
LABELS["address-bk"]=""

COMMANDS["urlshorten"]="  '/home/dka/bin/rofi-scripts/url-shorten'"
LABELS["urlshorten"]=""

COMMANDS["radio4"]="  urxvt -e '/home/dka/bin/radio4'"
LABELS["radio4"]=""

# Call another rofi script, rofi notes
COMMANDS["rn"]=" '/home/dka/bin/rofi-scripts/rofi-notes' \"\${input}\""
LABELS["rn"]="rofi-notes"

COMMANDS["todo"]=" '/home/dka/bin/rofi-scripts/todo.sh'"
LABELS["todo"]="todo"

COMMANDS["edit-todos"]="leafpad   '/home/dka/.rofi_todo'"
LABELS["edit-todos"]="edit-todos"


COMMANDS["suspend"]="rofi-suspend \"\${input}\""
LABELS["suspend"]="suspend"

#google maps, type gmps blackpool or whatever!
COMMANDS["gmps"]="$browser https://www.google.nl/maps/place/\" \${input}\""
LABELS["gmps"]="gmaps"

# type web and then webaddress, ie web youtube.com
COMMANDS["web"]="chromium --disk-cache-dir=/tmp/cache \"\${input}\""
LABELS["web"]=""
# google search
COMMANDS["gs"]="$browser  www.google.com/search?q=\  \" \${input}\""
LABELS["gs"]="Web search"
#search IMBD 
COMMANDS["movie"]="$browser http://www.imdb.com/find?q=\" \${input}\""
LABELS["movie"]="movie search"
#search instructables
COMMANDS["inst"]="chromium --disk-cache-dir=/tmp/cache http://www.instructables.com/tag/?q=\" \${input}\""
LABELS["inst"]="instructables"
#search archwiki
COMMANDS["archwiki"]="$browser https://wiki.archlinux.org/index.php/\" \${input}\""
LABELS["archwiki"]=""

COMMANDS["piratebay"]="chromium --disk-cache-dir=/tmp/cache http://thepiratebay.org/search/\" \${input}\""
LABELS["piratebay"]=""

COMMANDS["stackexchange"]="chromium --disk-cache-dir=/tmp/cache http://stackexchange.com/search?q=\" \${input}\""
LABELS["stackexchange"]=""

COMMANDS["rofi-keys"]="leafpad  '/home/dka/bin/rofi-scripts/rofi-keybindings.txt'"
LABELS["rofi-keys"]=""

COMMANDS["edit-rofibangs"]="geany  '/home/dka/bin/rofi-scripts/rofi-bangs'"
LABELS["edit-rofibangs"]=""

COMMANDS["funny"]="leafpad  '/home/dka/text-files/funnysymbols.txt'"
LABELS["funny"]="funny symbols"

COMMANDS["fsearch"]="fsearch"
LABELS["fsearch"]=""

COMMANDS["qutebrowser"]="qutebrowser"
LABELS["qutebrowser"]="qutebrowser"


COMMANDS["keepassx"]="keepassx "
LABELS["keepassx"]=


COMMANDS["cs5"]='/home/dka/bin/cs5-Portable'
LABELS["cs5"]=

COMMANDS[".bin"]="spacefm -r '/home/dka/bin'"
LABELS[".bin"]=".bin"

COMMANDS[".downloads"]="spacefm -r '/home/dka/Downloads'"
LABELS[".downloads"]=".downloads"

# WEB SITES but can type rb to use rofi-bookmarks script that has more in the list than these few
COMMANDS["weer"]="chromium --disk-cache-dir=/tmp/cache http://www.buienradar.nl/weer/huizen/nl/2753468/3uurs"
LABELS["weer"]=

COMMANDS["wyt"]="$browser http://www.youtube.com"
LABELS["wyt"]=

COMMANDS["wbq"]="$browser http://linuxbbq.org/bbs/index.php?sid=e878fa6ab8409d0bfea986c99a4f4c06"
LABELS["wbq"]=

COMMANDS["wbol"]="$browser http://www.boll.com"
LABELS["wbol"]=

COMMANDS["whotmail"]='chromium --disk-cache-dir=/tmp/cache www.hotmail.com'
LABELS["whotmail"]=""
#
#####################################
# putting a # in front of the ones that call scripts, just a test ,not needed

#for password retrieval	
COMMANDS["#snippypw"]=" '/home/dka/bin/rofi-scripts/snippypw'"
LABELS["#snippypw"]=""

COMMANDS["#screenshot"]='/home/dka/bin/screenshot-scripts/myscreenshot.sh'
LABELS["#screenshot"]="screenshot"

COMMANDS["#editconfigs"]='/home/dka/bin/edit-configs-and-scripts'
LABELS["#editconfigs"]="edit"

COMMANDS["#mounttemple"]='echo mysecretpass | encfs -S /media/ElementsA/new-temple/.new-temple_encfs /media/ElementsA/templemount/'
LABELS["#mounttemple"]="#mounttemple"

COMMANDS["#unmounttemple"]='fusermount -u  /media/ElementsA/templemount'
LABELS["#unmounttemple"]="#unmounttemple"
##sign in to hotmail
COMMANDS["#hmsignin"]='sleep 5s;xdotool type 'myname';sleep 0.5s;xdotool key 132;xdotool type 'hotmail.co.uk';xdotool key Tab;xdotool type 'mygreatpassword';xdotool key "Return"'
LABELS["#hmsignin"]="#hmsignin"



################################################################################
# do not edit below
################################################################################

##
# Generate menu
##
function print_menu()
{
    for key in ${!LABELS[@]}
    do
		echo "$key    ${LABELS}"
     #   echo "$key    ${LABELS[$key]}"
     # my top version just shows the first field in labels row, not two words side by side
    done
}
##
# Show rofi.
##
function start()
{
    print_menu | rofi -dmenu -p "?=>" 
}


# Run it
value="$(start)"

# Split input.
# grab upto first space.
choice=${value%%\ *}
# graph remainder, minus space.
input=${value:$((${#choice}+1))}

##
# Cancelled? bail out
##
if test -z ${choice}
then
    exit
fi

# check if choice exists
if test ${COMMANDS[$choice]+isset}
then
    # Execute the choice
    eval echo "Executing: ${COMMANDS[$choice]}"
    eval ${COMMANDS[$choice]}
else
	eval  $choice | rofi
 # prefer my above so I can use this same script to also launch apps like geany or leafpad etc (DK)	
 #   echo "Unknown command: ${choice}" | rofi -dmenu -p "error"
fi

Post Reply