-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add multi-profile support to web app installer #1266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a36f914
Add multi-profile supprot to web app installer
mulsori 9956e26
Friendly names for profiles
mulsori 27d8c8e
More browsers support and different logo for webapp installer
mulsori 4771c05
Clean up
mulsori 12e33f6
.desktop names as they were
mulsori e0d23d7
Webapp installer logo
mulsori dd564c8
Resolving conflicts
mulsori 8daad16
Helium browser profiles support
mulsori 07670e1
Add Opera support
mulsori 50ee275
Merge branch 'master' into multiple-browser-profiles
mulsori 0fc03ee
Merge branch 'master' into multiple-browser-profiles
mulsori File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,65 @@ | ||
| #!/bin/bash | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Launch or focus on a given command identified by the passed in window-pattern. | ||
| # Use by some default bindings, like the one for Spotify, to ensure there is only one instance of the application open. | ||
| find_window_address() { | ||
| local pattern="$1" | ||
| hyprctl clients -j \ | ||
| | jq -r --arg p "$pattern" '.[] | select((.class+" "+.title) | test($p;"i")) | .address' \ | ||
| | head -n1 | ||
| } | ||
|
|
||
| regex_escape() { | ||
| sed -e 's/[.[\*^$()+?{}|\\]/\\&/g' <<<"$1" | ||
| } | ||
|
|
||
| if (($# == 0)); then | ||
| echo "Usage: omarchy-launch-or-focus [window-pattern] [launch-command]" | ||
| echo "Usage:" | ||
| echo " omarchy-launch-or-focus <window-pattern> [launch-command]" | ||
| echo " omarchy-launch-or-focus <url> [profile] [extra browser flags...]" | ||
| 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|test("\\b" + $p + "\\b";"i")) or (.title|test("\\b" + $p + "\\b";"i")))|.address' | head -n1) | ||
| arg1="$1" | ||
|
|
||
| if [[ "$arg1" =~ ^https?:// ]]; then | ||
| APP_URL="$1" | ||
| PROFILE="${2-}" | ||
| shift || true | ||
| if [[ -n "${PROFILE:-}" ]]; then shift || true; fi | ||
| EXTRA_FLAGS=("$@") | ||
|
|
||
| host="${APP_URL#*://}"; host="${host%%/*}" | ||
| host_esc="$(regex_escape "$host")" | ||
|
|
||
| if [[ -n "${PROFILE:-}" ]]; then | ||
| prof_as_is="$(regex_escape "$PROFILE")" | ||
| prof_uscore="$(regex_escape "${PROFILE// /_}")" | ||
| WINDOW_PATTERN="(^| )(chrome|chromium|brave|vivaldi|microsoft-edge|google-chrome)-${host_esc}(__[^ ]*-)(${prof_as_is}|${prof_uscore})( |$)" | ||
| else | ||
| WINDOW_PATTERN="(^| )(chrome|chromium|brave|vivaldi|microsoft-edge|google-chrome)-${host_esc}(__[^ ]*)?( |$)" | ||
| fi | ||
|
|
||
| [[ "${DEBUG:-0}" = "1" ]] && echo "Pattern: $WINDOW_PATTERN" >&2 | ||
|
|
||
| if WINDOW_ADDRESS="$(find_window_address "$WINDOW_PATTERN")" && [[ -n "$WINDOW_ADDRESS" ]]; then | ||
| hyprctl dispatch focuswindow "address:$WINDOW_ADDRESS" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ -n "${PROFILE:-}" ]]; then | ||
| exec omarchy-launch-webapp "$APP_URL" "$PROFILE" "${EXTRA_FLAGS[@]}" | ||
| else | ||
| exec omarchy-launch-webapp "$APP_URL" "${EXTRA_FLAGS[@]}" | ||
| fi | ||
|
|
||
| if [[ -n $WINDOW_ADDRESS ]]; then | ||
| hyprctl dispatch focuswindow "address:$WINDOW_ADDRESS" | ||
| else | ||
| eval exec setsid $LAUNCH_COMMAND | ||
| fi | ||
| WINDOW_PATTERN="$arg1" | ||
|
|
||
| LAUNCH_COMMAND="${2:-"uwsm-app --app-id=org.omarchy.terminal -- $WINDOW_PATTERN"}" | ||
|
|
||
| if WINDOW_ADDRESS="$(find_window_address "$WINDOW_PATTERN")" && [[ -n "$WINDOW_ADDRESS" ]]; then | ||
| hyprctl dispatch focuswindow "address:$WINDOW_ADDRESS" | ||
| else | ||
| eval exec "$LAUNCH_COMMAND" | ||
| fi | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,18 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Launch the passed in URL as a web app in the default browser (or chromium if the default doesn't support --app). | ||
|
|
||
| browser=$(xdg-settings get default-web-browser) | ||
|
|
||
| case $browser in | ||
| google-chrome* | brave-browser* | microsoft-edge* | opera* | vivaldi* | helium*) ;; | ||
| *) browser="chromium.desktop" ;; | ||
| google-chrome* | brave-browser* | microsoft-edge* | opera* | vivaldi* | helium-browser*) ;; | ||
| *) browser="chromium.desktop" ;; | ||
| esac | ||
|
|
||
| exec setsid uwsm-app -- $(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,~/.nix-profile,/usr}/share/applications/$browser 2>/dev/null | head -1) --app="$1" "${@:2}" | ||
| DEFAULT_BROWSER_BIN="$(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,~/.nix-profile,/usr}/share/applications/$browser 2>/dev/null | head -1)" | ||
|
|
||
| APP_URL="$1" | ||
| PROFILE="${2:-Default}" | ||
| BROWSER_BIN="${3:-$DEFAULT_BROWSER_BIN}" | ||
|
|
||
| shift 3 || true | ||
|
|
||
| exec setsid uwsm app -- "$BROWSER_BIN" --profile-directory="$PROFILE" --app="$APP_URL" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/bash | ||
|
|
||
| clear | ||
| echo -e '\033[32m' | ||
| cat ~/.local/share/omarchy/webapp-logo.txt | ||
| echo -e '\033[0m' | ||
| echo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ▄████████ ▄█ █▄ ▄████████ ▄██████▄ ▄▄▄▄███▄▄▄▄ ▄█ ███ █▄ ▄▄▄▄███▄▄▄▄ | ||
| ███ ███ ███ ███ ███ ███ ███ ███ ▄██▀▀▀███▀▀▀██▄ ███ ███ ███ ▄██▀▀▀███▀▀▀██▄ | ||
| ███ █▀ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███▌ ███ ███ ███ ███ ███ | ||
| ███ ▄███▄▄▄▄███▄▄ ▄███▄▄▄▄██▀ ███ ███ ███ ███ ███ ███▌ ███ ███ ███ ███ ███ | ||
| ███ ▀▀███▀▀▀▀███▀ ▀▀███▀▀▀▀▀ ███ ███ ███ ███ ███ ███▌ ███ ███ ███ ███ ███ | ||
| ███ █▄ ███ ███ ▀███████████ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ | ||
| ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ | ||
| ████████▀ ███ █▀ ███ ███ ▀██████▀ ▀█ ███ █▀ █▀ ████████▀ ▀█ ███ █▀ | ||
| ███ ███ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct profile names.