1234567891011121314151617181920212223242526272829303132333435 |
- # vim: ft=sh
- # shellcheck shell=sh
- run_app() {
- set -ue
- name="${1:?provide app name}"
- app="${2:-}"
- chromium="chromium${CHROMIUM_NO_VPN:+-nv}"
- if [ -n "${CHROMIUM_TEMPORARY:-}" ]; then
- apps_dir="${XDG_RUNTIME_DIR:-${TMPDIR:-/tmp}}/chromium-apps"
- else
- apps_dir="${HOME}/.cache/chromium-apps"
- fi
- dir="${apps_dir}/${name}"
- [ -z "${app}" ] && echo 'WARNING: no app url provided' 1>&2
- mkdir -p "${dir}"
- cd "${dir}"
- [ -n "${CHROMIUM_TEMPORARY:-}" ] && {
- ppid="${$}"
- # shellcheck disable=2016
- chromium_tmp_dir="${dir}" \
- waitpid "${ppid}" \
- 'exec rm -rf -- "${chromium_tmp_dir:?}"' &
- }
- exec "${chromium}" \
- --user-data-dir="../${dir##*/}" \
- ${app:+--app="${app}"}
- }
|