2

I have a problem with the glib / gio GVolumeMonitor. When I run this code

g_type_init();
GVolumeMonitor *vmon = g_volume_monitor_get();
GList *drives = g_volume_monitor_get_connected_drives(vmon);
printf("DRIVES: %p\n", drives);

inside gnome I get a valid entry.

Outside of gnome (e.g. in a terminal without a gnome session) I get a NIL.

Does anyone have a hint how to use GVolumeMonitor correctly? Perhaps gio needs to be initialized, but I don't know how to do it.

Michael W
  • 303
  • 1
  • 3
  • 10

1 Answers1

1

You need dbus and gvfsd. To test it, in a TTY you can try the following:

$ dbus-launch screen
$ ipython
>>> import gio
>>> vmon = gio.volume_monitor_get()
>>> vmon.get_connected_drives()
[...]
gpoo
  • 8,408
  • 3
  • 38
  • 53