Update to Awesome 4.0

Configuration works mostly identical to previous state. Some exceptions:
- Minor changes in tag names (removed unicode symbols), as they are now
  referenced by name in the rules.
- Calendar module is not yet ported and not loaded.
- Scratch terminal on F12 key currently moves to bottom of the screen after
  first opening. Probably will be reimplemented using the new extended
  awful.spawn API.
- awsetbg util writes different wallpaperrc (preexisting wallpaperrc is ignored,
  as the filename now includes .lua)
This commit is contained in:
crater2150 2017-01-10 17:45:32 +01:00
parent 457f474a2c
commit a43b908350
10 changed files with 549 additions and 633 deletions

150
tags.lua
View file

@ -3,103 +3,105 @@ local awful = require("awful")
local conf = conf
local modkey = conf.modkey or "Mod4"
local tags={ mt={} }
local tags={}
awful.layout.layouts = {
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.tile,
awful.layout.suit.tile.bottom,
awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
awful.layout.suit.floating,
-- awful.layout.suit.magnifier,
-- awful.layout.suit.corner.nw,
-- awful.layout.suit.corner.ne,
-- awful.layout.suit.corner.sw,
-- awful.layout.suit.corner.se,
}
local function getfunc_viewonly(i)
return function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then
tag:view_only()
end
end
end
local function getfunc_viewtoggle(i)
return function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewtoggle(tags[screen][i])
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then
awful.tag.viewtoggle(tag)
end
end
end
local function getfunc_moveto(i)
return function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.movetotag(tags[client.focus.screen][i])
if client.focus then
local tag = client.focus.screen.tags[i]
if tag then
client.focus:move_to_tag(tag)
end
end
end
end
local function getfunc_clienttoggle(i)
return function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.toggletag(tags[client.focus.screen][i])
if client.focus then
local tag = client.focus.screen.tags[i]
if tag then
client.focus:toggle_tag(tag)
end
end
end
end
local defaultsetup = {
{"1:⚙"},
{ name = "2:⌘", layout = awful.layout.suit.max },
{ name = "3:☻", layout = awful.layout.suit.tile, mwfact = 0.20, ncol = 2, nmaster = 2},
{ name = "4:✉", layout = awful.layout.suit.max },
{"5:☑"},
{"6:♫"},
{"7:☣"},
{"8:☕"},
{"9:⚂"},
{"0:☠"},
{ name = "F1:☭", layout = awful.layout.suit.max },
{"F2:♚"},
{"F3:♛"},
{"F4:♜"}--,
-- {"F5:♝"},
-- {"F6:♞"},
-- {"F7:♟"},
-- {"F8:⚖"},
-- {"F9:⚛"},
-- {"F10:⚡"},
-- {"F11:⚰"},
-- {"F12:⚙"}
local tagdef = {
{"1"},
{"2", { layout = awful.layout.suit.max }},
{"3", {
layout = awful.layout.suit.tile,
master_width_factor = 0.20,
column_count = 2,
master_count = 2
}},
{"4", { layout = awful.layout.suit.max }},
{"5"},
{"6"},
{"7"},
{"8"},
{"9"},
{"0"},
{"F1", { layout = awful.layout.suit.max }},
{"F2"},
{"F3"},
{"F4", { layout = awful.layout.suit.max }},
}
local list = {}
function tags.setup(setuptable)
local setup = setuptable or defaultsetup
for s = 1, screen.count() do
list[s] = {}
for i, t in ipairs(setup) do
local layout = t.layout or conf.default_layout or awful.layout.suit.fair
local name = t.name or t[1]
list[s][i] = awful.tag.new({name}, s, layout)[1];
list[s][i].selected = false
if(t.mwfact) then
awful.tag.setmwfact(t.mwfact,list[s][i])
end
if(t.ncol) then
awful.tag.setncol(t.ncol,list[s][i])
end
if(t.nmaster) then
awful.tag.setnmaster(t.nmaster,list[s][i])
end
function tags.setup()
awful.screen.connect_for_each_screen(function(s)
for _,t in ipairs(tagdef) do
awful.tag.add(t[1], awful.util.table.join(
{screen = s},
t[2] or { layout = awful.layout.layouts[1] }
))
end
list[s][1].selected = true
end
s.tags[1]:view_only()
end)
end
function tags.create_bindings()
-- Compute the maximum number of digit we need, limited to 22
keynumber = 0
for s = 1, screen.count() do
keynumber = math.min(22, math.max(#(list[s]), keynumber));
end
local tagkeys = {}
-- Bind all key numbers to tags, using keycodes
for i = 1, keynumber do
-- Bind all number keys and F-keys to tags
for i = 1, 21 do
if i < 10 then
k = "#" .. i + 9 -- number keys 1-9
elseif i == 10 then
@ -108,23 +110,21 @@ function tags.create_bindings()
k = "F" .. i - 10 -- F keys
end
tagkeys = awful.util.table.join(tagkeys,
awful.key( { modkey }, k, getfunc_viewonly(i)),
awful.key( { modkey, "Control" }, k, getfunc_viewtoggle(i)),
awful.key( { modkey, "Shift" }, k, getfunc_moveto(i)),
awful.key( { modkey, "Control", "Shift" }, k, getfunc_clienttoggle(i))
awful.key( { modkey }, k, getfunc_viewonly(i)),
awful.key( { modkey, "Control" }, k, getfunc_viewtoggle(i)),
awful.key( { modkey, "Shift" }, k, getfunc_moveto(i)),
awful.key( { modkey, "Control", "Shift" }, k, getfunc_clienttoggle(i))
)
end
-- keys for all tags
tagkeys = awful.util.table.join(tagkeys,
awful.key({ modkey }, "u", awful.client.urgent.jumpto),
awful.key({ modkey }, "Left", awful.tag.viewprev ),
awful.key({ modkey }, "Right", awful.tag.viewnext ),
awful.key({ modkey }, "Escape", awful.tag.history.restore)
awful.key({ modkey }, "u", awful.client.urgent.jumpto),
awful.key({ modkey }, "Left", awful.tag.viewprev ),
awful.key({ modkey }, "Right", awful.tag.viewnext ),
awful.key({ modkey }, "Escape", awful.tag.history.restore)
)
return tagkeys;
end
tags.mt.__index = list
tags.mt.__newindex = list
return setmetatable(tags, tags.mt)
return tags