imporved chromium launch script. Has sensible defaults

trantor
Kebler Network System Administrator 2021-01-30 19:38:05 -08:00
parent 803e1fab5e
commit 3262da4ded
1 changed files with 15 additions and 7 deletions

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# TODO if non interactive then send notificaiton instead attempting command
function mv_chromium () { function mv_chromium () {
local _ch local _ch
local ch local ch
@ -23,14 +25,20 @@ local dir
mv_chromium mv_chromium
[[ $? -ne 0 ]] && echo chromium not installed && return 1 [[ $? -ne 0 ]] && echo chromium not installed && return 1
# echo chromium executable available and moved to $(command -v _chromium) # echo chromium executable available and moved to $(command -v _chromium)
user=${CHROME_USER:-$1}
user=${user:-$USER}
dir=${CHROME_CONFIG_HOME:-"$HOME/.config/chromium"}
[[ $user == "$USER" ]] && dir="$HOME/.config/chromium"
exe=$(command -v _chromium) exe=$(command -v _chromium)
echo "$exe --user-data-dir=$dir/$user" [[ ! $exe ]] && echo _chromium not set && return 1
$exe --user-data-dir=$dir/$user 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 # # if script was executed then call the function