-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: master
Are you sure you want to change the base?
Add multi-profile support to web app installer #1266
Conversation
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.
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.
This feature is exactly what i'm waiting for, thanks so much for your work
I think you need to simplify the web app view for this use case. After Omarchy ASCII logo,
We're not creating a web app here. The profile already exists and is detected. You could replace the Omarchy ASCII logo with default browser icon. That'd be nice. Easy to grasp.
|
From Omarchy
#!/bin/bash
browser=$(xdg-settings get default-web-browser)
case $browser in
google-chrome* | brave-browser* | microsoft-edge* | opera* | vivaldi*) ;;
*) browser="chromium.desktop" ;;
esac
# Extract the browser binary from the .desktop file
BROWSER_BIN="$(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,~/.nix-profile,/usr}/share/applications/$browser 2>/dev/null | head -1)"
APP_URL="$1"
shift || true
# If a profile arg is provided (as $2 in the original), use it; otherwise launch without profile.
PROFILE_ARG=()
if [ -n "${1-}" ]; then
PROFILE_ARG=(--profile-directory="$1")
shift
fi
# Any remaining args after the profile name are forwarded as-is.
exec setsid uwsm app -- "$BROWSER_BIN" "${PROFILE_ARG[@]}" --app="$APP_URL" "$@"
#!/bin/bash
set -euo pipefail
# Usage:
# omarchy-launch-or-focus <window-pattern> [launch-command]
# omarchy-launch-or-focus <url> [profile] [extra browser flags...]
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:"
echo " omarchy-launch-or-focus <window-pattern> [launch-command]"
echo " omarchy-launch-or-focus <url> [profile] [extra browser flags...]"
exit 1
fi
arg1="$1"
if [[ "$arg1" =~ ^https?:// ]]; then
# ------------------ URL MODE ------------------
APP_URL="$1"
PROFILE="${2-}" # optional
shift || true
if [[ $# -gt 0 ]]; then shift; fi
EXTRA_FLAGS=("$@")
# Host (e.g., gemini.google.com, chatgpt.com)
host="${APP_URL#*://}"; host="${host%%/*}"
host_esc="$(regex_escape "$host")"
# Allow optional "__<segment>-" between host and profile, e.g. "__app-"
# Examples matched:
# chrome-gemini.google.com__app-Default
# chrome-chatgpt.com__-Default
# chrome-web.whatsapp.com__-Profile_1
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
# No profile provided: match any window of this host, regardless of the optional segment/profile
WINDOW_PATTERN="(^| )(chrome|chromium|brave|vivaldi|microsoft-edge|google-chrome)-${host_esc}(__[^ ]*)?( |$)"
fi
# Debug aid: show the pattern if DEBUG=1
[[ "${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
# No match → delegate launching (no duplication of browser logic here)
if [[ -n "${PROFILE:-}" ]]; then
exec omarchy-launch-webapp "$APP_URL" "$PROFILE" "${EXTRA_FLAGS[@]}"
else
exec omarchy-launch-webapp "$APP_URL" "${EXTRA_FLAGS[@]}"
fi
else
# ---------------- PATTERN MODE (original) ----------------
WINDOW_PATTERN="$arg1"
LAUNCH_COMMAND="${2:-"uwsm app -- $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 looks amazing waiting to see this in a new release. |
@Prajwal-Prathiksh thank you, I will try to fix it tomorrow or next week, I also need to resolve conflict with the webapp-install 🙂 |
Might need to change The default browser icon was a suggestion. I hadn't considered multi-browser setups. You nailed it. If DHH doesn't like |
case $browser in | ||
google-chrome* | brave-browser* | microsoft-edge* | opera* | vivaldi* | helium-browser*) ;; | ||
*) browser="chromium.desktop" ;; | ||
google-chrome* | brave-browser* | microsoft-edge* | opera* | vivaldi*) ;; |
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.
google-chrome* | brave-browser* | microsoft-edge* | opera* | vivaldi*) ;; | |
google-chrome* | brave-browser* | microsoft-edge* | opera* | vivaldi* | helium-browser*) ;; |
Helium browser was added last week #1945
Add multi-profile support for web app installer
This PR enhances the web app installer to support multiple browser profiles, allowing users to create separate web apps from different Chromium profiles.
Changes:
Use case:
Users can now install the same web app (e.g., Teams, Discord) multiple times with different browser profiles, allowing separate work/personal accounts to run simultaneously.
Example: