refactor(hypr): namespace config under sjb/
Move the Hyprland Lua modules into config/hypr/sjb/ with init.lua as the entry point, so the whole config tree can be symlinked per-file and the unmanaged hypr*.conf files keep their own symlinks. Add an sjb block that requires the new entry point. While here: bind the second Lenovo L15, force 3440x1440@144 on the MAG342CQR, use the named 2fg scroll method, and drop dead locals. Switch the skills mise task to clone/pull SjB/skills into ~/.local/share/skills and symlink it, replacing the npx skills adds.
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
function sysinfo()
|
||||
local mem = io.popen("free -h | awk '/^Mem/ {print $3 \"/\" $2}'"):read("*a")
|
||||
local cpu = io.popen("top -bn1 | grep 'Cpu(s)' | awk '{print $2 + $4 \"%\"}'"):read("*a")
|
||||
local battery = io.popen("acpi -b | awk -F', ' '{print $2}'"):read("*a")
|
||||
local time = os.date("%Y-%m-%d %H:%M:%S")
|
||||
local monitor = hl.get_active_monitor()
|
||||
local workspace_id = monitor.active_workspace.id
|
||||
local mesg = "System Info"
|
||||
.. "\nDate: " .. time
|
||||
.. "\nFocused monitor: " .. monitor.name
|
||||
.. "\nWorkspace: " .. workspace_id
|
||||
.. "\nBattery: " .. battery
|
||||
.. "CPU: " .. cpu .. " MEM: " .. mem
|
||||
|
||||
hl.notification.create({ text = mesg, icon = "hint", duration = 5000 })
|
||||
end
|
||||
|
||||
function toggle_pin()
|
||||
local win = hl.get_active_window()
|
||||
if win == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local is_pinned = win.pinned
|
||||
hl.dispatch(hl.dsp.window.pin({ action = is_pinned and "unset" or "set" }))
|
||||
end
|
||||
|
||||
function dispatch_focus_or_launch(opts)
|
||||
return function()
|
||||
focus_or_launch(opts)
|
||||
end
|
||||
end
|
||||
|
||||
function focus_or_launch(opts)
|
||||
local match = opts.match
|
||||
local cmd = opts.cmd
|
||||
local field = opts.field or "class" -- class, title, initialClass, initialTitle
|
||||
local use_workspace = opts.use_workspace ~= false
|
||||
|
||||
local clients = hl.get_windows()
|
||||
|
||||
for _, client in ipairs(clients) do
|
||||
local value = client[field]
|
||||
if value and string.find(string.lower(value), string.lower(match), 1, true) then
|
||||
if use_workspace and client.workspace and client.workspace.id then
|
||||
hl.dispatch(hl.dsp.focus({
|
||||
workspace = client.workspace.id,
|
||||
on_current_monitor = true,
|
||||
}))
|
||||
end
|
||||
hl.dispatch(hl.dsp.focus({
|
||||
window = "address:" .. client.address
|
||||
}))
|
||||
|
||||
local layout = client.layout
|
||||
if not (layout and layout.name == "master" and layout.is_master) then
|
||||
hl.dispatch(hl.dsp.layout("swapwithmaster"))
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
hl.exec_cmd(cmd)
|
||||
end
|
||||
|
||||
function fetch_or_launch(opts)
|
||||
local match = opts.match
|
||||
local cmd = opts.cmd
|
||||
local field = opts.field or "class" -- class, title, initialClass, initialTitle
|
||||
local use_workspace = opts.use_workspace ~= false
|
||||
|
||||
local clients = hl.get_windows()
|
||||
|
||||
local active_workspace = hl.get_active_workspace()
|
||||
|
||||
for _, client in ipairs(clients) do
|
||||
local value = client[field]
|
||||
if value and string.find(string.lower(value), string.lower(match), 1, true) then
|
||||
if use_workspace and client.workspace and client.workspace.id then
|
||||
hl.dispatch(hl.dsp.window.move({
|
||||
workspace = active_workspace,
|
||||
on_current_monitor = true,
|
||||
window = client,
|
||||
}))
|
||||
end
|
||||
|
||||
hl.dispatch(hl.dsp.focus({ window = client }))
|
||||
|
||||
local layout = client.layout
|
||||
if not (layout and layout.name == "master" and layout.is_master) then
|
||||
hl.dispatch(hl.dsp.layout("swapwithmaster"))
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
hl.exec_cmd(cmd)
|
||||
end
|
||||
|
||||
function toggle_master()
|
||||
local ws = hl.get_active_workspace()
|
||||
if not ws then
|
||||
return
|
||||
end
|
||||
|
||||
local mfact = nil
|
||||
|
||||
for _, win in ipairs(ws:get_windows()) do
|
||||
local layout = win.layout
|
||||
if layout and layout.name == "master" and layout.is_master then
|
||||
mfact = math.floor(layout.perc_master * 100 + 0.5) / 100
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if mfact == 0.7 then
|
||||
mfact = 0.5
|
||||
else
|
||||
mfact = 0.7
|
||||
end
|
||||
hl.dispatch(hl.dsp.layout("mfact exact " .. mfact))
|
||||
end
|
||||
|
||||
function toggle_float_with_limit()
|
||||
local win = hl.get_active_window()
|
||||
if win == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local was_floating = win.floating
|
||||
hl.dispatch(hl.dsp.window.float({ action = "toggle" }))
|
||||
if was_floating then
|
||||
return
|
||||
end
|
||||
|
||||
local mon = win.monitor and hl.get_monitor(win.monitor) or hl.get_active_monitor()
|
||||
if mon == nil or mon.size == nil or win == nil or win.size == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local max_width = math.floor(mon.width * 0.8)
|
||||
local max_height = math.floor(mon.height * 0.8)
|
||||
local scale = math.max(1, win.size.x / max_width, win.size.y / max_height)
|
||||
hl.notification.create({
|
||||
text = "Scale " ..
|
||||
scale .. " Max float size: " .. win.size.x / max_width .. "x" .. win.size.y / max_height,
|
||||
duration = 2000,
|
||||
icon =
|
||||
"hint"
|
||||
})
|
||||
if scale > 1 then
|
||||
hl.dispatch(hl.dsp.window.resize({
|
||||
x = math.floor(max_width),
|
||||
y = math.floor(max_height),
|
||||
relative = false,
|
||||
window = win
|
||||
}))
|
||||
end
|
||||
end
|
||||
|
||||
function cycle_next_window(opts)
|
||||
return function()
|
||||
hl.dispatch(hl.dsp.window.cycle_next(opts))
|
||||
|
||||
local win = hl.get_active_window()
|
||||
if win and win.floating then
|
||||
hl.dispatch(hl.dsp.window.alter_zorder({ window = win, mode = "top" }))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function window_resize_percentage(px, py)
|
||||
local win = hl.get_active_window()
|
||||
if win == nil or win.monitor == nil then
|
||||
return
|
||||
end
|
||||
local mon = hl.get_monitor(win.monitor)
|
||||
|
||||
if mon == nil or mon.size == nil or mon.size.height == nil or mon.size.width == nil then
|
||||
return
|
||||
end
|
||||
local sx = math.floor(mon.size.width * px)
|
||||
local sy = math.floor(mon.size.height * py)
|
||||
if not win.floating then
|
||||
hl.dispatch(hl.dsp.window.float({ action = "set" }))
|
||||
end
|
||||
if win.fullscreen then
|
||||
hl.dispatch(hl.dsp.window.fullscreen({ action = "unset" }))
|
||||
end
|
||||
hl.dispatch(hl.dsp.window.resize({ x = sx, y = sy, relative = false }))
|
||||
end
|
||||
|
||||
function toggle_master_scrolling()
|
||||
local current = hl.get_config("general.layout")
|
||||
local next_layout = current == "master" and "scrolling" or "master"
|
||||
|
||||
hl.config({ general = { layout = next_layout } })
|
||||
end
|
||||
Reference in New Issue
Block a user