Skip to content

Commit d4eb27a

Browse files
committed
Complete multi-monitor support and component framework added.
1 parent 121a0bb commit d4eb27a

File tree

13 files changed

+665
-511
lines changed

13 files changed

+665
-511
lines changed

config.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ local config = {
5555
main_panel = 'wibar', -- variants: wibar, polybar, none
5656
--{{{ Features Activity
5757
dashboard_enabled = true,
58+
collage_enabled = true,
5859
desktop_enabled = false,
5960
active_corners_enabled = true,
6061
--}}}

fishlive/collage/init.lua

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ local gears = require("gears")
1212
local wibox = require("wibox")
1313
local surface = require("gears.surface")
1414
local helpers = require("fishlive.helpers")
15+
local capi = {
16+
screen = screen
17+
}
1518

1619
-- fishlive collage submodule
1720
-- fishlive.collage
1821
local collage = { _NAME = "fishlive.collage" }
1922

20-
function collage.align(align, posx, posy, imgwidth, imgheight)
23+
function collage.align(align, posx, posy, imgwidth, imgheight, screen)
2124
if align == "top-left" then uposx = posx; uposy = posy
2225
elseif align == "top-right" then uposx = posx - imgwidth; uposy = posy
23-
elseif align == "bottom-left" then uposx = posx + imgwidth; uposy = posy - imgheight
24-
elseif align == "bottom-right" then uposx = posx - imgwidth; uposy = posy - imgheight
26+
elseif align == "bottom-left" then uposx = screen.geometry.width - posx + imgwidth; uposy = screen.geometry.height - posy - imgheight
27+
elseif align == "bottom-right" then uposx = screen.geometry.width - posx - imgwidth; uposy = screen.geometry.height - posy - imgheight
2528
end
2629
return uposx, uposy
2730
end
@@ -68,22 +71,25 @@ function collage.calcShadow(imgwidth, imgheight, uposx, uposy)
6871
return width, height, x, y
6972
end
7073

71-
function collage.placeCollageImage(reqimgwidth, reqimgheight, posx, posy, align, imgsrcs, imgidx, ontop)
74+
function collage.placeCollageImage(s, reqimgwidth, reqimgheight, posx, posy, align, imgsrcs, imgidx, ontop)
7275
local homeDir = os.getenv("HOME")
7376
local shadowsrc = homeDir .. "/.config/awesome/fishlive/collage/shadow.png"
7477
local imgsrc = imgsrcs[imgidx]
7578

7679
local imgwidth, imgheight, imgratio = collage.calcImageRes(imgsrc, reqimgwidth, reqimgheight)
77-
local uposx, uposy = collage.align(align, posx, posy, imgwidth, imgheight)
80+
local uposx, uposy = collage.align(align, posx, posy, imgwidth, imgheight, s)
7881
local shwWidth, shwHeight, shwX, shwY = collage.calcShadow(imgwidth, imgheight, uposx, uposy)
7982
local ontop = ontop or false and true
8083

84+
local geom = s.geometry
85+
8186
local imgboxShw = wibox({
87+
screen = s,
8288
type = "desktop",
8389
width = shwWidth,
8490
height = shwHeight,
85-
x = shwX,
86-
y = shwY,
91+
x = geom.x + shwX,
92+
y = geom.y + shwY,
8793
visible = true,
8894
ontop = ontop,
8995
opacity = 1.00,
@@ -103,10 +109,11 @@ function collage.placeCollageImage(reqimgwidth, reqimgheight, posx, posy, align,
103109
}
104110
}
105111
local imgbox = wibox({
112+
screen = s,
106113
type = "desktop",
107114
width = imgwidth,
108115
height = imgheight,
109-
x = uposx,
116+
x = geom.x + uposx,
110117
y = uposy,
111118
visible = true,
112119
ontop = ontop,
@@ -143,10 +150,11 @@ function collage.placeCollageImage(reqimgwidth, reqimgheight, posx, posy, align,
143150
if imgidx > #imgsrcs then imgidx = 1 end
144151
imgsrc = imgsrcs[imgidx]
145152
imgwidth, imgheight, imgratio = collage.calcImageRes(imgsrc, reqimgwidth, reqimgheight)
146-
uposx, uposy = collage.align(align, posx, posy, imgwidth, imgheight)
153+
uposx, uposy = collage.align(align, posx, posy, imgwidth, imgheight, s)
147154
shwWidth, shwHeight, shwX, shwY = collage.calcShadow(imgwidth, imgheight, uposx, uposy)
148155

149-
imgboxShw.x = shwX
156+
imgboxShw.screen = s
157+
imgboxShw.x = geom.x + shwX
150158
imgboxShw.y = shwY
151159
imgboxShw.width = shwWidth
152160
imgboxShw.height = shwHeight
@@ -156,30 +164,42 @@ function collage.placeCollageImage(reqimgwidth, reqimgheight, posx, posy, align,
156164
shwWibox.forced_height = shwHeight
157165
shwWibox.horizontal_fit_policy = "fit"
158166
shwWibox.vertical_fit_policy = "fit"
167+
self.screen = s
159168
self.width = imgwidth
160169
self.height = imgheight
161-
self.x = uposx
170+
self.x = geom.x + uposx
162171
self.y = uposy
163172
self:get_children_by_id("img")[1].image = gears.surface.load_uncached(imgsrc)
164173
end)
165174

166175
return { image = imgbox, shadow = imgboxShw }
167176
end
168177

178+
-- function for search and find tag according to bidx or index
179+
local function find_tag_by_ids(id)
180+
for scr in capi.screen do
181+
-- check if bidx is used bidx (for shared tags)
182+
local use_bidx = scr.tags[1] and scr.tags[1].bidx ~= nil
183+
184+
for _, tag in ipairs(scr.tags) do
185+
if (use_bidx and tag.bidx == id) or (not use_bidx and scr.tags[id]) then
186+
return tag, scr -- return found tag and its screen
187+
end
188+
end
189+
end
190+
return nil
191+
end
192+
169193
-- Tag Collage Changer
170194
function collage.registerTagCollage(t)
171-
local screen = t.screen
172195
local collage_template = t.collage_template
173196
local imgsources = t.imgsources
174197
local tagids = t.tagids
175198
local imgboxes = nil
176199

177-
-- For each screen
178-
for scr in screen do
179-
-- Go over each tag
180-
for t = 1,#tagids do
181-
local tag = scr.tags[tagids[t]]
182-
if tag == nil then goto continue end
200+
for t = 1,#tagids do
201+
local tag = find_tag_by_ids(tagids[t])
202+
if tag then
183203
tag:connect_signal("property::selected", function (tag)
184204
-- if not selected, hide collage
185205
if not tag.selected and imgboxes ~= nil then
@@ -196,6 +216,7 @@ function collage.registerTagCollage(t)
196216
imgboxes = {}
197217
for i = 1,#collage_template do
198218
imgboxes[i] = collage.placeCollageImage(
219+
tag.screen,
199220
collage_template[i].max_width or -1,
200221
collage_template[i].max_height or -1,
201222
collage_template[i].posx or 0,
@@ -215,7 +236,6 @@ function collage.registerTagCollage(t)
215236
end
216237
end
217238
end)
218-
::continue::
219239
end
220240
end
221241
end

fishlive/helpers.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ end
119119

120120
-- get max screen_resolution X coordination
121121
function helpers.screen_res_x()
122-
return io.popen("echo $(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1)"):read("*all"):gsub("%s+", "")
122+
--return io.popen("echo $(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1)"):read("*all"):gsub("%s+", "")
123+
return awful.screen.focused().geometry.width
123124
end
124125

125126
-- get max screen_resolution Y coordination
126127
function helpers.screen_res_y()
127-
return io.popen("echo $(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f2)"):read("*all"):gsub("%s+", "")
128+
--return io.popen("echo $(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f2)"):read("*all"):gsub("%s+", "")
129+
return awful.screen.focused().geometry.height
128130
end
129131

130132
-- }}}
@@ -683,7 +685,7 @@ function helpers.hover_pointer(widget)
683685
local w = mouse.current_wibox
684686
old_cursor, old_wibox = w.cursor, w
685687
w.cursor = "hand2"
686-
widget:get_children_by_id("custom_icon")[1].font = beautiful.icon_font.."31"
688+
widget:get_children_by_id("custom_icon")[1].font = beautiful.icon_font.."29"
687689
end)
688690
widget:connect_signal("mouse::leave", function()
689691
if old_wibox then

fishlive/wallpaper/init.lua

Lines changed: 55 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* (c) 2022, A.Fischer
88
--]]
99

10-
local awful = require("awful")
1110
local gears = require("gears")
1211
local helpers = require("fishlive.helpers")
1312

@@ -17,37 +16,34 @@ local wallpaper = { _NAME = "fishlive.wallpaper" }
1716

1817
-- User Wallpaper Changer
1918
function wallpaper.createUserWallpaper(t)
20-
local screen = t.screen
21-
local wppath_user = t.wppath_user
22-
local wp_user = helpers.scandir(wppath_user)
23-
local wp_user_idx = 0
24-
t.wp_user = wp_user
19+
local wppath_user = t.wppath_user
20+
local wp_user = helpers.scandir(wppath_user)
21+
local wp_user_idx = 0
22+
t.wp_user = wp_user
2523

26-
return function(direction)
27-
local maxIdx = #wp_user
28-
wp_user_idx = wp_user_idx + direction
29-
if wp_user_idx < 1 then wp_user_idx = maxIdx end
30-
if wp_user_idx > maxIdx then wp_user_idx = 1 end
24+
return function(direction, scr)
25+
local maxIdx = #wp_user
26+
wp_user_idx = wp_user_idx + direction
27+
if wp_user_idx < 1 then wp_user_idx = maxIdx end
28+
if wp_user_idx > maxIdx then wp_user_idx = 1 end
3129

32-
local wp = wp_user[wp_user_idx]
30+
local wp = wp_user[wp_user_idx]
3331

34-
for s in screen do
35-
for i = 1,#s.tags do
36-
local tag = s.tags[i]
37-
if tag.selected then
38-
t.wallpaper_user = wppath_user .. wp
39-
t.wallpaper_user_tag = tag
40-
awesome.emit_signal("wallpaper::change", t.wallpaper_user)
41-
gears.wallpaper.maximized(t.wallpaper_user, s, false)
42-
end
43-
end
44-
end
45-
end
32+
if not scr then scr = mouse.screen end
33+
34+
local tag = scr.selected_tag
35+
if tag.selected then
36+
t.wallpaper_user = wppath_user .. wp
37+
t.wallpaper_user_tag = tag
38+
awesome.emit_signal("wallpaper::change", t.wallpaper_user)
39+
gears.wallpaper.maximized(t.wallpaper_user, scr, false)
40+
end
41+
end
4642
end
4743

4844
-- Tag Wallpaper Changer
4945
function wallpaper.registerTagWallpaper(t)
50-
local screen = t.screen
46+
local scr = t.screen
5147
local wp_selected = t.wp_selected
5248
local wp_portrait = t.wp_portrait
5349
local wp_random = t.wp_random
@@ -56,45 +52,42 @@ function wallpaper.registerTagWallpaper(t)
5652
local wp_colorscheme_params = t.wp_colorscheme_params
5753
local change_wallpaper_colorscheme = t.change_wallpaper_colorscheme
5854

59-
-- For each screen
60-
for scr in screen do
61-
-- Detect if the screen is in portrait mode
62-
local is_portrait = scr.geometry.width < scr.geometry.height
63-
-- Set actual wallpaper for first tag and screen
64-
local wp = is_portrait and wp_portrait[1] or wp_selected[1]
65-
if wp == "random" then wp = wp_random[1] end
66-
awesome.emit_signal("wallpaper::change", wppath .. wp)
67-
gears.wallpaper.maximized(wppath .. wp, scr, false)
55+
-- Detect if the screen is in portrait mode
56+
local is_portrait = scr.geometry.width < scr.geometry.height
57+
-- Set actual wallpaper for first tag and screen
58+
local imgidx = scr.tags[1].bidx and scr.tags[1].bidx or 1
59+
local wp = is_portrait and wp_portrait[imgidx] or wp_selected[imgidx]
60+
if wp == "random" then wp = wp_random[1] end
61+
awesome.emit_signal("wallpaper::change", wppath .. wp)
62+
gears.wallpaper.maximized(wppath .. wp, scr, false)
6863

69-
-- Go over each tab
70-
for t = 1,#scr.tags do
71-
local tag = scr.tags[t]
72-
tag:connect_signal("property::selected", function (tag)
73-
-- And if selected
74-
if not tag.selected then return end
75-
-- Set the color of tag
76-
--theme.taglist_fg_focus = theme.baseColors[tag.index]
77-
-- Set random wallpaper
78-
if wp_user_params.wallpaper_user_tag == tag then
79-
wp = wp_user_params.wallpaper_user
80-
elseif wp_colorscheme_params.wallpaper_user_tag == tag then
81-
wp = wp_colorscheme_params.wallpaper_user
82-
elseif wp_selected[t] == "random" then
83-
local position = math.random(1, #wp_random)
84-
wp = wppath .. wp_random[position]
85-
elseif wp_selected[t] == "colorscheme" then
86-
if not wp_colorscheme_params.wallpaper_user then
87-
change_wallpaper_colorscheme(1)
88-
end
89-
wp = wp_colorscheme_params.wallpaper_user
90-
else
91-
wp = wppath .. (is_portrait and wp_portrait[t] or wp_selected[t])
64+
-- Go over each tab
65+
for t = 1, #scr.tags do
66+
local tag = scr.tags[t]
67+
--todo sharedtags - active tag is moved to another screen - ensure notification
68+
tag:connect_signal("property::selected", function(tag)
69+
-- And if selected
70+
if not tag.selected then return end
71+
local imgidx = tag.bidx and tag.bidx or t
72+
-- Set random wallpaper
73+
if wp_user_params.wallpaper_user_tag == tag then
74+
wp = wp_user_params.wallpaper_user
75+
elseif wp_colorscheme_params.wallpaper_user_tag == tag then
76+
wp = wp_colorscheme_params.wallpaper_user
77+
elseif wp_selected[imgidx] == "random" then
78+
local position = math.random(1, #wp_random)
79+
wp = wppath .. wp_random[position]
80+
elseif wp_selected[imgidx] == "colorscheme" then
81+
if not wp_colorscheme_params.wallpaper_user then
82+
change_wallpaper_colorscheme(1, tag.screen)
9283
end
93-
--gears.wallpaper.fit(wppath .. wp_selected[t], s)
94-
awesome.emit_signal("wallpaper::change", wp)
95-
gears.wallpaper.maximized(wp, scr, false)
96-
end)
97-
end
84+
wp = wp_colorscheme_params.wallpaper_user
85+
else
86+
wp = wppath .. (is_portrait and wp_portrait[imgidx] or wp_selected[imgidx])
87+
end
88+
awesome.emit_signal("wallpaper::change", wp)
89+
gears.wallpaper.maximized(wp, tag.screen, false)
90+
end)
9891
end
9992
end
10093

fishlive/widget/dashboard/collage.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local fishlive = require("fishlive")
22
local collage = require("fishlive.collage")
33
local fhelpers = require("fishlive.helpers")
4+
local awful = require("awful")
45

56
local imgbox = nil
67

@@ -10,9 +11,10 @@ return {
1011
local notifpath = os.getenv("HOME").."/Pictures/wallpapers/public-wallpapers/portrait/"
1112
local sel_portrait = fhelpers.first_line(os.getenv("HOME")..'/.portrait') or 'joy'
1213
local _, imgsources = fishlive.helpers.getImgsFromDir(notifpath, sel_portrait)
13-
local xres = fishlive.helpers.screen_res_x()
14+
local s = awful.screen.focused()
15+
local xres = s.geometry.width
1416

15-
imgbox = collage.placeCollageImage(xres/5.48, xres/5.48,
17+
imgbox = collage.placeCollageImage(s, xres/5.48, xres/5.48,
1618
xres-(3840/xres)^2 * 20, xres/3840 * 60, "top-right", imgsources, 1, true)
1719
else
1820
imgbox.shadow.visible = true

fishlive/widget/dashboard/init.lua

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ local function dashboard()
4747
local terminal = require("fishlive.widget.dashboard.terminal")
4848
local collage = require("fishlive.widget.dashboard.collage")
4949

50+
local s = awful.screen.focused()
51+
local geom = s.geometry
52+
5053
local dashboard = wibox({
5154
visible = false,
5255
ontop = true,
5356
type = "dock",
54-
screen = screen.focused,
55-
x = 0,
56-
y = beautiful.bar_height,
57-
width = awful.screen.focused().geometry.width,
58-
height = awful.screen.focused().geometry.height - beautiful.bar_height,
57+
screen = s,
58+
x = geom.x,
59+
y = geom.y + beautiful.bar_height,
60+
width = geom.width,
61+
height = geom.height - beautiful.bar_height,
5962
bg = beautiful.base01 .. "cf"
6063
})
6164

0 commit comments

Comments
 (0)