new-qb

#47
Raw
Author
winny
Created
Sept. 8, 2020, 2:18 a.m.
Expires
Never
Size
1.0 KB
Hits
64
Syntax
Bash
#!/usr/bin/env bash
# A script to start up qutebrowser sessions or to otherwise manage them.
set -eu
error() {
    printf 'Error: %s\n' "$*"
    usage
}
usage() {
    printf '%s [-t|-p <profile>]\n' "$0" >&2
    printf "When no argument is given, \`-t' is used\n" >&2
    exit $1
}
mode=unset
while getopts 'tp:h' options; do
    case "${options}" in
        t)
            if [[ $mode != unset ]]; then
                error 'Connot specify both -t and -p'
            fi
            mode=t
            ;;
        p)
            if [[ $mode != unset ]]; then
                error 'Connot specify both -t and -p'
            fi
            mode=p
            profile="${OPTARG}"
            ;;
        h)
            usage 0
            ;;
        *)
            usage 1
            ;;
    esac
done
if [[ $mode = unset ]]; then
    mode=t
fi
case "$mode" in
    t)
        args=(-T)
        ;;
    p)
        args=(-B "$HOME/.config/qutebrowser.${profile}")
        ;;
esac
shift $((OPTIND - 1))
set -x
exec qutebrowser "${args[@]}" "$@"