~hristoast/mousikofidi

ae0e0d325a28434f7994ecab1020d1f89ffa05b9 — Hristos N. Triantafillou 1 year, 11 days ago 4cb308d
Added an executable for a 'client'

It's just a wrapper for opening a web browser, but it might be nice to
have.
4 files changed, 121 insertions(+), 1 deletions(-)

M .builds/archlinux.yml
M .builds/debian.yml
A example/mousikofidi-client
M setup.py
M .builds/archlinux.yml => .builds/archlinux.yml +1 -0
@@ 39,3 39,4 @@ tasks:
      cd mousikofidi
      sudo pip3 install .
      mousikofidi --help
      mousikofidi-client --help

M .builds/debian.yml => .builds/debian.yml +1 -0
@@ 41,6 41,7 @@ tasks:
      cd mousikofidi
      sudo pip3 install .
      mousikofidi --help
      mousikofidi-client --help
  - upload-to-pypi: |
      cd mousikofidi
      ./pypi-upload.sh

A example/mousikofidi-client => example/mousikofidi-client +118 -0
@@ 0,0 1,118 @@
#!/bin/bash

Help() {
    cat << EOF
usage: mousikofidi-client [-h] [-u URL] [-n] [optional browser flag]

Run a web browser in incognito or private mode pointed at the
MousikóFídi instance of your choosing.

optional arguments:
  -h, --help            show this help message and exit

Options:
  --chrome              Open a MousikóFídi with Chrome.

  --chromium            Open a MousikóFídi with Chromium.
                        This is the default.

  --firefox             Open a MousikóFídi with Firefox.

  --icecat              Open a MousikóFídi with IceCat.

  -o BROWSER            Name of a web browser executable to use.
  --other BROWSER

  -u URL,               The address of the MousikóFídi instance to be opened.
  --instance-url URL    Default: mousikofidi.info

  -n, --no-private      Don't use an incognito or private browser session.
EOF
}

export browser=chromium
export instanceURL=${FIDI_URL:-mousikofidi.info}
export other=false
export private=true

opts=$(getopt -l "help,chrome,chromium,firefox,icecat,instance-url:,no-private,other:" -o "no:u:" -a -- "$@")

eval set -- "$opts"

while true
do
    case $1 in
        -h|--help)
            Help
            exit 0
            ;;
        --chrome)
            export browser=chrome
            ;;
        --chromium)
            export browser=chromium
            ;;
        --firefox)
            export browser=firefox
            ;;
        --icecat)
            export browser=icecat
            ;;
        --other)
            shift
            export browser=$1
            export other=true
            ;;
        -u|--instance-url)
            shift
            export instanceURL=$1
            ;;
        -p|--private)
            export private=true
            ;;
        --)
            shift
            break;;
    esac
    shift
done

if [ "${browser}" = "chrome" ]; then
    if [ "${private}" = "true" ]; then
        chrome --incognito "${instanceURL}" 2>/dev/null >/dev/null
    else
        chrome "${instanceURL}" 2>/dev/null >/dev/null
    fi

elif [ "${browser}" = "chromium" ]; then
    if [ "${private}" = "true" ]; then
        chromium --incognito "${instanceURL}" 2>/dev/null >/dev/null
    else
        chromium "${instanceURL}" 2>/dev/null >/dev/null
    fi

elif [ "${browser}" = "firefox" ]; then
    if [ "${private}" = "true" ]; then
        firefox --private-window "${instanceURL}" 2>/dev/null >/dev/null
    else
        firefox "${instanceURL}" 2>/dev/null >/dev/null
    fi

elif [ "${browser}" = "icecat" ]; then
    if [ "${private}" = "true" ]; then
        icecat --private-window "${instanceURL}" 2>/dev/null >/dev/null
    else
        icecat "${instanceURL}" 2>/dev/null >/dev/null
    fi

elif [ "${other}" = "true" ]; then
    eval "${browser}" "${instanceURL}" 2>/dev/null >/dev/null || echo [ERROR]: The given browser \""${browser}"\" failed!

else
    if [ "${private}" = "true" ]; then
        chromium --incognito "${instanceURL}" 2>/dev/null >/dev/null
    else
        chromium "${instanceURL}" 2>/dev/null >/dev/null
    fi

fi

M setup.py => setup.py +1 -1
@@ 67,5 67,5 @@ setup(
    ],
    install_requires=req,
    python_requires=">=3.5",
    scripts=["example/mousikofidi"],
    scripts=["example/mousikofidi", "example/mousikofidi-client"],
)