Skip to content

Commit

Permalink
feat(slots): make predefined slots HOF
Browse files Browse the repository at this point in the history
  • Loading branch information
Aire-One committed Nov 27, 2024
1 parent d0dda93 commit 4d6b886
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 38 deletions.
9 changes: 7 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"useGitignore": true,
"ignorePaths": [".git"],
"ignorePaths": [
".git"
],
"enableGlobDot": true,
"words": [
"Aire-One",
Expand All @@ -14,7 +16,9 @@
"dryrun",
"fatalwarnings",
"fullscreen",
"halign",
"hasitem",
"imagebox",
"JohnnyMorganz",
"keygrabber",
"ldoc",
Expand All @@ -30,6 +34,7 @@
"rockspec",
"rockspecs",
"staticfct",
"stylua"
"stylua",
"wibox"
]
}
15 changes: 7 additions & 8 deletions src/awesome-slot/slots/client.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
local keyboard = require "awful.keyboard"
local mouse = require "awful.mouse"

local client_slots = {}

function client_slots.append_mousebindings(params)
local mouse = require "awful.mouse"

for _, bindings in pairs(params.mousebindings) do
mouse.append_client_mousebindings(bindings)
return function()
mouse.append_client_mousebindings(params.mousebindings)
end
end

function client_slots.append_keybindings(params)
local keyboard = require "awful.keyboard"

for _, bindings in pairs(params.keybindings) do
keyboard.append_client_keybindings(bindings)
return function()
keyboard.append_client_keybindings(params.keybindings)
end
end

Expand Down
15 changes: 7 additions & 8 deletions src/awesome-slot/slots/ruled.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
local client = require "ruled.client"
local notification = require "ruled.notification"

local ruled_slots = {}

function ruled_slots.append_client_rules(params)
local client = require "ruled.client"

for _, rule in pairs(params.rules) do
client.append_rule(rule)
return function()
client.append_rules(params.rules)
end
end

function ruled_slots.append_notification_rules(params)
local notification = require "ruled.notification"

for _, rule in pairs(params.rules) do
notification.append_rule(rule)
return function()
notification.append_rules(params.rules)
end
end

Expand Down
39 changes: 22 additions & 17 deletions src/awesome-slot/slots/screen.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
local screen_slots = {}

function screen_slots.wallpaper(screen, params)
local beautiful = require "beautiful"
local wallpaper = require "gears.wallpaper"

params = params or {
wallpaper = beautiful.wallpaper,
}
local beautiful = require "beautiful"
local imagebox = require "wibox.widget.imagebox"
local tile = require "wibox.container.tile"
local wallpaper = require "awful.wallpaper"

local w = params.wallpaper

if w then
-- If wallpaper is a function, call it with the screen
if type(w) == "function" then
w = w(screen)
end
local screen_slots = {}

wallpaper.maximized(w, screen, true)
function screen_slots.wallpaper(params)
return function(screen)
wallpaper {
screen = screen,
widget = {
{
image = params.wallpaper or beautiful.wallpaper,
upscale = true,
downscale = true,
widget = imagebox,
},
valign = "center",
halign = "center",
tiled = false,
widget = tile,
},
}
end
end

Expand Down
8 changes: 5 additions & 3 deletions src/awesome-slot/slots/tag.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
local layout = require "awful.layout"

local tag_slots = {}

function tag_slots.default_layouts(params)
local layout = require "awful.layout"

layout.append_default_layouts(params.layouts)
return function()
layout.append_default_layouts(params.layouts)
end
end

return tag_slots

0 comments on commit 4d6b886

Please sign in to comment.