1 /* Setup if we need battery? */
3 #include "e_mod_main.h"
6 # include <sys/ioctl.h>
7 # include <sys/sysctl.h>
9 # include <machine/apm_bios.h>
14 read_file(const char *file)
16 FILE *f = fopen(file, "r");
20 len = fread(buf, 1, sizeof(buf) - 1, f);
27 for (p = buf; *p; p++)
29 if (p[0] == '\n') p[0] = 0;
36 wizard_page_init(E_Wizard_Page *pg __UNUSED__)
42 wizard_page_shutdown(E_Wizard_Page *pg __UNUSED__)
48 wizard_page_show(E_Wizard_Page *pg __UNUSED__)
52 char buf[PATH_MAX], *file, *dname, *str;
54 dname = "/sys/class/power_supply";
55 dir = ecore_file_ls(dname);
58 EINA_LIST_FREE(dir, file)
60 snprintf(buf, sizeof(buf), "%s/%s/type", dname, file);
64 if (!strcasecmp(str, "Battery")) hav_bat = 1;
69 dname = "/proc/acpi/battery/";
70 dir = ecore_file_ls(dname);
73 EINA_LIST_FREE(dir, file)
75 snprintf(buf, sizeof(buf), "%s/%s/state", dname, file);
90 /* Read some information on first run. */
92 sysctlnametomib("hw.acpi.battery.state", mib_state, &len);
94 if (sysctl(mib_state, 4, &state, &len, NULL, 0) != -1)
103 EINA_LIST_FOREACH(e_config->modules, l, em)
105 if (!em->name) continue;
106 if (!strcmp(em->name, "battery"))
108 e_config->modules = eina_list_remove_list
109 (e_config->modules, l);
110 if (em->name) eina_stringshare_del(em->name);
115 e_config_save_queue();
117 return 0; /* 1 == show ui, and wait for user, 0 == just continue */
121 wizard_page_hide(E_Wizard_Page *pg __UNUSED__)
127 wizard_page_apply(E_Wizard_Page *pg __UNUSED__)