1 /* Setup if we need cpufreq? */
2 #include "e_wizard.h"
3 #include "e_wizard_api.h"
4
5 #if defined(__FreeBSD__) || defined(__DragonFly__)
6 #include <sys/types.h>
7 #include <sys/sysctl.h>
8 #endif
9
10 #if !defined(__FreeBSD__) && !defined(__DragonFly__)
11 static char *
read_file(const char * file)12 read_file(const char *file)
13 {
14 FILE *f = fopen(file, "r");
15 size_t len;
16 char buf[4096], *p;
17 if (!f) return NULL;
18 len = fread(buf, 1, sizeof(buf) - 1, f);
19 if (len == 0)
20 {
21 fclose(f);
22 return NULL;
23 }
24 buf[len] = 0;
25 for (p = buf; *p; p++)
26 {
27 if (p[0] == '\n') p[0] = 0;
28 }
29 fclose(f);
30 return strdup(buf);
31 }
32 #endif
33 /*
34 E_API int
35 wizard_page_init(E_Wizard_Page *pg EINA_UNUSED, Eina_Bool *need_xdg_desktops EINA_UNUSED, Eina_Bool *need_xdg_icons EINA_UNUSED)
36 {
37 return 1;
38 }
39
40 E_API int
41 wizard_page_shutdown(E_Wizard_Page *pg EINA_UNUSED)
42 {
43 return 1;
44 }
45 */
46 E_API int
wizard_page_show(E_Wizard_Page * pg EINA_UNUSED)47 wizard_page_show(E_Wizard_Page *pg EINA_UNUSED)
48 {
49 int hav_cpufreq = 0;
50 #if defined(__FreeBSD__) || defined(__DragonFly__)
51 char buf[PATH_MAX];
52 size_t len = 0;
53
54 len = sizeof(buf);
55 #ifdef __DragonFly__
56 /* XXX specific to intel acpi */
57 if (sysctlbyname("hw.acpi.cpu.px_dom0.avail", buf, &len, NULL, 0) == 0)
58 #else
59 if (sysctlbyname("dev.cpu.0.freq_levels", buf, &len, NULL, 0) == 0)
60 #endif
61 hav_cpufreq = 1;
62 #elif defined(__linux__)
63 char *str, *p;
64
65 str = read_file("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies");
66 if (str)
67 {
68 for (p = str; *p; p++)
69 {
70 if (isspace(*p))
71 {
72 hav_cpufreq = 1;
73 break;
74 }
75 }
76 free(str);
77 }
78 #endif
79 if (!hav_cpufreq)
80 {
81 E_Config_Module *em;
82 Eina_List *l;
83
84 EINA_LIST_FOREACH(e_config->modules, l, em)
85 {
86 if (!em->name) continue;
87 if (!strcmp(em->name, "cpufreq"))
88 {
89 e_config->modules = eina_list_remove_list
90 (e_config->modules, l);
91 if (em->name) eina_stringshare_del(em->name);
92 free(em);
93 break;
94 }
95 }
96 e_config_save_queue();
97 }
98 return 0; /* 1 == show ui, and wait for user, 0 == just continue */
99 }
100 /*
101 E_API int
102 wizard_page_hide(E_Wizard_Page *pg EINA_UNUSED)
103 {
104 return 1;
105 }
106
107 E_API int
108 wizard_page_apply(E_Wizard_Page *pg EINA_UNUSED)
109 {
110 return 1;
111 }
112 */
113