Skip to content

Instantly share code, notes, and snippets.

@xuhdev
Created December 25, 2014 08:57
Show Gist options
  • Select an option

  • Save xuhdev/cc840c8dd6229cfe0d25 to your computer and use it in GitHub Desktop.

Select an option

Save xuhdev/cc840c8dd6229cfe0d25 to your computer and use it in GitHub Desktop.
Enable and disable wireless via libnm-glib
/* Compile with
* gcc nm-test.c `pkg-config --cflags libnm-glib` `pkg-config --libs libnm-glib` `pkg-config --cflags glib-2.0` */
#include <string.h>
#include <nm-client.h>
#include <glib.h>
int main(int argc, const char * argv[])
{
NMClient * nm = nm_client_new();
if (argc >= 2 && !strcmp(argv[1], "disable"))
{
nm_client_wireless_set_enabled(nm, FALSE);
puts("Wireless disabled.");
}
else
{
nm_client_wireless_set_enabled(nm, TRUE);
puts("Wireless enabled.");
}
g_object_unref(nm);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment