diff --git a/awesomerc.lua.in b/awesomerc.lua.in index db1ef4d7..05a4628d 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -2,6 +2,10 @@ -- Include awesome library, with lots of useful function! require("awful") +require("tabulous") + +-- Uncomment this to activate autotabbing +-- tabulous.autotab_start() -- {{{ Colors and fonts awesome.font_set("sans 8") @@ -175,15 +179,51 @@ keybinding.new({ modkey, "Shift" }, "space", function () awful.layout.inc(layout -- Menu keybinding.new({ modkey }, "F1", function () awful.menu("Run: ", mymenubox, awful.spawn) end):add() +--- Tabulous, tab manipulation +keybinding.new({ modkey, "Control" }, "y", function () + local tabbedview = tabulous.tabindex_get() + + if tabbedview == nil then + tabbedview = tabulous.tab_create() + end + + tabulous.tab(tabbedview, awful.client.next(1)) +end):add() + +keybinding.new({ modkey, "Shift" }, "y", tabulous.untab):add() + +keybinding.new({ modkey }, "y", function () + local tabbedview = tabulous.tabindex_get() + + if tabbedview ~= nil then + local n = tabulous.next(tabbedview) + tabulous.display(tabbedview, n) + end +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() +keybinding.new({ modkey }, "t", awful.client.togglemarked):add() +keybinding.new({ modkey, 'Shift' }, "t", function () + local tabbedview = tabulous.tabindex_get() + local clients = awful.client.getmarked() + + if tabbedview == nil then + tabbedview = tabulous.tab_create(clients[1]) + table.remove(clients, 1) + end + + for k,c in pairs(clients) do + tabulous.tab(tabbedview, c) + end + +end):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 + for k, c in pairs(awful.client.getmarked()) do awful.client.movetotag(tags[screen][i], c) end end @@ -194,12 +234,26 @@ end -- {{{ Hooks -- Hook function to execute when focusing a client. function hook_focus(c) - c:border_set({ width = 1, color = "white" }) + if not awful.client.ismarked(c) then + c:border_set({ width = 1, color = "white" }) + end end -- Hook function to execute when unfocusing a client. function hook_unfocus(c) - c:border_set({ width = 1, color = "black" }) + if not awful.client.ismarked(c) then + c:border_set({ width = 1, color = "black" }) + end +end + +-- Hook function to execute when marking a client +function hook_marked(c) + c:border_set({ width = 1, color = "red" }) +end + +-- Hook function to execute when unmarking a client +function hook_unmarked(c) + c:border_set({ width = 1, color = "white" }) end -- Hook function to exeucte when the mouse is over a client. @@ -239,6 +293,8 @@ end -- Set up some hooks awful.hooks.focus(hook_focus) awful.hooks.unfocus(hook_unfocus) +awful.hooks.marked(hook_marked) +awful.hooks.unmarked(hook_unmarked) awful.hooks.manage(hook_manage) awful.hooks.mouseover(hook_mouseover) awful.hooks.arrange(hook_arrange) diff --git a/awful.lua b/awful.lua index 95e7eedc..9b2fef2d 100644 --- a/awful.lua +++ b/awful.lua @@ -31,6 +31,26 @@ local keygrabber = keygrabber -- Reset env setfenv(1, P) +-- Hook functions, wrappers around awesome's hooks. functions so we +-- can easily add multiple functions per hook. +P.hooks = {} +P.myhooks = {} + +-- Create a new userhook (for external libs) +local function userhook_create(name) + P.myhooks[name] = {} + P.hooks[name] = function (f) + table.insert(P.myhooks[name], {callback = f}) + end +end + +-- Call a created userhook (for external libs +local function userhook_call(name, args) + for i,o in pairs(P.myhooks[name]) do + P.myhooks[name][i]['callback'](unpack(args)) + end +end + -- Function to the good value in table, cycling local function array_boundandcycle(t, i) if i > #t then @@ -268,42 +288,75 @@ 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 +-- Just set an awful mark to a client to move it later. +local awfulmarked = {} +userhook_create('marked') +userhook_create('unmarked') -local function client_ontag (f) - ontag_callback = f -end - -local function client_onuntag (f) - onuntag_callback = f -end - -local function client_tag (c) +-- Mark a client +local function client_mark (c) local cl = c or client.focus_get() if cl then - for k, v in pairs(awfultags) do + for k, v in pairs(awfulmarked) do if cl == v then - return + return false end end - awfultags[cl] = true + + table.insert(awfulmarked, cl) + -- Call callback - if ontag_callback then ontag_callback(cl) end + userhook_call('marked', {cl}) + return true 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) +-- Unmark a client +local function client_unmark(c) + local cl = c or client.focus_get() + + for k, v in pairs(awfulmarked) do + if cl == v then + table.remove(awfulmarked, k) + userhook_call('unmarked', {cl}) + return true end end - t = awfultags - awfultags = {} + + return false +end + +-- Check if marked +local function client_ismarked(c) + local cl = c or client.focus_get() + if cl then + for k, v in pairs(awfulmarked) do + if cl == v then + return true + end + end + + return false + end +end + +-- Toggle marked +local function client_togglemarked(c) + local cl = c or client.focus_get() + + if not client_mark(c) then + client_unmark(c) + end +end + +-- Return the marked clients and empty the table +local function client_getmarked () + for k, v in pairs(awfulmarked) do + userhook_call('unmarked', {v}) + end + + t = awfulmarked + awfulmarked = {} return t end @@ -336,26 +389,6 @@ local function layout_set(layout) end end --- Hook functions, wrappers around awesome's hooks. functions so we --- can easily add multiple functions per hook. -P.hooks = {} -P.myhooks = {} - --- Create a new userhook (for external libs) -local function userhook_create(name) - P.myhooks[name] = {} - P.hooks[name] = function (f) - table.insert(P.myhooks[name], {callback = f}) - end -end - --- Call a created userhook (for external libs -local function userhook_call(name, args) - for i,o in pairs(P.myhooks[name]) do - P.myhooks[name][i]['callback'](unpack(args)) - end -end - P.hooks['userhook_create'] = userhook_create P.hooks['userhook_call'] = userhook_call @@ -468,10 +501,11 @@ P.client = togglefloating = client_togglefloating; moveresize = client_moveresize; movetoscreen = client_movetoscreen; - tag = client_tag; - gettagged = client_gettagged; - ontag = client_ontag; - onuntag = client_onuntag; + mark = client_mark; + unmark = client_unmark; + ismarked = client_ismarked; + togglemarked = client_togglemarked; + getmarked = client_getmarked; } P.screen = {