dotfiles
Clone
https://git.tahinli.com/Tahinli/dotfiles.git
0 watching0 forksShellGPL-3.0334.8 KiBb1320e9Tahinli17 days ago105 commits
| 1 | #!/usr/bin/env bash |
| 2 | # Launch a Chromium web app (github, whatsapp, deezer, mail, ...). |
| 3 | # |
| 4 | # usage: webapp.sh [--mullvad] <url> <profile-id> |
| 5 | # |
| 6 | # --mullvad route outside the VPN via mullvad-exclude |
| 7 | # <url> app URL, e.g. https://github.com/ |
| 8 | # <profile-id> directory name under the web-app-hub profiles dir |
| 9 | # |
| 10 | # The window class is derived from the URL host as chrome-<host>__-Default, |
| 11 | # which is what Chromium itself would generate — it has to match, since that is |
| 12 | # the app-id niri and waybar see. |
| 13 | # |
| 14 | # Compositor-agnostic: usable from niri binds and Hyprland binds alike. |
| 15 | |
| 16 | |
| 17 | BROWSER_ID="io.github.ungoogled_software.ungoogled_chromium" |
| 18 | PROFILES="/.var/app//data/web-app-hub/profiles" |
| 19 | |
| 20 | MULLVAD=0 |
| 21 | if [; then |
| 22 | MULLVAD=1 |
| 23 | |
| 24 | fi |
| 25 | |
| 26 | URL="" |
| 27 | PROFILE="" |
| 28 | |
| 29 | # https://web.whatsapp.com/foo -> web.whatsapp.com |
| 30 | HOST="" |
| 31 | HOST="" |
| 32 | CLASS="chrome-__-Default" |
| 33 | |
| 34 | # Chromium names its MPRIS player chromium.instance<pid>, and every flatpak |
| 35 | # sandbox has its own pid namespace, so each web app's browser would get the |
| 36 | # same pid and only the first app to start shows in playerctl. The sandbox |
| 37 | # shell forks and reaps PID_SKIP throwaway processes first (pids are handed out |
| 38 | # sequentially), which moves chromium to a per-profile pid. Offsets start at 10 |
| 39 | # to stay clear of the Chromium flatpak and FreeTube at pid 2. The trailing |
| 40 | # `exit` stops bash from exec'ing chromium in place. |
| 41 | PID_SKIP= |
| 42 | cmd=(flatpak run --command=bash "" |
| 43 | -c 'for ((i = 0; i < $0; i++)); do : & done; wait; chromium "$@"; exit $?' "" |
| 44 | --no-first-run |
| 45 | --app="" |
| 46 | --class="" |
| 47 | --name="" |
| 48 | --user-data-dir="/") |
| 49 | |
| 50 | if [; then |
| 51 | cmd=(mullvad-exclude "") |
| 52 | fi |
| 53 | |
| 54 | # --dry-run prints the command instead of running it, for verification. |
| 55 | if [; then |
| 56 | |
| 57 | |
| 58 | |
| 59 | fi |
| 60 | |
| 61 |