Add focus or launch script (#925)

* Add focus or launch script

* Replace eval with exec

* Use eval so it properly expands the variables

* Apply to the apps where it makes most sense

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
v-oleg
2025-09-14 14:58:08 -05:00
committed by GitHub
parent e228a987a8
commit e4ca98301b
4 changed files with 40 additions and 6 deletions

16
bin/omarchy-launch-or-focus Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
if (($# == 0)); then
echo "Usage: omarchy-launch-or-focus [window-pattern] [launch-command]"
exit 1
fi
WINDOW_PATTERN="$1"
LAUNCH_COMMAND="${2:-"uwsm app -- $WINDOW_PATTERN"}"
WINDOW_ADDRESS=$(hyprctl clients -j | jq -r --arg p "$WINDOW_PATTERN" '.[]|select((.class+" "+.title)|test($p;"i"))|.address' | head -n1)
if [[ -n $WINDOW_ADDRESS ]]; then
hyprctl dispatch focuswindow "address:$WINDOW_ADDRESS"
else
eval exec $LAUNCH_COMMAND
fi

View File

@@ -0,0 +1,8 @@
#!/bin/bash
if (($# == 0)); then
echo "Usage: omarchy-launch-or-focus-webapp [window-pattern] [url]"
exit 1
fi
exec omarchy-launch-or-focus $1 "omarchy-launch-webapp '$2'"

View File

@@ -6,12 +6,12 @@ bindd = SUPER, return, Terminal, exec, $terminal --working-directory="$(omarchy-
bindd = SUPER, F, File manager, exec, uwsm app -- nautilus --new-window
bindd = SUPER, B, Browser, exec, $browser
bindd = SUPER SHIFT, B, Browser (private), exec, $browser --private
bindd = SUPER, M, Music, exec, uwsm app -- spotify
bindd = SUPER, M, Music, exec, omarchy-launch-or-focus spotify
bindd = SUPER, N, Neovim, exec, $terminal -e nvim
bindd = SUPER, T, Activity, exec, $terminal -e btop
bindd = SUPER, D, Docker, exec, $terminal -e lazydocker
bindd = SUPER, G, Signal, exec, uwsm app -- signal-desktop
bindd = SUPER, O, Obsidian, exec, uwsm app -- obsidian -disable-gpu --enable-wayland-ime
bindd = SUPER, G, Signal, exec, omarchy-launch-or-focus signal "uwsm app -- signal-desktop"
bindd = SUPER, O, Obsidian, exec, omarchy-launch-or-focus obsidian "uwsm app -- obsidian -disable-gpu --enable-wayland-ime"
bindd = SUPER, slash, Passwords, exec, uwsm app -- 1password
# If your web app url contains #, type it as ## to prevent hyperland treat it as comments
@@ -19,9 +19,9 @@ bindd = SUPER, A, ChatGPT, exec, omarchy-launch-webapp "https://chatgpt.com"
bindd = SUPER SHIFT, A, Grok, exec, omarchy-launch-webapp "https://grok.com"
bindd = SUPER, C, Calendar, exec, omarchy-launch-webapp "https://app.hey.com/calendar/weeks/"
bindd = SUPER, E, Email, exec, omarchy-launch-webapp "https://app.hey.com"
bindd = SUPER, Y, YouTube, exec, omarchy-launch-webapp "https://youtube.com/"
bindd = SUPER SHIFT, G, WhatsApp, exec, omarchy-launch-webapp "https://web.whatsapp.com/"
bindd = SUPER ALT, G, Google Messages, exec, omarchy-launch-webapp "https://messages.google.com/web/conversations"
bindd = SUPER, Y, YouTube, exec, omarchy-launch-or-focus-webapp YouTube "https://youtube.com/"
bindd = SUPER SHIFT, G, WhatsApp, exec, omarchy-launch-or-focus-webapp WhatsApp "https://web.whatsapp.com/"
bindd = SUPER ALT, G, Google Messages, exec, omarchy-launch-or-focus-webapp "Google Messages" "https://messages.google.com/web/conversations"
bindd = SUPER, X, X, exec, omarchy-launch-webapp "https://x.com/"
bindd = SUPER SHIFT, X, X Post, exec, omarchy-launch-webapp "https://x.com/compose/post"

10
migrations/1757877852.sh Normal file
View File

@@ -0,0 +1,10 @@
echo "Switch select bindings to launch or focus mode"
if [[ -f ~/.config/hypr/bindings.conf ]]; then
sed -i '/SUPER, M, Music, exec/ c\bindd = SUPER, M, Music, exec, omarchy-launch-or-focus spotify' ~/.config/hypr/bindings.conf
sed -i '/SUPER, O, Obsidian, exec/ c\bindd = SUPER, O, Obsidian, exec, omarchy-launch-or-focus obsidian "uwsm app -- obsidian -disable-gpu --enable-wayland-ime"' ~/.config/hypr/bindings.conf
sed -i '/SUPER, G, Signal, exec/ c\bindd = SUPER, G, Signal, exec, omarchy-launch-or-focus signal "uwsm app -- signal-desktop"' ~/.config/hypr/bindings.conf
sed -i '/SUPER SHIFT, G, WhatsApp, exec/ c\bindd = SUPER SHIFT, G, WhatsApp, exec, omarchy-launch-or-focus-webapp WhatsApp "https://web.whatsapp.com/"' ~/.config/hypr/bindings.conf
sed -i '/SUPER ALT, G, Google Messages, exec/ c\bindd = SUPER ALT, G, Google Messages, exec, omarchy-launch-or-focus-webapp "Google Messages" "https://messages.google.com/web/conversations"' ~/.config/hypr/bindings.conf
fi