From a018531108b1b51eaadb576750dec9c40b84c1f8 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 22 May 2021 10:31:32 +0800 Subject: 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. --- wifi-bluetooth-conf.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'wifi-bluetooth-conf.el') 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 @@ -147,6 +147,15 @@ If ARG is non-nil, then list the currently connected port." :command (list durand-wifi-executable "-s") :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. @@ -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 -- cgit v1.2.3-18-g5258