Skip to content

Conversation

przemekmatsumoto
Copy link

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:

  • Installer: Added profile detection and selection
    • Automatically detects available Chromium profiles (Default, Profile 1, etc.)
    • Shows profile selection menu when multiple profiles exist
    • Uses single profile automatically when only one exists

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:

  • Teams (Work profile)
  • Teams (Personal profile)
screenshot-2025-08-28_21-55-10 screenshot-2025-08-28_21-56-31 screenshot-2025-08-28_21-58-50
  • Both appear as separate desktop applications

@dhh dhh mentioned this pull request Sep 1, 2025
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new names

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct profile names.

Copy link

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

@rez1coder
Copy link
Contributor

I think you need to simplify the web app view for this use case.

After Omarchy ASCII logo,

Let's create a new web app you can start with the app launcher.

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.

  • Which browser
  • Select Browser Profile
  • Enter

@Prajwal-Prathiksh
Copy link

From Omarchy v3.0.0, omarchy-launch-or-focus was introduced.
Because of this I had to make some modifications to your fork to have it work with the new release.
I'm updating it here @przemekmatsumoto in case you want to follow up further on this PR.

omarchy-lauch-webapp

#!/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" "$@"

omarchy-launch-or-focus

#!/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

@alvarosaavedra
Copy link

This looks amazing waiting to see this in a new release.

@przemekmatsumoto
Copy link
Author

@Prajwal-Prathiksh thank you, I will try to fix it tomorrow or next week, I also need to resolve conflict with the webapp-install 🙂

@przemekmatsumoto
Copy link
Author

pragne snu bardzo pragne snu

If the user only has one profile in the browser, the script won't ask for it; it will automatically create using "Default".

I don't know if this is what rez1coder had in mind about changing the Omarchy logo 😄.

@rez1coder
Copy link
Contributor

I don't know if this is what rez1coder had in mind about changing the Omarchy logo 😄.

Might need to change chromium if Ladybird and Firefox catch up with frameless web-app windows.

The default browser icon was a suggestion. I hadn't considered multi-browser setups. You nailed it.

If DHH doesn't like chromium or browser ASCII, the default Omarchy logo works fine.

case $browser in
google-chrome* | brave-browser* | microsoft-edge* | opera* | vivaldi* | helium-browser*) ;;
*) browser="chromium.desktop" ;;
google-chrome* | brave-browser* | microsoft-edge* | opera* | vivaldi*) ;;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants