Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d014f9c268 | |||
| 76226cb637 |
+36
-8
@@ -247,21 +247,45 @@ function M.randomizeWallpaper()
|
||||
local home = os.getenv("HOME")
|
||||
local april_dir = home .. "/images/April"
|
||||
local sbm_dir = home .. "/images/Seven Beats Music"
|
||||
local black_png = home .. "/images/black.png"
|
||||
|
||||
-- Choose image source based on monitor count
|
||||
local img_dir = (#monitors <= 1) and april_dir or sbm_dir
|
||||
-- Determine if we are on the home WiFi ("keep")
|
||||
local is_home_wifi = false
|
||||
local f = io.popen("bash -c '/usr/bin/iwgetid -r 2>/dev/null || /usr/bin/nmcli -t -f active,ssid dev wifi 2>/dev/null | grep \"^yes\" | cut -d: -f2'")
|
||||
if f then
|
||||
local ssid = f:read("*a")
|
||||
f:close()
|
||||
if ssid and ssid:match("keep") then
|
||||
is_home_wifi = true
|
||||
end
|
||||
end
|
||||
|
||||
-- Select image source based on location
|
||||
local img_dir = nil
|
||||
if #monitors > 1 then
|
||||
img_dir = sbm_dir
|
||||
elseif is_home_wifi then
|
||||
img_dir = april_dir
|
||||
end
|
||||
|
||||
local images = {}
|
||||
local handle = io.popen('find "' .. img_dir .. '" -type f \\( -name "*.jpg" -o -name "*.png" -o -name "*.jpeg" \\) 2>/dev/null')
|
||||
if handle then
|
||||
for line in handle:lines() do
|
||||
table.insert(images, line)
|
||||
if img_dir then
|
||||
local handle = io.popen('find "' .. img_dir .. '" -type f \\( -name "*.jpg" -o -name "*.png" -o -name "*.jpeg" \\) 2>/dev/null')
|
||||
if handle then
|
||||
for line in handle:lines() do
|
||||
table.insert(images, line)
|
||||
end
|
||||
handle:close()
|
||||
end
|
||||
handle:close()
|
||||
else
|
||||
table.insert(images, black_png)
|
||||
end
|
||||
|
||||
if #images == 0 then return end
|
||||
|
||||
-- Unload old wallpapers from memory
|
||||
hl.dispatch(hl.dsp.exec_cmd("hyprctl hyprpaper unload all"))
|
||||
|
||||
-- Pick a unique random image for each monitor
|
||||
math.randomseed(os.time())
|
||||
local used = {}
|
||||
@@ -277,8 +301,12 @@ function M.randomizeWallpaper()
|
||||
end
|
||||
attempts = attempts + 1
|
||||
end
|
||||
if not img then img = images[1] end -- fallback if we run out of unique images
|
||||
|
||||
if img then
|
||||
hl.dispatch(hl.dsp.exec_cmd('hyprctl hyprpaper reload "' .. mon.name .. ',' .. img .. '"'))
|
||||
-- Standard hyprpaper IPC
|
||||
hl.dispatch(hl.dsp.exec_cmd('hyprctl hyprpaper preload "' .. img .. '"'))
|
||||
hl.dispatch(hl.dsp.exec_cmd('hyprctl hyprpaper wallpaper "' .. mon.name .. ',' .. img .. '"'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+3
-1
@@ -18,7 +18,9 @@ local function assign_workspaces()
|
||||
package.loaded["workspace_config"] = nil -- force reload in case it changed
|
||||
local ws_config = require("workspace_config")
|
||||
|
||||
for _, ws in ipairs(ws_config) do
|
||||
-- Iterate in REVERSE to assign the most negative IDs to the first items, counteracting Waybar's low-to-high sorting!
|
||||
for i = #ws_config, 1, -1 do
|
||||
local ws = ws_config[i]
|
||||
local target_mon = has_dock and ws.monitor or "eDP-1"
|
||||
hl.workspace_rule({ workspace = "name:" .. ws.name, monitor = target_mon, persistent = true, default = true })
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user