nicferrier / emacs-nm

Emacs interface to Gnome's Network Manager
12 stars 5 forks source link

nmcli changed its interface #2

Open YoungFrog opened 8 years ago

YoungFrog commented 8 years ago

Hi nic. it seems that nmcli changed its interface : the "nm" object vanished and some other options seem to have changed. I guess the more reliable way is to use dbus, which is what @tromey does at https://github.com/tromey/emacs-network-manager

as an example I wrote a dbus version of your (gnomenm/connected) function. (I'm not 100% sure I'm doing it right,but I guess it's not too far)

(require 'NetworkManager)
(defun gnomenm-dbus//get-prop (property &optional path interface)
  (dbus-get-property NetworkManager-bus
                     NetworkManager-service
                     (or path NetworkManager-path)
                     (or interface NetworkManager-interface)
                     property))
(defun gnomenm-dbus//PrimaryConnection ()
  (gnomenm-dbus//get-prop "PrimaryConnection"))

(defun gnomenm-dbus/connected ()
  "What AP are we currently connected to?"
  (and
   (NetworkManager-connected-p)
   (equal (gnomenm-dbus//get-prop "PrimaryConnectionType")
          "802-11-wireless")
   (gnomenm-dbus//get-prop
    "Id"
    (gnomenm-dbus//PrimaryConnection)
    "org.freedesktop.NetworkManager.Connection.Active")))
YoungFrog commented 8 years ago

Btw here's the spec for the dbus API https://developer.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.html