mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 14:12:41 +00:00
feat: Adds generic launch-or-focus script for apps that aren't webapps
This commit is contained in:
28
env/.local/scripts/launch-or-focus
vendored
Executable file
28
env/.local/scripts/launch-or-focus
vendored
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user