From: martin f. krafft Date: Sun, 11 Sep 2016 08:10:06 +0000 (+0200) Subject: rewrite tabs creation based on a config table X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/01e8bae5bdc4719c23fbd479814c35dddff5fbab?ds=inline rewrite tabs creation based on a config table --- diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index d262bf7..4f9fe01 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -94,6 +94,20 @@ local function client_menu_toggle_fn() end end +local function sorted_pairs(t, f) + local a = {} + for n in pairs(t) do table.insert(a, n) end + table.sort(a, f) + local i = 0 -- iterator variable + local iter = function () -- iterator function + i = i + 1 + if a[i] == nil then return nil + else return a[i], t[a[i]] + end + end + return iter +end + local function print_table(tbl, indent) if not indent then indent = 0 end for k, v in pairs(tbl) do @@ -188,6 +202,39 @@ mytasklist.buttons = awful.util.table.join( -- }}} -- {{{ Tags +tags = {} +tags.config = {} +tags.config["main"] = { + t1 = { layout = layout_default, selected = true }, + t2 = { layout = layout_default }, + t3 = { layout = layout_tiled }, + t4 = { layout = layout_tiled }, + t5 = { layout = layout_tiled }, + t6 = { layout = layout_floating }, + t7 = { layout = layout_maximised }, + t8 = { layout = layout_maximised }, + t9 = { layout = layout_maximised }, +} +tags.config["aux"] = { + t1 = { layout = layout_default, selected = true }, + t2 = { layout = layout_default }, + t3 = { layout = layout_tiled }, + t4 = { layout = layout_floating }, + t5 = { layout = layout_floating }, + t6 = { layout = layout_floating }, + t7 = { layout = layout_floating }, + t8 = { layout = layout_floating }, + t9 = { layout = layout_maximised }, +} + +screentags = {} +screentags[1] = tags.config["main"] +if screen.count() == 2 then -- aux screen is on the right + screentags[2] = tags.config["aux"] +elseif screen.count() == 3 then -- main screen is still #1 in the middle + screentags[2] = tags.config["aux"] + screentags[3] = tags.config["aux"] +end awful.screen.connect_for_each_screen(function(s) -- Wallpaper @@ -200,12 +247,14 @@ awful.screen.connect_for_each_screen(function(s) --DISABLED-- gears.wallpaper.maximized(wallpaper, s, true) --DISABLED--end - -- Each screen has its own tag table. - tags = awful.tag.new({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, layout_default) - tags[7].layout = layout_maximised - tags[8].layout = layout_maximised - tags[9].layout = layout_maximised - tags[1].selected = true + if not tags[s.index] then + tags[s.index] = {} + end + for n,p in sorted_pairs(screentags[s.index]) do + p["screen"] = s + n = string.sub(n, 2) -- remove leading 't' needed for syntax in table + table.insert(tags[s.index], awful.tag.add(n, p)) + end -- Create a promptbox for each screen mypromptbox[s] = awful.widget.prompt()