basic implementation of networks (requires nmcli)
This commit is contained in:
parent
941b33587e
commit
1db07cc0fa
|
@ -3,3 +3,38 @@
|
||||||
;; - [ ] is connected using wifi or ethernet
|
;; - [ ] is connected using wifi or ethernet
|
||||||
;; - [ ] if wifi, the netkwork name
|
;; - [ ] if wifi, the netkwork name
|
||||||
;; - [ ] network usage (speed)
|
;; - [ ] 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))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue