Skip to content

Commit 56e76a4

Browse files
committed
feat(slots): make predefined slots HOF
1 parent d0dda93 commit 56e76a4

File tree

6 files changed

+60
-38
lines changed

6 files changed

+60
-38
lines changed

.cspell.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
33
"version": "0.2",
44
"useGitignore": true,
5-
"ignorePaths": [".git"],
5+
"ignorePaths": [
6+
".git"
7+
],
68
"enableGlobDot": true,
79
"words": [
810
"Aire-One",
@@ -14,7 +16,9 @@
1416
"dryrun",
1517
"fatalwarnings",
1618
"fullscreen",
19+
"halign",
1720
"hasitem",
21+
"imagebox",
1822
"JohnnyMorganz",
1923
"keygrabber",
2024
"ldoc",
@@ -30,6 +34,7 @@
3034
"rockspec",
3135
"rockspecs",
3236
"staticfct",
33-
"stylua"
37+
"stylua",
38+
"wibox"
3439
]
3540
}

spec/helper.lua

+12
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,15 @@ package.loaded["ruled.notification"] = {}
1616
package.loaded["awful.keyboard"] = {
1717
append_client_keybindings = function() end,
1818
}
19+
20+
package.loaded["awful.mouse"] = {}
21+
22+
package.loaded["beautiful"] = {}
23+
24+
package.loaded["wibox.widget.imagebox"] = {}
25+
26+
package.loaded["wibox.container.tile"] = {}
27+
28+
package.loaded["awful.wallpaper"] = {}
29+
30+
package.loaded["awful.layout"] = {}

src/awesome-slot/slots/client.lua

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1+
local keyboard = require "awful.keyboard"
2+
local mouse = require "awful.mouse"
3+
14
local client_slots = {}
25

36
function client_slots.append_mousebindings(params)
4-
local mouse = require "awful.mouse"
5-
6-
for _, bindings in pairs(params.mousebindings) do
7-
mouse.append_client_mousebindings(bindings)
7+
return function()
8+
mouse.append_client_mousebindings(params.mousebindings)
89
end
910
end
1011

1112
function client_slots.append_keybindings(params)
12-
local keyboard = require "awful.keyboard"
13-
14-
for _, bindings in pairs(params.keybindings) do
15-
keyboard.append_client_keybindings(bindings)
13+
return function()
14+
keyboard.append_client_keybindings(params.keybindings)
1615
end
1716
end
1817

src/awesome-slot/slots/ruled.lua

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1+
local client = require "ruled.client"
2+
local notification = require "ruled.notification"
3+
14
local ruled_slots = {}
25

36
function ruled_slots.append_client_rules(params)
4-
local client = require "ruled.client"
5-
6-
for _, rule in pairs(params.rules) do
7-
client.append_rule(rule)
7+
return function()
8+
client.append_rules(params.rules)
89
end
910
end
1011

1112
function ruled_slots.append_notification_rules(params)
12-
local notification = require "ruled.notification"
13-
14-
for _, rule in pairs(params.rules) do
15-
notification.append_rule(rule)
13+
return function()
14+
notification.append_rules(params.rules)
1615
end
1716
end
1817

src/awesome-slot/slots/screen.lua

+22-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
local screen_slots = {}
2-
3-
function screen_slots.wallpaper(screen, params)
4-
local beautiful = require "beautiful"
5-
local wallpaper = require "gears.wallpaper"
6-
7-
params = params or {
8-
wallpaper = beautiful.wallpaper,
9-
}
1+
local beautiful = require "beautiful"
2+
local imagebox = require "wibox.widget.imagebox"
3+
local tile = require "wibox.container.tile"
4+
local wallpaper = require "awful.wallpaper"
105

11-
local w = params.wallpaper
12-
13-
if w then
14-
-- If wallpaper is a function, call it with the screen
15-
if type(w) == "function" then
16-
w = w(screen)
17-
end
6+
local screen_slots = {}
187

19-
wallpaper.maximized(w, screen, true)
8+
function screen_slots.wallpaper(params)
9+
return function(screen)
10+
wallpaper {
11+
screen = screen,
12+
widget = {
13+
{
14+
image = params.wallpaper or beautiful.wallpaper,
15+
upscale = true,
16+
downscale = true,
17+
widget = imagebox,
18+
},
19+
valign = "center",
20+
halign = "center",
21+
tiled = false,
22+
widget = tile,
23+
},
24+
}
2025
end
2126
end
2227

src/awesome-slot/slots/tag.lua

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
local layout = require "awful.layout"
2+
13
local tag_slots = {}
24

35
function tag_slots.default_layouts(params)
4-
local layout = require "awful.layout"
5-
6-
layout.append_default_layouts(params.layouts)
6+
return function()
7+
layout.append_default_layouts(params.layouts)
8+
end
79
end
810

911
return tag_slots

0 commit comments

Comments
 (0)