Using dmenu
From awesome
Contents |
I prefer dmenu because of its search style( searching for 'dc' will bring up all the words that contain 'dc', like 'linuxdcpp' and not just 'dcgui' or 'dc2k' )
- Using dmenu in its default avatar is as simple as adding the following key binding.
awful.key({modkey }, "p", function() awful.util.spawn( "dmenu_run" ) end)
- Dmenu offers a wide range of options to customize its look and feel. To pass the customization options to dmenu, use awful.util.spawn_with_shell. The color options have been taken from wmii's script.
awful.key({modkey }, "p", function()
awful.util.spawn_with_shell( "exe=`dmenu_path | dmenu -b -nf '#888888' -nb '#222222' -sf '#ffffff' -sb '#285577'` && exec $exe")
end)
- When customizing the font, be sure to use the full name for the font (XLFD), as given by the 'xfontsel' application. E.g.: "-xos4-terminus-medium-r-*-*-22-*-*-*-*-*-*-*" (using "Terminus-22" seems to work in shellscripts, but not when calling from awesome's rc.lua)
Integrating with your awesome theme
dmenu is a simple tool, but it can be well customized. I did it using Beautiful values:
awful.key({ modkey }, "r", function ()
awful.util.spawn("dmenu_run -i -p 'Run command:' -nb '" ..
beautiful.bg_normal .. "' -nf '" .. beautiful.fg_normal ..
"' -sb '" .. beautiful.bg_focus ..
"' -sf '" .. beautiful.fg_focus .. "'")
end),
Instead of directly launching dmenu_run, you can get the result of the command and let awesome run command itself. This allow to check if the command is already launched, and show the application instead of launching a new one :
-- Run or raise applications with dmenu
awful.key({ modkey }, "r",
function ()
local f_reader = io.popen( "dmenu_path | dmenu -b -nb '".. beautiful.bg_normal .."' -nf '".. beautiful.fg_normal .."' -sb '#955'")
local command = assert(f_reader:read('*a'))
f_reader:close()
if command == "" then return end
-- Check throught the clients if the class match the command
local lower_command=string.lower(command)
for k, c in pairs(client.get()) do
local class=string.lower(c.class)
if string.match(class, lower_command) then
for i, v in ipairs(c:tags()) do
awful.tag.viewonly(v)
c:raise()
c.minimized = false
return
end
end
end
awful.util.spawn(command)
end)
see man dmenu for more info