fix: Fixes launch script to have a --new-instance flag to force launching a new instance of an application.

This commit is contained in:
2025-10-06 08:29:01 -04:00
parent a4a560eb3d
commit 6721b2a8c5
3 changed files with 9 additions and 3 deletions

View File

@@ -23,6 +23,7 @@ OPTIONS:
instance.
-x | --close-active-only: Close only windows on active workspace matching the pattern.
-s | --special <name>: Launch or toggle a special workspace.
-n | --new-instance: Launch a new instance of an application.
-h | --help: Show this help page.
NOTES:
@@ -46,6 +47,7 @@ close_flag="0"
close_active_only_flag="0"
focus_flag="0"
focus_active_only_flag="0"
new_instance_flag="0"
launch_cmd=()
pattern=""
special_flag="0"
@@ -71,6 +73,8 @@ while [[ $# -gt 0 ]]; do
close_flag="1"
close_active_only_flag="1"
action="closewindow"
elif [[ $1 == "-n" ]] || [[ $1 == "--new-instance" ]]; then
new_instance_flag="1"
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
usage && exit 0
elif [[ -z $pattern ]]; then
@@ -124,9 +128,11 @@ log "Pattern: $pattern"
addresses=$(hyprctl clients -j | jq ".[] | select(.class | contains(\"$pattern\")) | .address")
# If no addresses, then launch the application.
if [[ -z $addresses ]]; then
if [[ -z $addresses ]] || [[ $new_instance_flag == "1" ]]; then
log "No addresses found or new instance flag set."
# Toggle special workspace if applicable.
if [[ $special_flag == "1" ]]; then
log "Toggling special workspace."
toggle_special
fi
launch_application && exit 0