summaryrefslogtreecommitdiffhomepage
path: root/net/jao-proton-utils.el
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2020-09-30 03:31:05 +0100
committerjao <jao@gnu.org>2020-09-30 03:31:05 +0100
commit72c580909cdfd6f8d3655cd92ab1a4bfd52717fe (patch)
treedce47f9fe2966b3c6a1064458a09e06d7a137fb4 /net/jao-proton-utils.el
parentd91bc785a7d2669014dd6509bcf6e4816756806c (diff)
downloadelibs-72c580909cdfd6f8d3655cd92ab1a4bfd52717fe.tar.gz
elibs-72c580909cdfd6f8d3655cd92ab1a4bfd52717fe.tar.bz2
proton vpn: ugly sit to reconnect
Diffstat (limited to 'net/jao-proton-utils.el')
-rw-r--r--net/jao-proton-utils.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/net/jao-proton-utils.el b/net/jao-proton-utils.el
index 5c817ac..2d20f5e 100644
--- a/net/jao-proton-utils.el
+++ b/net/jao-proton-utils.el
@@ -60,15 +60,15 @@
(defvar jao-proton-vpn--buffer "*pvpn*")
-(defun jao-proton-vpn--do (things &optional buffer)
- (let ((b (or buffer (pop-to-buffer (get-buffer-create jao-proton-vpn--buffer)))))
+(defun jao-proton-vpn--do (things)
+ (let ((b (pop-to-buffer (get-buffer-create jao-proton-vpn--buffer))))
(let ((inhibit-read-only t)
(cmd (format "sudo protonvpn %s" things)))
(delete-region (point-min) (point-max))
(message "Running: %s ...." cmd)
(shell-command cmd b)
(message ""))
- (when (not buffer) (proton-vpn-mode))))
+ (proton-vpn-mode)))
;;;###autoload
(defun proton-vpn-status ()
@@ -79,8 +79,10 @@
(or (when-let ((b (get-buffer jao-proton-vpn--buffer)))
(with-current-buffer b
(goto-char (point-min))
- (when (re-search-forward "^Status: *\\(.+\\)$" nil t)
- (match-string-no-properties 1))))
+ (if (re-search-forward "^Status: *\\(.+\\)$" nil t)
+ (match-string-no-properties 1)
+ (when (re-search-forward "^Connected!$")
+ "Connected"))))
"Disconnected"))
;;;###autoload
@@ -94,13 +96,15 @@
(interactive)
(jao-proton-vpn--do "r"))
+(setenv "PVPN_WAIT" "300")
+
;;;###autoload
(defun proton-vpn-maybe-reconnect ()
(interactive)
(when (string= "Connected" (proton-vpn--get-status))
- (message "Reconnecting VPN...")
- (proton-vpn-reconnect)
- (message "Reconnecting VPN... done")))
+ (jao-proton-vpn--do "d")
+ (sit-for 5)
+ (jao-proton-vpn--do "r")))
;;;###autoload
(defun proton-vpn-disconnect ()