This repository has been archived on 2022-02-20. You can view files and clone it, but cannot push or open issues/pull-requests.
bash-shell-host/all/archive/chromium.sh.archive

52 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/bash
# TODO if non interactive then send notificaiton instead attempting command
function mv_chromium () {
local _ch
local ch
_ch=$(command -v _chromium)
if [[ $_ch ]]; then
ch=$(dirname "$_ch")/chromium
## if chromium exits probably an update to so move again
[[ -f $ch ]] && sudo mv "${ch}" "$_ch" && echo chromium updated: $($_ch --version)
else
# echo no _chromium
ch=$(command -v chromium)
[[ $ch ]] && sudo mv "${ch}" "$(dirname "$ch")/_chromium" || return 1
fi
return 0
}
function chromium_ () {
local user
local dir
mv_chromium
[[ $? -ne 0 ]] && echo chromium not installed && return 1
# echo chromium executable available and moved to $(command -v _chromium)
exe=$(command -v _chromium)
[[ ! $exe ]] && echo _chromium not set && return 1
user=${CHROME_USER}
[[ $1 && ( ! $1 == -* ) ]] && user=$1 && shift
user=${user:-$USER}
if [[ $user == "$USER" ]]; then
unset CHROME_CONFIG_HOME
$exe "$@"
else
[[ $user == "incognito" ]] && set -- "$@" "-incognito"
dir=${CHROME_CONFIG_HOME:-"$HOME/.local/share/chromium"}
echo "$exe $@ --user-data-dir=$dir/$user"
$exe "$@" --user-data-dir=$dir/$user
fi
}
# # if script was executed then call the function
(return 0 2>/dev/null) || chromium_ $@