diff --git a/env/.config/hypr/keybinds.conf b/env/.config/hypr/keybinds.conf index 7049e30..1a961cb 100644 --- a/env/.config/hypr/keybinds.conf +++ b/env/.config/hypr/keybinds.conf @@ -42,7 +42,7 @@ bindd = $mainMod, C, [C]onfig folder in tmux session, exec, $termi bindd = $mainMod, D, [D]ispatch app - special workspace, exec, $pwa --special dispatch $housecallPro bindd = $mainMod SHIFT, D, [D]ispatch app - new window, exec, $pwa $housecallPro bindd = $mainMod, E, [E]mail - personal, exec, $pwa --focus "https://mail.proton.me" -bindd = $mainMod SHIFT, E, [E]mail - work, exec, uwsm app -- thunderbird +bindd = $mainMod SHIFT, E, [E]mail - work, exec, $scripts/launch-or-focus thunderbird uwsm app -- thunderbird bindd = $mainMod, F, [F]ile manager - terminal, exec, $fileManager bindd = $mainMod SHIFT, F, [F]ile manager - application, exec, $fileBrowser bindd = $mainMod, G, [G]itea, exec, $pwa "https://git.housh.dev" diff --git a/env/.local/scripts/launch-or-focus b/env/.local/scripts/launch-or-focus new file mode 100755 index 0000000..8e3921d --- /dev/null +++ b/env/.local/scripts/launch-or-focus @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Launch or focus a window based on a pattern contained within the +# window class name. + +pattern=$1 +launchCmd=${@:2} + +if [[ -z $pattern ]]; then + echo "Error: Must supply a pattern to match the window class." + exit 1 +fi + +if [[ -z $launchCmd ]]; then + echo "Error: Must supply a launch command to match the window class." + exit 1 +fi + +address=$(hyprctl clients -j | jq -r ".[] | select(.class | contains(\"$pattern\")) | .address") + +echo "Pattern: $pattern" +echo "Address: $address" + +if [[ -n $address ]]; then + hyprctl dispatch focuswindow "address:$address" +else + eval exec $launchCmd +fi