int main (int argc, char **argv) { SensorData *data; GUdevClient *client; int ret = 0; const gchar * const subsystems[] = { "iio", "input", "platform", NULL }; guint i; /* g_setenv ("G_MESSAGES_DEBUG", "all", TRUE); */ data = g_new0 (SensorData, 1); data->previous_orientation = ORIENTATION_UNDEFINED; data->uses_lux = TRUE; /* Set up D-Bus */ setup_dbus (data); client = g_udev_client_new (subsystems); if (!find_sensors (client, data)) { g_debug ("Could not find any supported sensors"); return 0; } g_signal_connect (G_OBJECT (client), "uevent", G_CALLBACK (sensor_changes), data); for (i = 0; i < NUM_SENSOR_TYPES; i++) { data->clients[i] = create_clients_hash_table (); if (!driver_type_exists (data, i)) continue; if (!driver_open (DRIVER_FOR_TYPE(i), DEVICE_FOR_TYPE(i), driver_type_to_callback_func (data->drivers[i]->type), data)) { DRIVER_FOR_TYPE(i) = NULL; g_clear_object (&DEVICE_FOR_TYPE(i)); } } if (!any_sensors_left (data)) goto out; data->init_done = TRUE; if (data->connection) { send_dbus_event (data, PROP_ALL); send_dbus_event (data, PROP_ALL_COMPASS); } data->loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (data->loop); out: free_orientation_data (data); return ret; }
int main (int argc, char **argv) { ControlData *data; int fd; /* g_setenv ("G_MESSAGES_DEBUG", "all", TRUE); */ /* Check for VGA switcheroo availability */ fd = open (SWITCHEROO_SYSFS_PATH, O_WRONLY); if (fd < 0) { int err = errno; switch (err) { case EACCES: g_warning ("switcheroo-control needs to run as root"); break; case ENOENT: g_debug ("No switcheroo support available"); /* not an error */ return 0; default: g_warning ("switcheroo-control could not query vga_switcheroo status: %s", g_strerror (err)); } return 1; } /* And force the integrated card to be the default card */ force_integrate_card (fd); close (fd); data = g_new0 (ControlData, 1); data->available = TRUE; setup_dbus (data); data->init_done = TRUE; if (data->connection) send_dbus_event (data); data->loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (data->loop); free_control_data (data); return 0; }