fix: removing dependency on copilot too expensive

This commit is contained in:
2026-06-06 17:09:17 -04:00
parent 6914bfed15
commit 70d2eb2e65
6 changed files with 206 additions and 179 deletions
+55 -40
View File
@@ -193,36 +193,40 @@ function sysinfo()
hl.notification.create({ text = mesg, icon = "hint", duration = 5000 })
end
function focus_or_launch(opts)
function dispatch_focus_or_launch(opts)
return function()
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
}))
return
end
end
hl.exec_cmd(cmd)
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
}))
return
end
end
hl.exec_cmd(cmd)
end
function toggle_master()
local ws = hl.get_active_workspace()
if not ws then
@@ -247,14 +251,25 @@ function toggle_master()
hl.dispatch(hl.dsp.layout("mfact exact " .. mfact))
end
hl.bind(LEADER .. "return",
hl.bind(LEADER .. "return", function()
focus_or_launch({
match = terminal,
field = "class",
cmd = terminal .. " tmux new -A -s main"
}), { description = "Open terminal" })
})
end, { description = "Open terminal" })
--hl.bind(LEADER .. "SHIFT + return", hl.dsp.exec_raw(terminal .. "tmux attach-session -t $(tmux list-windows -a -F '#S:#I' | rofi -dmenu -P Session)"))
hl.bind(LEADER .. "SHIFT + return", function()
local session = io.popen("tmux list-sessions -F '#S:#I' | rofi -dmenu -P Session"):read("*a")
hl.notification.create({ text = "Attaching to tmux session: " .. session, icon = "hint", duration = 2000 })
focus_or_launch({
match = "session",
field = "title",
cmd = terminal .. " -e tmux attach-session -t " .. session
})
end, { description = "Attach to tmux session" })
hl.bind(LEADER .. "SHIFT + return", hl.dsp.exec_raw(terminal .. " nvim"))
hl.bind(LEADER .. "B", hl.dsp.exec_raw(browser), { description = "Open browser" })
hl.bind(LEADER .. "T", hl.dsp.exec_raw(terminal .. " -e btop"), { description = "Open system monitor" })
hl.bind(LEADER .. "S", hl.dsp.exec_raw("rofi -show recursivebrowser"), { description = "Open finder" })
@@ -278,58 +293,58 @@ hl.bind(HYPR .. "B", hl.dsp.exec_cmd("blueberry"), { description = "Bluetooth ma
hl.bind(HYPR .. "semicolon", hl.dsp.exec_cmd("~/.local/bin/bing-wallpaper"), { description = "get new wallpaper" })
hl.bind(HYPR .. "A", focus_or_launch({
hl.bind(HYPR .. "A", dispatch_focus_or_launch({
match = "Goose",
field = "class",
cmd = "gtk-launch goose-desktop.desktop"
}), { description = "Goose Desktop" })
hl.bind(HYPR .. "C", focus_or_launch({
hl.bind(HYPR .. "C", dispatch_focus_or_launch({
match = "chrome-chatgpt.com",
cmd = "gtk-launch ChatGPT.desktop",
}), { description = "ChatGPT" })
hl.bind(HYPR .. "O", focus_or_launch({
hl.bind(HYPR .. "O", dispatch_focus_or_launch({
match = "chrome-outlook.office.com",
cmd = "gtk-launch Outlook.desktop",
}), { description = "Email" })
hl.bind(HYPR .. "T", focus_or_launch({
hl.bind(HYPR .. "T", dispatch_focus_or_launch({
match = "chrome-teams.microsoft.com",
cmd = "gtk-launch Team.desktop",
}), { description = "UWO Team" })
hl.bind(HYPR .. "Y", focus_or_launch({
hl.bind(HYPR .. "Y", dispatch_focus_or_launch({
match = "chrome-youtube.com",
cmd = "gtk-launch YouTube.desktop",
}), { description = "YouTube" })
hl.bind(HYPR .. "W", focus_or_launch({
hl.bind(HYPR .. "W", dispatch_focus_or_launch({
match = "chrome-web.whatsapp.com",
cmd = "gtk-launch WhatsApp.desktop",
}), { description = "WhatsApp" })
hl.bind(HYPR .. "G", focus_or_launch({
hl.bind(HYPR .. "G", dispatch_focus_or_launch({
match = "chrome-www.gmail.com",
cmd = webapp .. "https://www.gmail.com/",
}), { description = "Google" })
hl.bind(HYPR .. "D", focus_or_launch({
hl.bind(HYPR .. "D", dispatch_focus_or_launch({
match = "chrome-discord.com",
cmd = "gtk-launch Discord.desktop"
}), { description = "Discord" })
hl.bind(HYPR .. "M", focus_or_launch({
hl.bind(HYPR .. "M", dispatch_focus_or_launch({
match = "chrome-messages.google.com",
cmd = "gtk-launch \"Google Messages.desktop\"",
}), { description = "Google Messages" })
hl.bind(HYPR .. "S", focus_or_launch({
hl.bind(HYPR .. "S", dispatch_focus_or_launch({
match = "Spotify",
cmd = music,
}), { description = "Music" })
hl.bind(HYPR .. "F", focus_or_launch({
hl.bind(HYPR .. "F", dispatch_focus_or_launch({
match = "pcmanfm",
cmd = "pcmanfm",
}), { description = "File Manager" })