From 566344ffba82d219237893902474bec1644ad083 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 29 Jan 2013 02:05:12 +0100 Subject: awesome: add run_or_raises --- .config/awesome/rc.lua | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 645b1f7..1ba9689 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -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", -- cgit v1.2.3-54-g00ecf