summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-02-07 19:43:07 +0100
committerRuben Pollan <meskio@sindominio.net>2018-02-07 19:43:07 +0100
commita93041b152b02d2c782baae2ccb39af905e6b9a3 (patch)
treec2c4d326afe1b7586664368e6f3a222647cd337c /docs
parent0f69d4ba3a73d5a1c2d9793a928a26feac91e99e (diff)
[doc] autostart with .desktop and qubes i3 status
Diffstat (limited to 'docs')
-rw-r--r--docs/vpn/index.rst59
1 files changed, 59 insertions, 0 deletions
diff --git a/docs/vpn/index.rst b/docs/vpn/index.rst
index 95eb08c2..ef9a1510 100644
--- a/docs/vpn/index.rst
+++ b/docs/vpn/index.rst
@@ -77,3 +77,62 @@ a systemd script to launch vpn. If you have the latest master installed from a d
[Install]
WantedBy=default.target
+
+Another option is to autostart it adding a ``~/.config/autostart/bitmask.desktop``::
+
+ [Desktop Entry]
+ Version=1.0
+ Encoding=UTF-8
+ Type=Application
+ Name=Bitmask
+ Comment=Secure Communication
+ Exec=bitmaskctl vpn start
+ Terminal=false
+ Icon=bitmask
+
+Qubes i3 status
+---------------
+The following script can be used to add the bitmask status to the i3 status bar in qubes::
+
+ status_bitmask() {
+ local status=$(qvm-run "sys-bitmask" -p 'bitmaskctl vpn status --json' 2>/dev/null)
+ local error=$(parse_json 'error')
+
+ if [[ $error -ne "None" ]]; then
+ json bitmask "VPN: $error" '#ff0000'
+ else
+ local domain=$(parse_json 'result' 'domain')
+ local sttus=$(parse_json 'result' 'status')
+ local up=$(parse_json 'result' 'up')
+ local down=$(parse_json 'result' 'down')
+ local error=$(parse_json 'result' 'error')
+
+ case $sttus in
+ "on")
+ local text="$domain: ↑$up ↓$down"
+ local color=""
+ ;;
+ "starting")
+ local text="$domain: starting"
+ local color="#00ff00"
+ ;;
+ "off"|"stopping")
+ local text="VPN: off"
+ local color='#ffff00'
+ ;;
+ "failed")
+ local text="VPN: $error"
+ local color="#ff0000"
+ ;;
+ esac
+ json bitmask "$text" $color
+ fi
+ }
+
+ parse_json() {
+ local item=""
+ for param in $@; do
+ item=${item}"['${param}']"
+ done
+ echo -n $(python -c "import json; j=json.loads(\"\"\"$status\"\"\"); print j${item}")
+ }