WIP: Somewm migration

This commit is contained in:
Alexander Gehrke 2026-08-12 18:09:07 +02:00
parent f5caff6684
commit ce56320097
17 changed files with 342 additions and 238 deletions

View file

@ -1,5 +1,6 @@
-- key bindings
local awful = require("awful")
local gears = require("gears")
local naughty = require("naughty")
local conf = require("localconf")
local modkey = conf.modkey or "Mod4"
@ -101,12 +102,13 @@ local function screen_in_wrapdir(dir, _screen)
for s = 1, screen.count() do
geomtbl[s] = screen[s].geometry
end
local target = awful.util.get_rectangle_in_direction(dir, geomtbl, screen[sel].geometry)
local target = gears.geometry.rectangle.get_in_direction(dir, geomtbl, screen[sel].geometry)
if not target then
local new_target = sel
while new_target do
target = new_target
new_target = awful.util.get_rectangle_in_direction(opposite_dirs[dir], geomtbl, screen[target].geometry)
new_target =
gears.geometry.rectangle.get_in_direction(opposite_dirs[dir], geomtbl, screen[target].geometry)
end
end
@ -114,22 +116,15 @@ local function screen_in_wrapdir(dir, _screen)
end
end
local function screen_focus_wrapdir(dir)
return function()
local target = screen_in_wrapdir(dir)
awful.screen.focus(target)
end
end
local function screen_move_client_wrapdir(dir)
return function(c)
local target = screen_in_wrapdir(dir)
awful.client.movetoscreen(c, target)
c:move_to_screen(target)
end
end
function binder.add_bindings(keys)
globalkeys = awful.util.table.join(globalkeys, keys)
globalkeys = gears.table.join(globalkeys, keys)
return binder
end
@ -144,11 +139,11 @@ function binder.clear()
end
function binder.apply()
naughty.notify({ text = "Reloading key bindings" })
local allkeys = awful.util.table.clone(globalkeys)
naughty.notification({ text = "Reloading key bindings" })
local allkeys = gears.table.clone(globalkeys)
for _, v in pairs(globalkeyfuncs) do
local loadedkeys = v()
allkeys = awful.util.table.join(allkeys, loadedkeys)
allkeys = gears.table.join(allkeys, loadedkeys)
end
root.keys(allkeys)
end
@ -165,7 +160,7 @@ local function client_opacity_set(c, default, max, step)
end
end
local clientkeys = awful.util.table.join(
local clientkeys = gears.table.join(
awful.key({ modkey, "Shift" }, "f", function(c)
c.fullscreen = not c.fullscreen
end),
@ -176,7 +171,9 @@ local clientkeys = awful.util.table.join(
awful.key({ modkey, "Control" }, "Return", function(c)
c:swap(awful.client.getmaster())
end),
awful.key({ modkey }, "o", awful.client.movetoscreen),
awful.key({ modkey }, "o", function(c)
c:move_to_screen()
end),
awful.key({ modkey, "Shift" }, "h", screen_move_client_wrapdir("left")),
awful.key({ modkey, "Shift" }, "l", screen_move_client_wrapdir("right")),
awful.key({ modkey, "Control" }, "o", function(c)
@ -193,7 +190,7 @@ local clientkeys = awful.util.table.join(
end),
awful.key({}, "XF86Calculater", awful.client.movetoscreen),
awful.key({ modkey }, "i", function(c)
require("naughty").notify({
naughty.notification({
text = string.format(
"name: '%s'\nclass: '%s'\ninstance: '%s'\ntype: '%s'\npid: %d",
c["name"],
@ -206,9 +203,9 @@ local clientkeys = awful.util.table.join(
end)
)
root.buttons(awful.util.table.join(awful.button({}, 4, awful.tag.viewnext), awful.button({}, 5, awful.tag.viewprev)))
root.buttons(gears.table.join(awful.button({}, 4, awful.tag.viewnext), awful.button({}, 5, awful.tag.viewprev)))
local clientbuttons = awful.util.table.join(
local clientbuttons = gears.table.join(
awful.button({}, 1, function(c)
if c.name ~= "Onboard" then
client.focus = c
@ -230,14 +227,14 @@ function binder.client.keys()
end
function binder.client.add_buttons(buttons)
clientbuttons = awful.util.table.join(clientbuttons, buttons)
clientbuttons = gears.table.join(clientbuttons, buttons)
end
function binder.client.add_bindings(keys)
clientkeys = awful.util.table.join(clientkeys, keys)
clientkeys = gears.table.join(clientkeys, keys)
end
local default_bindings = awful.util.table.join(
local default_bindings = gears.table.join(
awful.key({ modkey, "Control" }, "r", awesome.restart),
awful.key({ modkey, "Shift" }, "q", awesome.quit),
awful.key({ modkey }, "Return", spawnf(conf.cmd.terminal)),