#!/bin/bash # user to start MUST be first in arguments # if not supplied then will use default chromium_() { local DEFAULT=/opt/chromium local DEFAULT_USER=$HOME/.browsers local DEFAULT_SNAP=$HOME/snap/chromium/common # set default exe here (no flag) local exe="/usr/bin/chromium" local snap if [[ $1 == "-version" ]]; then $exe -version return fi [[ $1 == -d ]] && exe=/usr/bin/chromiium && shift [[ $1 == -g ]] && exe=$(command -v google-chrome) && shift [[ $1 == -s ]] && snap=true && exe=/snap/bin/chromium && shift [[ $1 == -u ]] && exe=/opt/bin/ungoogled-chromium && shift [[ $1 == -v ]] && exe=/opt/vivaldi/vivaldi && shift [[ $1 == -c ]] && exe=/usr/bin/chromium && shift echo execuatble to be used: $exe if [[ ! -f $exe ]]; then echo chromium/chrome not installed at $exe return 2 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 [[ ! $instance ]] && instance=chromium && unset CHROME_CONFIG_HOME [[ $instance == "incognito" ]] && set -- "$@" "-incognito" dir=${DEFAULT_USER}/$instance dir=$([[ -d "$dir" ]] && echo $dir || echo "${CHROMIUM_HOME:-$DEFAULT}/$instance") # exe="${exe//$dir}" if [[ $snap ]]; then sdir=${DEFAULT_SNAP}/$instance mkdir -p $sdir fusermount -u $sdir /usr/bin/bindfs $dir $sdir dir=$sdir fi mkdir -p $dir echo $exe $@ --user-data-dir=$dir $url $exe $@ --user-data-dir=$dir $url } # # if script was executed then call the function (return 0 2>/dev/null) || chromium_ $@