2021-02-05 12:21:17 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-10-23 23:40:37 -07:00
|
|
|
# user to start MUST be first in arguments
|
2021-02-05 12:21:17 -08:00
|
|
|
# if not supplied then will use default
|
2021-10-23 23:40:37 -07:00
|
|
|
chromium_() {
|
|
|
|
local DEFAULT=/opt/chromium
|
2021-12-04 22:14:09 -08:00
|
|
|
local DEFAULT_USER=$HOME/.browsers
|
2021-10-23 23:40:37 -07:00
|
|
|
# local DEFAULT="$HOME/.local/share/chromium"
|
|
|
|
local exe="/usr/bin/chromium"
|
2021-11-02 07:01:28 -07:00
|
|
|
|
|
|
|
[[ $1 == -g ]] && exe=$(command -v google-chrome) && shift
|
2021-12-04 22:14:09 -08:00
|
|
|
echo execuatble to be used: $exe
|
2021-10-23 23:40:37 -07:00
|
|
|
if [[ ! -f $exe ]]; then
|
2021-11-02 07:01:28 -07:00
|
|
|
echo chromium/chrome not installed, checking for flatpak version
|
2021-10-23 23:40:37 -07:00
|
|
|
flatpak=$(flatpak info com.github.Eloston.UngoogledChromium | grep error:)
|
|
|
|
if [[ $flatpak ]]; then
|
|
|
|
echo no flatpak version either - exiting && return 1
|
|
|
|
else
|
|
|
|
flatpak=true
|
|
|
|
exe="/usr/bin/flatpak run --branch=stable --arch=x86_64 --filesystem=<dir> --command=/app/bin/chromium --file-forwarding com.github.Eloston.UngoogledChromium @@u"
|
|
|
|
fi
|
2021-02-05 12:21:17 -08:00
|
|
|
fi
|
|
|
|
|
2021-10-23 23:40:37 -07:00
|
|
|
local instance=${CHROMIUM_INSTANCE}
|
|
|
|
[[ $1 && (! $1 == -*) ]] && instance=$1 && shift
|
|
|
|
[[ $1 && (! $1 == -*) ]] && url=$1 && shift
|
|
|
|
if [[ $instance =~ http[s]?:\/\/ ]]; then
|
|
|
|
url=$instance
|
|
|
|
instance=""
|
|
|
|
if [[ $url =~ ^-+ ]]; then
|
|
|
|
url=""
|
|
|
|
set -- "$@" $url
|
|
|
|
url=""
|
|
|
|
fi
|
|
|
|
fi
|
2021-02-05 12:21:17 -08:00
|
|
|
|
2021-10-23 23:40:37 -07:00
|
|
|
local dir
|
|
|
|
if [[ ! $instance ]]; then
|
|
|
|
unset CHROME_CONFIG_HOME
|
|
|
|
$HOME/.config/chromium
|
|
|
|
echo starting chromium for $USER in
|
|
|
|
dir=$HOME/.config/chromium
|
|
|
|
exe="${exe/<dir>/$dir}"
|
|
|
|
else
|
|
|
|
[[ $instance == "incognito" ]] && set -- "$@" "-incognito"
|
2021-12-04 22:14:09 -08:00
|
|
|
dir=${DEFAULT_USER}/$instance
|
|
|
|
dir=$([[ -d "$dir" ]] && echo $dir || echo "${CHROMIUM_HOME:-$DEFAULT}/$instance")
|
2021-10-23 23:40:37 -07:00
|
|
|
exe="${exe/<dir>/$dir}"
|
|
|
|
fi
|
2021-11-02 07:01:28 -07:00
|
|
|
mkdir -p $dir
|
|
|
|
echo $exe $@ --user-data-dir=$dir $url $([[ $flatpak ]] && echo "@@")
|
2021-10-23 23:40:37 -07:00
|
|
|
$exe $@ --user-data-dir=$dir $url $([[ $flatpak ]] && echo "@@")
|
2021-02-05 12:21:17 -08:00
|
|
|
|
2021-10-23 23:40:37 -07:00
|
|
|
}
|
2021-02-05 12:21:17 -08:00
|
|
|
|
2021-10-23 23:40:37 -07:00
|
|
|
# # if script was executed then call the function
|
|
|
|
(return 0 2>/dev/null) || chromium_ $@
|