From 3de82782746019f605456d57226815eb9aac8369 Mon Sep 17 00:00:00 2001 From: Michaël Ball Date: Sun, 21 Feb 2021 11:47:16 +0000 Subject: Initial commit --- vpn.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 vpn.sh (limited to 'vpn.sh') diff --git a/vpn.sh b/vpn.sh new file mode 100755 index 0000000..452f326 --- /dev/null +++ b/vpn.sh @@ -0,0 +1,83 @@ +#!/bin/bash +ON_COLOR=${ON_COLOR:-"#00FF00"} +OFF_COLOR=${ON_COLOR:-"#FF0000"} + +while getopts O:o:h opt; do + case "$opt" in + O) ON_COLOR="$OPTARG" ;; + o) OFF_COLOR="$OPTARG" ;; + h) printf \ +"Usage: vpn.sh [-O color] [-o color] [-h] +Options: +-O\tColor for connected VPN indicator. Default: $ON_COLOR +-o\tColor for disconnected VPN indicator. Default: $OFF_COLOR +-h\tShow this help text +" && exit 0;; + esac +done + +##Check VPN status +GET_VPN=$(ip link | grep "tun0\|wg0" | cut -d ' ' -f2) + +##Store status in STATUS +if [[ $GET_VPN == *"0"* ]] +then + STATUS='' +else + STATUS=' ' +fi + +echo " $STATUS" +echo " $STATUS" + +##Colors +if [[ "$STATUS" == "" ]] +then + echo "$ON_COLOR" +else + echo "$OFF_COLOR" +fi + +while getopts F:Sf:adH:M:L:X:T:t:C:c:i:m:s:h opt; do + case "$opt" in + S) SUBSCRIBE=1 ;; + F) LONG_FORMAT="$OPTARG" ;; + f) SHORT_FORMAT="$OPTARG" ;; + a) USE_ALSA_NAME=1 ;; + d) USE_DESCRIPTION=1 ;; + H) AUDIO_HIGH_SYMBOL="$OPTARG" ;; + M) AUDIO_MED_SYMBOL="$OPTARG" ;; + L) AUDIO_LOW_SYMBOL="$OPTARG" ;; + X) AUDIO_MUTED_SYMBOL="$OPTARG" ;; + T) AUDIO_MED_THRESH="$OPTARG" ;; + t) AUDIO_LOW_THRESH="$OPTARG" ;; + C) DEFAULT_COLOR="$OPTARG" ;; + c) MUTED_COLOR="$OPTARG" ;; + i) AUDIO_INTERVAL="$OPTARG" ;; + m) MIXER="$OPTARG" ;; + s) SCONTROL="$OPTARG" ;; + h) printf \ +"Usage: volume-pulseaudio [-S] [-F format] [-f format] [-p] [-a|-d] [-H symb] [-M symb] + [-L symb] [-X symb] [-T thresh] [-t thresh] [-C color] [-c color] [-i inter] + [-m mixer] [-s scontrol] [-h] +Options: +-F, -f\tOutput format (-F long format, -f short format) to use, with exposed variables: +\${SYMB}, \${VOL}, \${INDEX}, \${NAME} +-S\tSubscribe to volume events (requires persistent block, always uses long format) +-a\tUse ALSA name if possible +-d\tUse device description instead of name if possible +-H\tSymbol to use when audio level is high. Default: '$AUDIO_HIGH_SYMBOL' +-M\tSymbol to use when audio level is medium. Default: '$AUDIO_MED_SYMBOL' +-L\tSymbol to use when audio level is low. Default: '$AUDIO_LOW_SYMBOL' +-X\tSymbol to use when audio is muted. Default: '$AUDIO_MUTED_SYMBOL' +-T\tThreshold for medium audio level. Default: $AUDIO_MED_THRESH +-t\tThreshold for low audio level. Default: $AUDIO_LOW_THRESH +-C\tColor for non-muted audio. Default: $DEFAULT_COLOR +-c\tColor for muted audio. Default: $MUTED_COLOR +-i\tInterval size of volume increase/decrease. Default: $AUDIO_DELTA +-m\tUse the given mixer. +-s\tUse the given scontrol. +-h\tShow this help text +" && exit 0;; + esac +done -- cgit v1.2.3