Eeze is a library for manipulating devices through udev with a simple and fast api. It interfaces directly with libudev, avoiding such middleman daemons as udisks/upower or hal, to immediately gather device information the instant it becomes known to the system.

What can I do with Eeze?

  • Determine whether a cdrom has a disk inserted
  • Get the temperature of a cpu core
  • Get remaining power left in a battery
  • Get current power consumption of various parts
  • Monitor, in realtime, the status of peripheral devices

Each of the above examples can be performed by using only a single eeze function, as one of the primary focuses of the library is to reduce the complexity of managing devices.

How is complexity reduced?

Eeze provides a set of functions which work using abstracted types. For example, type 'EEZE_UDEV_TYPE_KEYBOARD' is used to gather data and monitor keyboard devices without knowing anything about the device itself.

list = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, "Logitech");

The above code will return a list of syspaths (/sys/path) for all keyboard devices attached whose names contain the string "Logitech." From there, the following code could be used to print the devpaths (/dev/path) for the keyboards:

EINA_LIST_FOREACH(list, l, string)
  printf("Keyboard %s has device path %s\n!", string, eeze_udev_syspath_get_devpath(string));

At this point, if we wanted to monitor the state of the keyboard, this could be used:

#include <Eeze.h>

static void
_eeze_callback(const char *device, Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch)
{
   switch (event)
     {
      case EEZE_UDEV_EVENT_REMOVE:
        printf("Device %s removed!\n", device);
        break;
      case EEZE_UDEV_EVENT_ADD:
        printf("Device %s added at path %s!\n", device, eeze_udev_syspath_get_devpath(device));
        break;
      case EEZE_UDEV_EVENT_CHANGE:
        printf("Device %s has changed its properties!\n", device);
        break;
      case EEZE_UDEV_EVENT_ONLINE:
        printf("Device %s has come online!\n", device);
        break;
      case EEZE_UDEV_EVENT_OFFLINE:
        printf("Device %s has gone offline!\n", device);
        break;
      default:
        printf("Device %s has not changed in any way! This is a bug!\n", device);
        break;
     }
}

int
main(void)
{
   ecore_init();
   eeze_init();
   eeze_udev_watch_add(EEZE_UDEV_TYPE_KEYBOARD, EEZE_UDEV_EVENT_NONE /* all events monitored */, _eeze_callback, NULL);
   ecore_main_loop_begin();
   eeze_shutdown();
   ecore_shutdown();
   return 0;
}

In this way, we have reduced the amount of code required to monitor a device to a single eeze function.

Software

Documentation

ROADMAP

Features for future versions.

1.1:

  • Will integrate udev with libmount, providing elegant disk-related functions.

The following small program could be used with eeze 1.1 to provide a simple disk viewing utility:

#include <stdio.h>
#include <Ecore.h>
#include <Eeze.h>
#include <Eeze_Disk.h>

/* simple app to print disks and their mount points */

int
main(void)
{
   Eina_List *disks;
   const char *syspath;
   
   eeze_init();
   eeze_disk_function();

   disks = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_MOUNTABLE, NULL);
   printf("Found the following disks:\n");
   EINA_LIST_FREE(disks, syspath)
     {
        Eeze_Disk *disk;

        disk = eeze_disk_new(syspath);
        printf("\t%s - %s:%s\n", syspath, eeze_disk_devpath_get(disk), eeze_disk_mount_point_get(disk));
        eeze_disk_free(disk);
        eina_stringshare_del(syspath);
     }
     
   disks = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
   printf("Found the following removable drives:\n");
   EINA_LIST_FREE(disks, syspath)
     {
        Eeze_Disk *disk;

        disk = eeze_disk_new(syspath);
        printf("\t%s - %s:%s\n", syspath, eeze_disk_devpath_get(disk), eeze_disk_mount_point_get(disk));
        eeze_disk_free(disk);
        eina_stringshare_del(syspath);
     }

   disks = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
   printf("Found the following internal drives:\n");
   EINA_LIST_FREE(disks, syspath)
     {
        Eeze_Disk *disk;

        disk = eeze_disk_new(syspath);
        printf("\t%s - %s\n", syspath, eeze_disk_devpath_get(disk));
        eeze_disk_free(disk);
        eina_stringshare_del(syspath);
     }
   return 0;
}