feat: supports chromium binary via faltpak

feat: will propery handle instance, url and additional options
master
Kebler Network System Administrator 2021-10-23 23:40:37 -07:00
parent 4fb2e4698c
commit 49920c442a
1 changed files with 44 additions and 28 deletions

View File

@ -2,35 +2,51 @@
# user to start MUST be first in arguments # user to start MUST be first in arguments
# if not supplied then will use default # if not supplied then will use default
chromium_ () { chromium_() {
local DEFAULT=/opt/chromium local DEFAULT=/opt/chromium
# local DEFAULT="$HOME/.local/share/chromium" # local DEFAULT="$HOME/.local/share/chromium"
local exe="/usr/bin/chromium" local exe="/usr/bin/chromium"
[[ ! $exe ]] && echo chromium not installed set && return 1 if [[ ! -f $exe ]]; then
user=${CHROMIUM_USER} echo deb chromium not installed, checking for flatpak version
[[ $1 && ( ! $1 == -* ) ]] && user=$1 && shift flatpak=$(flatpak info com.github.Eloston.UngoogledChromium | grep error:)
[[ $1 && ( ! $1 == -* ) ]] && url=$1 && shift if [[ $flatpak ]]; then
user=${user:-$USER} echo no flatpak version either - exiting && return 1
if [[ $user == "$USER" ]]; then else
unset CHROME_CONFIG_HOME flatpak=true
echo starting chromium for $USER in default directory within users home exe="/usr/bin/flatpak run --branch=stable --arch=x86_64 --filesystem=<dir> --command=/app/bin/chromium --file-forwarding com.github.Eloston.UngoogledChromium @@u"
echo $exe "$@" fi
$exe "$@"
else
[[ $user == "incognito" ]] && set -- "$@" "-incognito"
dir=${CHROMIUM_HOME:-$DEFAULT}
echo "$exe $@ --user-data-dir=$dir/$user"
"$exe" "$@" --user-data-dir="$dir"/"$user" $url
fi fi
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
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}"
# echo $exe "$@" $([[ $flatpak ]] && echo " @@")
# $exe "$@"
else
[[ $instance == "incognito" ]] && set -- "$@" "-incognito"
dir=${CHROMIUM_HOME:-$DEFAULT}/$instance
exe="${exe/<dir>/$dir}"
fi
$exe $@ --user-data-dir=$dir $url $([[ $flatpak ]] && echo "@@")
} }
# # if script was executed then call the function # # if script was executed then call the function
(return 0 2>/dev/null) || chromium_ $@ (return 0 2>/dev/null) || chromium_ $@