From 039d15a5e6473a884b23b832fa89be76d1f4b698 Mon Sep 17 00:00:00 2001 From: Steve Beaulac Date: Thu, 30 Jul 2026 17:51:55 -0400 Subject: [PATCH] refactor: extract terminal launch logic into shared script Add terminal-launcher script as a single entry point for launching foot-based terminals with a given class and command. Migrate all .desktop files to use it instead of inline foot invocations. Simplify hyprland keybindings by replacing inline focus_or_launch with hl.dsp.exec_cmd --- config/hypr/hyprland.lua | 31 +++++++++++++++++-------------- desktop/alcazar-herdr.desktop | 2 +- desktop/alcazar-tmux.desktop | 2 +- desktop/bianca-herdr.desktop | 2 +- desktop/bianca-tmux.desktop | 2 +- desktop/dupont-herdr.desktop | 2 +- desktop/dupont-tmux.desktop | 2 +- desktop/herdr.desktop | 2 +- desktop/nca-ai-01-herdr.desktop | 2 +- desktop/nca-ai-01-tmux.desktop | 2 +- desktop/obelix-herdr.desktop | 2 +- desktop/obelix-tmux.desktop | 2 +- desktop/steve-dev-herdr.desktop | 2 +- desktop/steve-dev-tmux.desktop | 2 +- desktop/terminal.desktop | 2 +- desktop/tmux.desktop | 2 +- mise.toml | 1 + script/terminal-launcher | 5 +++++ 18 files changed, 38 insertions(+), 29 deletions(-) create mode 100755 script/terminal-launcher diff --git a/config/hypr/hyprland.lua b/config/hypr/hyprland.lua index 6fed598..659042b 100644 --- a/config/hypr/hyprland.lua +++ b/config/hypr/hyprland.lua @@ -274,21 +274,24 @@ function toggle_master() hl.dispatch(hl.dsp.layout("mfact exact " .. mfact)) end -hl.bind(LEADER .. "return", function() - focus_or_launch({ - match = "tmux", - field = "class", - cmd = "gtk-launch tmux.desktop", - }) -end, { description = "Open tmux terminal" }) +-- hl.bind(LEADER .. "return", function() +-- focus_or_launch({ +-- match = "terminal-tmux", +-- field = "class", +-- cmd = "gtk-launch tmux.desktop", +-- }) +-- end, { description = "Open tmux terminal" }) -hl.bind(LEADER .. "SHIFT + return", function() - focus_or_launch({ - match = "herdr", - field = "class", - cmd = "gtk-launch herdr.desktop", - }) -end, { description = "Open herdr terminal" }) +-- hl.bind(LEADER .. "SHIFT + return", function() +-- focus_or_launch({ +-- match = "terminal-herdr", +-- field = "class", +-- cmd = "gtk-launch herdr.desktop", +-- }) +-- end, { description = "Open herdr terminal" }) + +hl.bind(LEADER .. "SHIFT + return", hl.dsp.exec_cmd("gtk-launch herdr.desktop"), { description = "Open herdr terminal" }) +hl.bind(LEADER .. "return", hl.dsp.exec_cmd("gtk-launch tmux.desktop"), { description = "Open tmux terminal" }) 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" }) diff --git a/desktop/alcazar-herdr.desktop b/desktop/alcazar-herdr.desktop index 5544597..c29beed 100644 --- a/desktop/alcazar-herdr.desktop +++ b/desktop/alcazar-herdr.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=alcazar herdr Comment=remote dev -Exec=foot -a alcazar-herdr -T "alcazar herdr" ssh alcazar mise exec -- herdr --session main +Exec=terminal-launcher alcazar-herdr "ssh alcazar mise exec -- herdr --session main" Terminal=false Type=Application Icon=foot diff --git a/desktop/alcazar-tmux.desktop b/desktop/alcazar-tmux.desktop index af7ec4a..539b161 100644 --- a/desktop/alcazar-tmux.desktop +++ b/desktop/alcazar-tmux.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=alcazar tmux Comment=remote dev -Exec=foot -a alcazar-tmux -T "alcazar tmux" ssh alcazar mise exec -- tmux new -A -s main +Exec=terminal-launcher alcazar-tmux "ssh alcazar mise exec -- tmux new -A -s main" Terminal=false Type=Application Icon=foot diff --git a/desktop/bianca-herdr.desktop b/desktop/bianca-herdr.desktop index f2e83e8..9fa1ce6 100644 --- a/desktop/bianca-herdr.desktop +++ b/desktop/bianca-herdr.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=bianca Herdr Comment=remote dev -Exec=foot -a bianca-herdr -T "bianca herdr" ssh bianca mise exec -- herdr --session main +Exec=terminal-launcher bianca-herdr "ssh bianca mise exec -- herdr --session main" Terminal=false Type=Application Icon=foot diff --git a/desktop/bianca-tmux.desktop b/desktop/bianca-tmux.desktop index a3b13be..5cbcf4a 100644 --- a/desktop/bianca-tmux.desktop +++ b/desktop/bianca-tmux.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=bianca tmux Comment=remote dev -Exec=foot -a bianca-tmux -T "bianca tmux" ssh bianca mise exec -- tmux new -A -s main +Exec=terminal-launcher bianca-tmux "ssh bianca mise exec -- tmux new -A -s main" Terminal=false Type=Application Icon=foot diff --git a/desktop/dupont-herdr.desktop b/desktop/dupont-herdr.desktop index 2c71a21..1e88471 100644 --- a/desktop/dupont-herdr.desktop +++ b/desktop/dupont-herdr.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=dupont herdr Comment=remote dev -Exec=foot -a dupont-herdr -T "dupont herdr" ssh dupont mise exec -- herdr --session main +Exec=terminal-launcher dupont-herdr "ssh dupont mise exec -- herdr --session main" Terminal=false Type=Application Icon=foot diff --git a/desktop/dupont-tmux.desktop b/desktop/dupont-tmux.desktop index d7f9a01..2029107 100644 --- a/desktop/dupont-tmux.desktop +++ b/desktop/dupont-tmux.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=dupont tmux Comment=remote dev -Exec=foot -a dupont-tmux -T "dupont tmux" ssh dupont mise exec -- tmux new -A -s main +Exec=terminal-launcher dupont-tmux "ssh dupont mise exec -- tmux new -A -s main" Terminal=false Type=Application Icon=foot diff --git a/desktop/herdr.desktop b/desktop/herdr.desktop index 1353e20..fabdbae 100644 --- a/desktop/herdr.desktop +++ b/desktop/herdr.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=Terminal herdr Comment=Terminal with herdr mux -Exec=foot -a herdr -T "terminal herdr" mise exec -- herdr --session=main +Exec=terminal-launcher terminal-herdr "mise exec -- herdr --session=main" Terminal=false Type=Application Icon=foot diff --git a/desktop/nca-ai-01-herdr.desktop b/desktop/nca-ai-01-herdr.desktop index 5294c4c..94db34c 100644 --- a/desktop/nca-ai-01-herdr.desktop +++ b/desktop/nca-ai-01-herdr.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=nca-ai-01 herdr Comment=remote dev -Exec=foot -a nca-ai-01-herdr -T "nca ai 01 herdr" ssh nca-ai-01 mise exec -- herdr --session main +Exec=terminal-launcher nca-ai-01-herdr "ssh nca-ai-01 mise exec -- herdr --session main" Terminal=false Type=Application Icon=foot diff --git a/desktop/nca-ai-01-tmux.desktop b/desktop/nca-ai-01-tmux.desktop index 4b8e7dc..818b0ce 100644 --- a/desktop/nca-ai-01-tmux.desktop +++ b/desktop/nca-ai-01-tmux.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=nca-ai-01 tmux Comment=remote dev -Exec=foot -a nca-ai-01-tmux -T "nca ai 01 tmux" ssh nca-ai-01 mise exec -- tmux new -A -s main +Exec=terminal-launcher nca-ai-01-tmux "ssh nca-ai-01 mise exec -- tmux new -A -s main" Terminal=false Type=Application Icon=foot diff --git a/desktop/obelix-herdr.desktop b/desktop/obelix-herdr.desktop index 1dfc6ca..6d6e8f3 100644 --- a/desktop/obelix-herdr.desktop +++ b/desktop/obelix-herdr.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=obelix herdr Comment=remote dev -Exec=foot -a obelix-herdr -T "obelix herdr" ssh obelix mise exec -- herdr --session main +Exec=terminal-launcher obelix-herdr "ssh obelix mise exec -- herdr --session main" Terminal=false Type=Application Icon=foot diff --git a/desktop/obelix-tmux.desktop b/desktop/obelix-tmux.desktop index 337dba2..415c5ad 100644 --- a/desktop/obelix-tmux.desktop +++ b/desktop/obelix-tmux.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=obelix tmux Comment=remote dev -Exec=foot -a obelix-tmux -T "obelix tmux" ssh obelix mise exec -- tmux new -A -s main +Exec=terminal-launcher obelix-tmux "ssh obelix mise exec -- tmux new -A -s main" Terminal=false Type=Application Icon=foot diff --git a/desktop/steve-dev-herdr.desktop b/desktop/steve-dev-herdr.desktop index bd3be62..42357a8 100644 --- a/desktop/steve-dev-herdr.desktop +++ b/desktop/steve-dev-herdr.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=steve dev herdr Comment=remote dev -Exec=foot -a steve-dev-herdr -T "steve dev herdr" ssh steve-dev mise exec -- herdr --session main +Exec=terminal-launcher steve-dev-herdr "ssh steve-dev mise exec -- herdr --session main" Terminal=false Type=Application Icon=foot diff --git a/desktop/steve-dev-tmux.desktop b/desktop/steve-dev-tmux.desktop index 54ede86..b21ef5a 100644 --- a/desktop/steve-dev-tmux.desktop +++ b/desktop/steve-dev-tmux.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=steve dev tmux Comment=remote dev -Exec=foot -a steve-dev-tmux -T "steve dev tmux" ssh steve-dev mise exec -- tmux new -A -s main +Exec=terminal-launcher steve-dev-tmux "ssh steve-dev mise exec -- tmux new -A -s main" Terminal=false Type=Application Icon=foot diff --git a/desktop/terminal.desktop b/desktop/terminal.desktop index 315899d..9dfb82e 100644 --- a/desktop/terminal.desktop +++ b/desktop/terminal.desktop @@ -1,6 +1,6 @@ [Desktop Entry] Type=Application -Exec=foot -T terminal +Exec=terminal-launcher terminal-fish "/usr/bin/fish" Icon=foot Terminal=false Categories=System;TerminalEmulator; diff --git a/desktop/tmux.desktop b/desktop/tmux.desktop index 6b54aa7..71fe707 100644 --- a/desktop/tmux.desktop +++ b/desktop/tmux.desktop @@ -2,7 +2,7 @@ Version=1.0 Name=Terminal tmux Comment=Terminal with tmux -Exec=foot -a tmux -T "terminal tmux" mise exec -- tmux new -A -s main +Exec=terminal-launcher "terminal-tmux" "mise exec -- tmux new -A -s main" Terminal=false Type=Application Icon=foot diff --git a/mise.toml b/mise.toml index 9e21ebf..635e6c4 100644 --- a/mise.toml +++ b/mise.toml @@ -85,6 +85,7 @@ dotfiles.default_mode = "symlink-each" "~/.local/bin/hyprland-keybindings" = { source = "script/hyprland-keybindings", mode = "symlink" } "~/.local/bin/hyprland-fetch-client" = { source = "script/hyprland-fetch-client", mode = "symlink" } "~/.local/bin/hyprland-focus-client" = { source = "script/hyprland-focus-client", mode = "symlink" } +"~/.local/bin/terminal-launcher" = { source = "script/terminal-launcher", mode = "symlink" } "~/.local/bin/battery" = { source = "script/battery", mode = "symlink" } # "~/.config/bin/ec" = { source = "script/ec", mode = "symlink" } diff --git a/script/terminal-launcher b/script/terminal-launcher new file mode 100755 index 0000000..14291d5 --- /dev/null +++ b/script/terminal-launcher @@ -0,0 +1,5 @@ +#!/bin/sh +class=$1 +cmd=$2 +terminal="foot -a $class -T $class \"$cmd\"" +hyprctl dispatch "focus_or_launch({ match = '$class', cmd = 'foot -a $class -T $class $cmd'})"