mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 14:59:27 -05:00
hl: create custom config files automatically
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
require("hyprland.lib")
|
||||
require("hyprland.variables")
|
||||
require("custom.variables")
|
||||
|
||||
@@ -6,13 +7,6 @@ local hyprScripts = "$HOME/.config/hypr/hyprland/scripts"
|
||||
local qsIpcCall = "qs -c $qsConfig ipc call"
|
||||
local qsIsAlive = qsIpcCall .. " TEST_ALIVE"
|
||||
|
||||
function WorkspaceInGroup(i)
|
||||
local curr = hl.get_active_workspace().id
|
||||
local newVal = math.floor((curr - 1) / workspaceGroupSize) * workspaceGroupSize + i
|
||||
-- hl.notification.create({ text = "curr " .. curr .. " floor " .. math.floor(curr / 10) .. " new " .. newVal, duration = 5000 })
|
||||
return newVal
|
||||
end
|
||||
|
||||
hl.bind("SUPER + SUPER_L", hl.dsp.global("quickshell:searchToggleRelease"), { description = "Shell: Toggle search" })
|
||||
hl.bind("SUPER + SUPER_R", hl.dsp.global("quickshell:searchToggleRelease"))
|
||||
hl.bind("SUPER + SUPER_L", hl.dsp.exec_cmd(qsIsAlive .. " || pkill fuzzel || fuzzel"))
|
||||
@@ -152,14 +146,14 @@ hl.bind("SUPER + P", hl.dsp.window.pin(), { description = "Window: Pin" })
|
||||
for i = 1, 10 do
|
||||
local numberkey = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }
|
||||
hl.bind("SUPER + ALT + code:" .. numberkey[i], function()
|
||||
hl.dispatch(hl.dsp.window.move({ workspace = WorkspaceInGroup(i), follow = false }))
|
||||
hl.dispatch(hl.dsp.window.move({ workspace = workspace_in_group(i), follow = false }))
|
||||
end)
|
||||
end
|
||||
--# keypad numbers
|
||||
for i = 1, 10 do
|
||||
local numpadkey = { 87, 88, 89, 83, 84, 85, 79, 80, 81, 90 }
|
||||
hl.bind("SUPER + ALT + code:" .. numpadkey[i], function()
|
||||
hl.dispatch(hl.dsp.window.move({ workspace = WorkspaceInGroup(i), follow = false }))
|
||||
hl.dispatch(hl.dsp.window.move({ workspace = workspace_in_group(i), follow = false }))
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -191,14 +185,14 @@ hl.bind("CTRL + SUPER + S", hl.dsp.workspace.toggle_special("special"))
|
||||
for i = 1, 10 do
|
||||
local numberkey = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }
|
||||
hl.bind("SUPER + code:" .. numberkey[i], function()
|
||||
hl.dispatch(hl.dsp.focus({ workspace = WorkspaceInGroup(i) }))
|
||||
hl.dispatch(hl.dsp.focus({ workspace = workspace_in_group(i) }))
|
||||
end)
|
||||
end
|
||||
--# keypad numbers
|
||||
for i = 1, 10 do
|
||||
local numpadkey = { 87, 88, 89, 83, 84, 85, 79, 80, 81, 90 }
|
||||
hl.bind("SUPER + code:" .. numpadkey[i], function()
|
||||
hl.dispatch(hl.dsp.focus({ workspace = WorkspaceInGroup(i) }))
|
||||
hl.dispatch(hl.dsp.focus({ workspace = workspace_in_group(i) }))
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
function is_file_exists(name)
|
||||
local f = io.open(name, "r")
|
||||
if f ~= nil then
|
||||
io.close(f)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function create_if_not_exists(path)
|
||||
if not is_file_exists(path) then
|
||||
os.execute("mkdir -p \"$(dirname \"" .. path .. "\")\"")
|
||||
os.execute("echo '-- This file will not be overwritten across dots-hyprland updates.\n-- The file name is for the sake of organization and does not matter\n-- See the corresponding files in ~/.config/hypr/hyprland for examples' > \"" .. path .. "\"")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function workspace_in_group(i)
|
||||
local curr = hl.get_active_workspace().id
|
||||
local newVal = math.floor((curr - 1) / workspaceGroupSize) * workspaceGroupSize + i
|
||||
-- hl.notification.create({ text = "curr " .. curr .. " floor " .. math.floor(curr / 10) .. " new " .. newVal, duration = 5000 })
|
||||
return newVal
|
||||
end
|
||||
@@ -0,0 +1,29 @@
|
||||
require("hyprland/lib")
|
||||
|
||||
hl.on("hyprland.start", function()
|
||||
local homeDir = os.getenv("HOME")
|
||||
if string.len(homeDir) == 0 then
|
||||
return
|
||||
end
|
||||
local baseCustomDir = homeDir .. "/.config/hypr/custom"
|
||||
local files = {
|
||||
baseCustomDir .. "/env.lua",
|
||||
baseCustomDir .. "/execs.lua",
|
||||
baseCustomDir .. "/general.lua",
|
||||
baseCustomDir .. "/keybinds.lua",
|
||||
baseCustomDir .. "/rules.lua",
|
||||
baseCustomDir .. "/variables.lua"
|
||||
}
|
||||
local createdFiles = 0
|
||||
for _, file in ipairs(files) do
|
||||
if not is_file_exists(file) then
|
||||
create_if_not_exists(file)
|
||||
createdFiles = createdFiles + 1
|
||||
end
|
||||
end
|
||||
|
||||
if createdFiles > 0 then
|
||||
hl.exec_cmd("notify-send 'Hyprland config' 'Created " .. createdFiles .. " custom Hyprland config files in " .. baseCustomDir .. "' -a 'Hyprland'")
|
||||
hl.exec_cmd("hyprctl reload")
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1 @@
|
||||
require("hyprland/services/create_custom_config")
|
||||
Reference in New Issue
Block a user