From a82a56d5f859cd2470339306e00bef0b828dd4e7 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 11 Jun 2008 08:52:07 +0200 Subject: [PATCH] [awful] Add a tagging system to manipulate windows Signed-off-by: Julien Danjou --- awesomerc.lua.in | 17 ++++++++++++++++- awful.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/awesomerc.lua.in b/awesomerc.lua.in index a8501de7..db1ef4d7 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -42,7 +42,7 @@ end -- Create a taglist widget mytaglist = widget.new({ type = "taglist", name = "mytaglist" }) mytaglist:mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end) -mytaglist:mouse({ modkey }, 1, function (object, tag) awful.client.toggletag(tag) end) +mytaglist:mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end) mytaglist:mouse({}, 3, function (object, tag) tag:view(not tag:isselected()) end) mytaglist:mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end) mytaglist:mouse({ }, 4, awful.tag.viewnext) @@ -174,6 +174,21 @@ keybinding.new({ modkey, "Shift" }, "space", function () awful.layout.inc(layout -- Menu keybinding.new({ modkey }, "F1", function () awful.menu("Run: ", mymenubox, awful.spawn) end):add() + +-- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them +awful.client.ontag(function (c) c:border_set({ color = "red" }) end) +keybinding.new({ modkey }, "t", awful.client.tag):add() +for i = 1, keynumber do + keybinding.new({ modkey, "Shift" }, "F" .. i, + function () + local screen = mouse.screen_get() + if tags[screen][i] then + for c, v in pairs(awful.client.gettagged()) do + awful.client.movetotag(tags[screen][i], c) + end + end + end):add() +end -- }}} -- {{{ Hooks diff --git a/awful.lua b/awful.lua index 1a7d4880..95e7eedc 100644 --- a/awful.lua +++ b/awful.lua @@ -268,6 +268,45 @@ local function layout_get(screen) end end +-- Just set a awful tag to a client to move it later. +local awfultags = {} +local ontag_callback = nil +local onuntag_callback = nil + +local function client_ontag (f) + ontag_callback = f +end + +local function client_onuntag (f) + onuntag_callback = f +end + +local function client_tag (c) + local cl = c or client.focus_get() + if cl then + for k, v in pairs(awfultags) do + if cl == v then + return + end + end + awfultags[cl] = true + -- Call callback + if ontag_callback then ontag_callback(cl) end + end +end + +-- Return the tagged client and empty the table +local function client_gettagged () + if onuntag_callback then + for k, v in pairs(awfultags) do + onuntag_callback(k) + end + end + t = awfultags + awfultags = {} + return t +end + -- Function to change the layout of the current tag. -- layouts = table of layouts (define in .awesomerc.lua) -- i = relative index @@ -429,6 +468,10 @@ P.client = togglefloating = client_togglefloating; moveresize = client_moveresize; movetoscreen = client_movetoscreen; + tag = client_tag; + gettagged = client_gettagged; + ontag = client_ontag; + onuntag = client_onuntag; } P.screen = {