awesome: add run_or_raises

This commit is contained in:
Tom Willemsen 2013-01-29 02:05:12 +01:00
parent 8e4b7f0f16
commit 566344ffba

View file

@ -12,6 +12,25 @@ local menubar = require("menubar")
awful.rules = require("awful.rules")
require("awful.autofocus")
function ror(program, cls)
local rorfunc = function ()
local matcher = function (c)
return awful.rules.match(c, { class = cls })
end
awful.client.run_or_raise(program, matcher)
end
return rorfunc
end
function ror_combo(mod, key, program, class)
return awful.util.table.join(
awful.key(mod, key, ror(program, class)),
awful.key(awful.util.table.join(mod, { "Shift" }), key,
function () awful.util.spawn(program) end))
end
----- Error handling
-- Check if awesome encountered an error during startup and fell back
-- to another config (This code will only ever execute for the
@ -171,7 +190,6 @@ globalkeys = awful.util.table.join(
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, }, "w", function () mymainmenu:show() end),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "n",
@ -227,9 +245,11 @@ globalkeys = awful.util.table.join(
mypromptbox[mouse.screen].widget,
awful.util.eval, nil,
awful.util.getdir("cache") .. "/history_eval")
end))
-- Menubar
-- awful.key({ modkey }, "p", function() menubar.show() end))
end),
ror_combo({ modkey }, "e", 'emacsclient -ca emacs', 'Emacs'),
ror_combo({ modkey }, "c", 'urxvt', 'URxvt'),
ror_combo({ modkey }, "w", 'conkeror', 'Conkeror'))
clientkeys = awful.util.table.join(
awful.key({ modkey, }, "f",