summaryrefslogtreecommitdiff
path: root/wifi-bluetooth-conf.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-05-22 10:31:32 +0800
committerJSDurand <mmemmew@gmail.com>2021-05-22 10:31:32 +0800
commita018531108b1b51eaadb576750dec9c40b84c1f8 (patch)
tree888cc7a9d32004bf1f527ef403224f7529cd5d6d /wifi-bluetooth-conf.el
parent402cadf8ee35a54e1f9493f6cf20189d30a5b004 (diff)
Add mechanism to automatically connect to Known WIFIs.
* wifi-bluetooth-conf.el (durand-wifi-ssid-machine-alist): This stores a list of associations between the SSID of WIFI and its machine name that can be used to search for passwords. (durand-wifi-join-port): This can now join two WIFI ports that I still remember the passwords, which is enough for now.
Diffstat (limited to 'wifi-bluetooth-conf.el')
-rw-r--r--wifi-bluetooth-conf.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/wifi-bluetooth-conf.el b/wifi-bluetooth-conf.el
index a32af96..52bff4d 100644
--- a/wifi-bluetooth-conf.el
+++ b/wifi-bluetooth-conf.el
@@ -148,6 +148,15 @@ If ARG is non-nil, then list the currently connected port."
:sentinel #'durand-wifi-list-sentinel) )))
;;;###autoload
+(defvar durand-wifi-ssid-machine-alist
+ (list
+ (cons "20-1" "wifi-2")
+ (cons "1-20-4F" "wifi-4"))
+ "A list of associations between the SSID of WIFI and the
+ machine name that we can use to search for the password in my
+ secret file.")
+
+;;;###autoload
(defun durand-wifi-join-port (port &optional pwd)
"Join PORT.
If PWD is non-nil, use that as the password."
@@ -156,6 +165,20 @@ If PWD is non-nil, use that as the password."
(cond ((and pwd (not (string= pwd "")))
(list po pwd))
((list po)))))
+ (cond
+ (pwd)
+ ((let ((search-result
+ (alist-get port
+ durand-wifi-ssid-machine-alist
+ nil nil #'string=)))
+ (cond
+ (search-result
+ (setq
+ pwd
+ (funcall
+ (plist-get
+ (car (auth-source-search :host search-result))
+ :secret))))))))
(make-process
:name "durand-wifi-join-port"
:buffer durand-wifi-bluetooth-buffer