lang fr|gb

howto use dmenu

dmenu is a dynamic menu for X fully controlled from the keyboard. it is available for all GNU/Linux distributions. dmenu is lightweight, fast, and is developed by suckless.org as dwm.
in Debian, it is part of the package suckless-tools.

dmenu starts simply with the dmenu_run command and list applications and scripts included in $PATH. Here's the default display:
note: once launch, demnu captures the keyboard, to skip dmenu, simply press ESC.

dmenu scripts included in livarp:

livarp includes some usefull scripts with dmenu in your /usr/local/bin directory:

dmenu-bind.sh

it's the basic utilisation script for dmenu; it just launch your applications:

#!/bin/bash
exe=`dmenu_path | dmenu -b -fn "snap" -nb '#222222' -nf '#7D7D7D' -sb '#005885' -sf '#BFBFBF' -p 'exec:'` && eval "exec $exe"

usage: launch dmenu-bind.sh from a keybind (depending on your session) and start typing the name of an application, the list is updated and ou can then type the full name or move between dmenu proposals with the arrows of your keyboard. press Enter to launch the selected application.

dmenu-home.sh

this script lists your $HOME directory and let you open/edit/display the selected file/folder with rox-filer.

#!/bin/bash
loc=`ls -A $HOME | dmenu -b -fn "snap" -nb '#222222' -nf '#7D7D7D' -sb '#005885' -sf '#D7D7D7' -p 'goto/open/edit: '` && eval "rox $loc"

usage: launch dmenu-home.sh from a keyboard shortcut (depending on your session) and start typing the name of a file or folder, you just have to choose in the dmenu proposals. press Enter to open/edit/display the selected file/folder.

dmenu-quit.sh

this script can replace shutdown.sh and let your execute actions on your machine.

#!/bin/bash
# a simple logout dialog
choice=`echo -e "0: Cancel\n1: Logout\n2: Shutdown\n3: Reboot\n4: Lock" | dmenu -b -fn "snap" -nb "#222222" -nf "#7D7D7D" -sb "#7D7D7D" -sf "#222222" -p "select an action:" | cut -d ':' -f 1`
# execute the choice in background
case "$choice" in
0) exit ;;
1) xdotool key Ctrl+Alt+BackSpace & ;;
2) sudo shutdown -h now & ;;
3) sudo shutdown -r now & ;;
4) xscreensaver-command -lock & ;;
esac

usage: launch dmenu-quit.sh from a keybind (depending on your session) then type a number or navigate through dmenu proposals with arrows keys. press Enter to execute selected action.

 

other scripts

dmenu-wall.sh

this script lists images from a 'WALLDIR' directory and display the selected image as scaled wallpaper:

#!/bin/bash
WALLDIR=$HOME/pics/walls
wall=`ls -A $WALLDIR | dmenu -b -fn "-*-fixed-*-*-*-*-10-70-*-*-*-*-*-*" -nb '#222222' -nf '#7D7D7D' -sb '#7D7D7D' -sf '#222222' -p 'set as wall:'` && eval "feh --no-xinerama --bg-scale $WALLDIR/$wall"

dmenu-todo.sh

this todo script works easily: you type, it adds a task, you select a task, it deletes it:

#!/bin/sh
## script pour gérer les différentes tâches à  faire avec dmenu.
## sources: 
# variables utilisées pour dmenu
SB="#7D7D7D"
SF="#222222"
NB="#222222"
NF="#7D7D7D"
FN="-*-fixed-*-*-*-*-10-70-*-*-*-*-*-*"
FILE=~/.todo
SCRIPT=~/bin/dmenu-todo.sh 
HEIGHT=$(cat $FILE | wc -l)
PROMPT="write:add | select:del > "
 
ACTION="cat $FILE | dmenu -fn $FN -l '$HEIGHT' -nb '$NB' -nf '$NF' -sb '$SB' -sf '$SF' -p '$PROMPT:' "
CMD=$(eval $ACTION)
while [ -n "$CMD" ]; do
	grep -q "^$CMD" $FILE
	if [ $? = 0 ]; then
		grep -v "^$CMD" $FILE > /tmp/todo
		mv /tmp/todo $FILE
	else
		echo "$CMD" >> $FILE
		exec $SCRIPT && exit 7
	fi
 
	CMD=$(eval $ACTION)
 
done
exit 0

dmenu-launch.sh

this script launch specifics scripts included in 'DIR':

#!/bin/sh
# minimal launcher with dmenu
DIR=$HOME/bin/skin_switchers
skin=`ls -1 $DIR | dmenu -b -fn '-*-fixed-*-*-*-*-10-70-*-*-*-*-*-*' -nb '#222222' -nf '#7D7D7D' -sb '#7D7D7D' -sf '#222222' -i -p 'skins: '` && eval "exec $DIR/$skin"

 

dmenu options:

option  argument    description
-b                  defines that dmenu appears at the bottom.
-i                  makes dmenu match menu entries case insensitively.
-l      digit 	    activates vertical list mode.  The given number of lines will be displayed.
                    Window height will get adjusted.
-p      texte 	    defines a prompt to be displayed before the input area.
-fn     font 	    defines the font.
-nb     #RRGGBB     defines the normal background color (#RGB, #RRGGBB, and color names are supported).
-nf 	#RRGGBB     defines the normal foreground color (#RGB, #RRGGBB, and color names are supported).
-sb 	#RRGGBB     defines the selected background color (#RGB, #RRGGBB, and color names are supported).
-sf 	#RRGGBB     defines the selected foreground color (#RGB, #RRGGBB, and color names are supported).
-v                  prints version information to standard output, then exits.

 

links: dmenu official webpage, the excellent thuban's blog(fr).

livarp_0.4 help center - arpinux@2013 - sources