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
This commit is contained in:
2026-07-30 17:51:55 -04:00
parent 38b77f94a3
commit 039d15a5e6
18 changed files with 38 additions and 29 deletions
+17 -14
View File
@@ -274,21 +274,24 @@ function toggle_master()
hl.dispatch(hl.dsp.layout("mfact exact " .. mfact)) hl.dispatch(hl.dsp.layout("mfact exact " .. mfact))
end end
hl.bind(LEADER .. "return", function() -- hl.bind(LEADER .. "return", function()
focus_or_launch({ -- focus_or_launch({
match = "tmux", -- match = "terminal-tmux",
field = "class", -- field = "class",
cmd = "gtk-launch tmux.desktop", -- cmd = "gtk-launch tmux.desktop",
}) -- })
end, { description = "Open tmux terminal" }) -- end, { description = "Open tmux terminal" })
hl.bind(LEADER .. "SHIFT + return", function() -- hl.bind(LEADER .. "SHIFT + return", function()
focus_or_launch({ -- focus_or_launch({
match = "herdr", -- match = "terminal-herdr",
field = "class", -- field = "class",
cmd = "gtk-launch herdr.desktop", -- cmd = "gtk-launch herdr.desktop",
}) -- })
end, { description = "Open herdr terminal" }) -- 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 .. "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 .. "T", hl.dsp.exec_raw(terminal .. " -e btop"), { description = "Open system monitor" })
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=alcazar herdr Name=alcazar herdr
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=alcazar tmux Name=alcazar tmux
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=bianca Herdr Name=bianca Herdr
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=bianca tmux Name=bianca tmux
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=dupont herdr Name=dupont herdr
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=dupont tmux Name=dupont tmux
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=Terminal herdr Name=Terminal herdr
Comment=Terminal with herdr mux 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=nca-ai-01 herdr Name=nca-ai-01 herdr
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=nca-ai-01 tmux Name=nca-ai-01 tmux
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=obelix herdr Name=obelix herdr
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=obelix tmux Name=obelix tmux
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=steve dev herdr Name=steve dev herdr
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=steve dev tmux Name=steve dev tmux
Comment=remote dev 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1 -1
View File
@@ -1,6 +1,6 @@
[Desktop Entry] [Desktop Entry]
Type=Application Type=Application
Exec=foot -T terminal Exec=terminal-launcher terminal-fish "/usr/bin/fish"
Icon=foot Icon=foot
Terminal=false Terminal=false
Categories=System;TerminalEmulator; Categories=System;TerminalEmulator;
+1 -1
View File
@@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=Terminal tmux Name=Terminal tmux
Comment=Terminal with 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 Terminal=false
Type=Application Type=Application
Icon=foot Icon=foot
+1
View File
@@ -85,6 +85,7 @@ dotfiles.default_mode = "symlink-each"
"~/.local/bin/hyprland-keybindings" = { source = "script/hyprland-keybindings", mode = "symlink" } "~/.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-fetch-client" = { source = "script/hyprland-fetch-client", mode = "symlink" }
"~/.local/bin/hyprland-focus-client" = { source = "script/hyprland-focus-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" } "~/.local/bin/battery" = { source = "script/battery", mode = "symlink" }
# "~/.config/bin/ec" = { source = "script/ec", mode = "symlink" } # "~/.config/bin/ec" = { source = "script/ec", mode = "symlink" }
+5
View File
@@ -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'})"