diff options
| author | pablu <me@pablu.de> | 2026-08-06 20:49:18 +0200 |
|---|---|---|
| committer | pablu <me@pablu.de> | 2026-08-06 20:49:18 +0200 |
| commit | 0716da5eef605977b804f34f265979cf39be844b (patch) | |
| tree | fa58e49aacfca5a78034b2af63022e5b8bf00447 /dot_config/hypr | |
| parent | b2ea1bd4568c0d1d9b700709ae5d7227de92f78a (diff) | |
update configs
Diffstat (limited to 'dot_config/hypr')
| -rw-r--r-- | dot_config/hypr/config/binds.lua | 86 | ||||
| -rw-r--r-- | dot_config/hypr/executable_games.py | 56 |
2 files changed, 68 insertions, 74 deletions
diff --git a/dot_config/hypr/config/binds.lua b/dot_config/hypr/config/binds.lua index 06b64f7..a5a9e6b 100644 --- a/dot_config/hypr/config/binds.lua +++ b/dot_config/hypr/config/binds.lua @@ -14,35 +14,85 @@ hl.bind(mainMod .. " + S", hl.dsp.exec_cmd("grim -o" .. MAIN_DISPLAY .. " \"${HOME}/screenshots/screenshot-$(date +%F-%T).png\"")) hl.bind(mainMod .. " + SHIFT + S", hl.dsp.exec_cmd("grim -g \"$(slurp)\" - | wl-copy")) +local function focus_hyprland(direction) + hl.dispatch(hl.dsp.focus({ direction = direction })) +end + +local function is_direct_nvim(title) + title = (title or ""):lower() + + return title:find("^nvim") + or title:find(" - nvim", 1, true) + or title:find("^vim") + or title:find(" - vim", 1, true) +end + +local function ask_direct_nvim(win, direction) + local runtime_dir = os.getenv("XDG_RUNTIME_DIR") or "/tmp" + + local socket_path = string.format( + "%s/nvim-hypr-nav-%x.sock", + runtime_dir, + tostring(win.stable_id) + ) + + local handle = io.popen(string.format( + "printf 'nav:%s\\n' | socat -T 0.25 -,ignoreeof UNIX-CONNECT:%s 2>/dev/null", + direction, + socket_path + )) + + if not handle then + return false + end + + local response = handle:read("*a") + handle:close() + + return response:find("success", 1, true) ~= nil +end + local function smart_nav(direction) return function() local win = hl.get_active_window() - if not win - or win.class ~= "com.mitchellh.ghostty" - or not ( - (win.title or ""):lower():find("^nvim") - or (win.title or ""):lower():find(" - nvim") - or (win.title or ""):lower():find("^vim") - or (win.title or ""):lower():find(" - vim")) - then - hl.dispatch(hl.dsp.focus({ direction = direction })) + if not win then + return + end + + if win.class ~= "com.mitchellh.ghostty" then + focus_hyprland(direction) return end - local runtime_dir = os.getenv("XDG_RUNTIME_DIR") or "/tmp" - local socket_path = string.format("%s/nvim-hypr-nav-%x.sock", runtime_dir, tostring(win.stable_id)) + local title = (win.title or ""):lower() + + if title == "herdr" then + local helper = (os.getenv("HOME") or "") + .. "/.config/hypr/scripts/herdr-smart-nav" + + local handle = io.popen(helper .. " " .. direction) - local handle = io.popen( - string.format("echo nav:%s | socat - UNIX-CONNECT:%s", - direction, socket_path)) + if not handle then + focus_hyprland(direction) + return + end - local response = handle:read("*a") - handle:close() + local result = handle:read("*a") + handle:close() - if response:find("failed") then - hl.dispatch(hl.dsp.focus({ direction = direction })) + if result:find("hyprland", 1, true) then + focus_hyprland(direction) + end + + return + end + + if is_direct_nvim(title) and ask_direct_nvim(win, direction) then + return end + + focus_hyprland(direction) end end diff --git a/dot_config/hypr/executable_games.py b/dot_config/hypr/executable_games.py deleted file mode 100644 index 3d59232..0000000 --- a/dot_config/hypr/executable_games.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python3 - -games = [ - ("all", "Stardew Valley"), - ("ic", "steam_app_.*", "tile", "max"), - ("all", "ffxiv*", "sf"), - ("all", "Hollow Knight"), - ("all", "HELLDIVERS*"), - ("all", "CS", "tile", "max"), - ("title", "Warhammer 40.000: Darktide", "tile", "max") -] - -def main(): - f = open("config/games.conf", "w") - conf: str = "# Auto generated window rules for Games\n\n" - for game in games: - if type(game) is not tuple: - continue - - name = game[1] - match game[0]: - case "ic": - selector = f"match:initial_class \"{name}\"" - case "title": - selector = f"match:title \"{name}\"" - case "class": - selector = f"match:class \"{name}\"" - case "all": - selector = f"match:title \"{name}\", match:class \"{name}\"" - case s: - print(f"Could not find selector for \"{s}\"") - continue - - for setting in game[2::]: - match setting: - case "sf": - conf += f"windowrule = stay_focused on, {selector}\n" - case "tile": - conf += f"windowrule = tile on, {selector}\n" - case "max": - conf += f"windowrule = maximize on, {selector}\n" - case s: - print(f"Could not find setting \"{s}\"") - - - conf += f"""windowrule = fullscreen on, {selector} -windowrule = monitor DP-3, {selector} -windowrule = allows_input on, {selector}\n -""" - f.write(conf) - f.close() - - -if __name__ == "__main__": - main() - |
