basic implementation of networks (requires nmcli)

master
nixo 2002-01-01 01:35:02 +01:00
parent 941b33587e
commit 1db07cc0fa
1 changed files with 35 additions and 0 deletions

View File

@ -3,3 +3,38 @@
;; - [ ] is connected using wifi or ethernet
;; - [ ] if wifi, the netkwork name
;; - [ ] network usage (speed)
(add-to-load-path "..")
(use-modules (ice-9 popen)
(ice-9 textual-ports)
(org helpers)
(org format))
(define (run-command command-string)
(let* ((port
(open-input-pipe command-string))
(str (get-string-all port)))
(close-pipe port)
(string-trim-both str)))
(define active-connections-command
(string-join '("nmcli -t" "con" "show" "--active")))
;; TODO: alist is better, fix org-format
(define (make-connection-list conn)
(let ((params '("NAME" "UUID" "TYPE" "DEVICE")))
(map (lambda (x y) `(,x ,y))
params conn)))
(define (split-on-colone str) (string-split str #\:))
(define (active-connections)
(map (lambda (c) (make-connection-list c))
(map split-on-colon
(string-split
(run-command active-connections-command)
#\nl))))
(map org-properties (active-connections))