@ -0,0 +1,421 @@ |
||||
images { |
||||
image: "e17_cpufreq_freq00.png" COMP; |
||||
image: "e17_cpufreq_freq01.png" COMP; |
||||
image: "e17_cpufreq_freq02.png" COMP; |
||||
image: "e17_cpufreq_freq03.png" COMP; |
||||
image: "e17_cpufreq_freq04.png" COMP; |
||||
image: "e17_cpufreq_freq05.png" COMP; |
||||
image: "e17_cpufreq_freq06.png" COMP; |
||||
image: "e17_cpufreq_freq07.png" COMP; |
||||
image: "e17_cpufreq_freq08.png" COMP; |
||||
image: "e17_cpufreq_freq09.png" COMP; |
||||
image: "e17_cpufreq_freq10.png" COMP; |
||||
image: "e17_cpufreq_increase1.png" COMP; |
||||
image: "e17_cpufreq_increase2.png" COMP; |
||||
image: "e17_cpufreq_decrease1.png" COMP; |
||||
image: "e17_cpufreq_decrease2.png" COMP; |
||||
image: "e17_cpufreq_cpu1.png" COMP; |
||||
image: "e17_cpufreq_cpu2.png" COMP; |
||||
} |
||||
|
||||
group { |
||||
name: "modules/cpufreq/main"; |
||||
min: 4 4; |
||||
max: 128 128; |
||||
|
||||
script { |
||||
public available_frequencies; |
||||
public available_governors; |
||||
|
||||
public message(Msg_Type:type, id, ...) { |
||||
if ((type == MSG_INT_SET) && (id == 1)) { |
||||
while (count(available_frequencies) > 0) { |
||||
remove(available_frequencies, 0); |
||||
} |
||||
for (new i = 2; i < numargs(); i++) { |
||||
append_int(available_frequencies, getarg(i)); |
||||
} |
||||
} else if ((type == MSG_STRING_SET) && (id == 2)) { |
||||
new text[100]; |
||||
|
||||
while (count(available_governors) > 0) { |
||||
remove(available_governors, 0); |
||||
} |
||||
|
||||
for (new i = 2; i < numargs(); i++) { |
||||
snprintf(text, 100, "%s", getarg(i)); |
||||
append_str(available_governors, text); |
||||
} |
||||
} else if ((type == MSG_INT_SET) && (id == 3)) { |
||||
new f = getarg(2); |
||||
new use_buttons = getarg(3); |
||||
new Float:freq, Float:min_freq, Float:max_freq; |
||||
new text[100]; |
||||
|
||||
freq = f; |
||||
min_freq = fetch_int(available_frequencies, 0); |
||||
max_freq = fetch_int(available_frequencies, |
||||
count(available_frequencies) - 1); |
||||
|
||||
freq = (freq - min_freq) / (max_freq - min_freq); |
||||
set_state(PART:"meter", "default", freq); |
||||
|
||||
if (f < 1000000) { |
||||
snprintf(text, 100, "%i Mhz", f / 1000); |
||||
} else { |
||||
snprintf(text, 100, "%i.%i Ghz", f / 1000000, |
||||
(f % 1000000) / 100000); |
||||
} |
||||
set_text(PART:"readout", text); |
||||
|
||||
if (use_buttons == 0) { |
||||
set_state(PART:"increase_button", "inactive", 0.0); |
||||
set_state(PART:"decrease_button", "inactive", 0.0); |
||||
set_state(PART:"increase", "inactive", 0.0); |
||||
set_state(PART:"decrease", "inactive", 0.0); |
||||
} else { |
||||
set_state(PART:"increase_button", "default", 0.0); |
||||
set_state(PART:"decrease_button", "default", 0.0); |
||||
set_state(PART:"increase", "default", 0.0); |
||||
set_state(PART:"decrease", "default", 0.0); |
||||
} |
||||
} else if((type == MSG_STRING) && (id == 4)) { |
||||
new text[100]; |
||||
snprintf(text, 100, "%s", getarg(2)); |
||||
/* |
||||
if (!strcmp(text, "performance") || !strcmp(text, "powersave") || |
||||
!strcmp(text, "userspace") || !strcmp(text, "ondemand")) { |
||||
set_state(PART:"governor", text, 0.0); |
||||
set_state(PART:"governorbackground", text, 0.0); |
||||
} else { |
||||
set_state(PART:"governor", "default", 0.0); |
||||
set_state(PART:"governorbackground", "default", 0.0); |
||||
} |
||||
*/ |
||||
} |
||||
} |
||||
} |
||||
|
||||
parts { |
||||
part { |
||||
name: "meter"; |
||||
type: IMAGE; |
||||
|
||||
description { |
||||
state: "default" 0.0; |
||||
rel1 { |
||||
relative: 0.078125 0.0; |
||||
offset: 0 0; |
||||
} |
||||
rel2 { |
||||
relative: 0.921875 0.375; |
||||
offset: -1 -1; |
||||
} |
||||
image { |
||||
normal: "e17_cpufreq_freq00.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "default" 0.1; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_freq01.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "default" 0.2; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_freq02.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "default" 0.3; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_freq03.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "default" 0.4; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_freq04.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "default" 0.5; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_freq05.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "default" 0.6; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_freq06.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "default" 0.7; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_freq07.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "default" 0.8; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_freq08.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "default" 0.9; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_freq09.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "default" 1.00; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_freq10.png"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
part { |
||||
name: "decrease_button"; |
||||
type: IMAGE; |
||||
mouse_events: 1; |
||||
|
||||
description { |
||||
state: "default" 0.0; |
||||
rel1 { |
||||
relative: 0.0 0.; |
||||
offset: 0 0; |
||||
} |
||||
rel2 { |
||||
relative: 1.0 0.375; |
||||
offset: -1 -1; |
||||
} |
||||
image { |
||||
normal: "e17_cpufreq_decrease1.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "clicked" 0.0; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_decrease2.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "inactive" 0.0; |
||||
inherit: "default" 0.0; |
||||
visible: 0; |
||||
} |
||||
} |
||||
|
||||
part { |
||||
name: "increase_button"; |
||||
type: IMAGE; |
||||
mouse_events: 1; |
||||
|
||||
description { |
||||
state: "default" 0.0; |
||||
rel1 { |
||||
relative: 0.0 0.; |
||||
offset: 0 0; |
||||
} |
||||
rel2 { |
||||
relative: 1.0 0.375; |
||||
offset: -1 -1; |
||||
} |
||||
image { |
||||
normal: "e17_cpufreq_increase1.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "clicked" 0.0; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_increase2.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "inactive" 0.0; |
||||
inherit: "default" 0.0; |
||||
visible: 0; |
||||
} |
||||
} |
||||
|
||||
part { |
||||
name: "cpu"; |
||||
type: IMAGE; |
||||
mouse_events: 1; |
||||
|
||||
description { |
||||
state: "default" 0.0; |
||||
rel1 { |
||||
relative: 0.1953125 0.3671875; |
||||
offset: 0 0; |
||||
} |
||||
rel2 { |
||||
relative: 0.8359375 1.0; |
||||
offset: -1 -1; |
||||
} |
||||
image { |
||||
normal: "e17_cpufreq_cpu1.png"; |
||||
} |
||||
} |
||||
description { |
||||
state: "clicked" 0.0; |
||||
inherit: "default" 0.0; |
||||
image { |
||||
normal: "e17_cpufreq_cpu2.png"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
part { |
||||
name: "readout"; |
||||
type: TEXT; |
||||
effect: SOFT_SHADOW; |
||||
mouse_events: 0; |
||||
description { |
||||
state: "default" 0.0; |
||||
rel1 { |
||||
relative: 0.5 0.7; |
||||
offset: 0 0; |
||||
} |
||||
rel2 { |
||||
relative: 0.5 0.7; |
||||
offset: 0 0; |
||||
} |
||||
color: 255 255 255 255; |
||||
color3: 0 0 0 32; |
||||
text { |
||||
text: "??? Ghz"; |
||||
font: "Edje Vera"; |
||||
size: 7; |
||||
align: 0.5 0.5; |
||||
min: 1 1; |
||||
} |
||||
} |
||||
} |
||||
|
||||
part { |
||||
name: "decrease"; |
||||
type: RECT; |
||||
description { |
||||
state: "default" 0.0; |
||||
visible: 1; |
||||
rel1 { |
||||
relative: 0.0 0.0; |
||||
offset: 0 0; |
||||
} |
||||
rel2 { |
||||
relative: 0.5 0.375; |
||||
offset: -1 -1; |
||||
} |
||||
color: 0 0 0 0; |
||||
} |
||||
description { |
||||
state: "inactive" 0.0; |
||||
inherit: "default" 0.0; |
||||
visible: 0; |
||||
} |
||||
} |
||||
|
||||
part { |
||||
name: "increase"; |
||||
type: RECT; |
||||
description { |
||||
state: "default" 0.0; |
||||
visible: 1; |
||||
rel1 { |
||||
relative: 0.5 0.0; |
||||
offset: 0 0; |
||||
} |
||||
rel2 { |
||||
relative: 1.0 0.375; |
||||
offset: -1 -1; |
||||
} |
||||
color: 0 0 0 0; |
||||
} |
||||
description { |
||||
state: "inactive" 0.0; |
||||
inherit: "default" 0.0; |
||||
visible: 0; |
||||
} |
||||
} |
||||
|
||||
} /* end parts */ |
||||
|
||||
programs { |
||||
program { |
||||
name: "next_governor"; |
||||
signal: "mouse,down,1"; |
||||
source: "cpu"; |
||||
action: SIGNAL_EMIT "next_governor" "governor"; |
||||
} |
||||
program { |
||||
name: "next_governor2"; |
||||
signal: "mouse,down,1"; |
||||
source: "cpu"; |
||||
action: STATE_SET "clicked" 0.0; |
||||
target: "cpu"; |
||||
} |
||||
program { |
||||
name: "next_governor3"; |
||||
signal: "mouse,up,1"; |
||||
source: "cpu"; |
||||
action: STATE_SET "default" 0.0; |
||||
target: "cpu"; |
||||
} |
||||
program { |
||||
name: "increase_frequency"; |
||||
signal: "mouse,down,1"; |
||||
source: "increase"; |
||||
action: SIGNAL_EMIT "increase_frequency" "frequency"; |
||||
} |
||||
program { |
||||
name: "increase_frequency2"; |
||||
signal: "mouse,down,1"; |
||||
source: "increase"; |
||||
action: STATE_SET "clicked" 0.0; |
||||
target: "increase_button"; |
||||
} |
||||
program { |
||||
name: "increase_frequency3"; |
||||
signal: "mouse,up,1"; |
||||
source: "increase"; |
||||
action: STATE_SET "default" 0.0; |
||||
target: "increase_button"; |
||||
} |
||||
program { |
||||
name: "decrease_frequency"; |
||||
signal: "mouse,down,1"; |
||||
source: "decrease"; |
||||
action: SIGNAL_EMIT "decrease_frequency" "frequency"; |
||||
} |
||||
program { |
||||
name: "decrease_frequency2"; |
||||
signal: "mouse,down,1"; |
||||
source: "decrease"; |
||||
action: STATE_SET "clicked" 0.0; |
||||
target: "decrease_button"; |
||||
} |
||||
program { |
||||
name: "decrease_frequency3"; |
||||
signal: "mouse,up,1"; |
||||
source: "decrease"; |
||||
action: STATE_SET "default" 0.0; |
||||
target: "decrease_button"; |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 4.8 KiB |
@ -0,0 +1,47 @@ |
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MODULE = cpufreq
|
||||
|
||||
# data files for the module
|
||||
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
|
||||
files_DATA = \
|
||||
module_icon.png |
||||
freqsetdir = $(libdir)/enlightenment/modules/$(MODULE)
|
||||
freqset_DATA = \
|
||||
freqset |
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
||||
|
||||
# the module .so file
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
-I$(includedir) \
|
||||
-I$(top_srcdir)$(MODULE) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/modules \
|
||||
@e_cflags@
|
||||
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = e_mod_main.c \
|
||||
e_mod_main.h
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
all-local: freqset$(EXEEXT) |
||||
installed_su = $(pkgdir)/freqset$(EXEEXT)
|
||||
setuid_root_mode = a=rx,u+s
|
||||
|
||||
INSTALL_SU = \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install install -m $(setuid_root_mode) freqset $(installed_su)"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install install -m $(setuid_root_mode) freqset $(installed_su); \
|
||||
#echo " chown root $(installed_su)"; \
|
||||
#chown root $(installed_su); \
|
||||
#echo " chmod $(setuid_root_mode) $(installed_su)"; \
|
||||
#chmod $(setuid_root_mode) $(installed_su)
|
||||
|
||||
install-freqsetDATA: freqset$(EXEEXT) |
||||
@$(INSTALL_SU)
|
||||
|
||||
noinst_PROGRAMS = freqset
|
||||
freqset_SOURCES = freqset.c
|
@ -0,0 +1,69 @@ |
||||
#ifndef E_MOD_MAIN_H |
||||
#define E_MOD_MAIN_H |
||||
|
||||
#include <e.h> |
||||
#include <Evas.h> |
||||
|
||||
typedef struct _Status Status; |
||||
typedef struct _Config Config; |
||||
typedef struct _Config_Face Config_Face; |
||||
typedef struct _Cpufreq Cpufreq; |
||||
typedef struct _Cpufreq_Face Cpufreq_Face; |
||||
|
||||
struct _Status |
||||
{ |
||||
Evas_List *frequencies; |
||||
Evas_List *governors; |
||||
int cur_frequency; |
||||
int can_set_frequency; |
||||
char *cur_governor; |
||||
}; |
||||
|
||||
struct _Config |
||||
{ |
||||
double poll_time; |
||||
Evas_List *faces; |
||||
}; |
||||
|
||||
struct _Config_Face |
||||
{ |
||||
unsigned char enabled; |
||||
}; |
||||
|
||||
struct _Cpufreq |
||||
{ |
||||
E_Menu *config_menu; |
||||
E_Menu *config_menu_poll; |
||||
E_Menu *menu_governor; |
||||
E_Menu *menu_frequency; |
||||
Evas_List *faces; |
||||
|
||||
Config *conf; |
||||
Status *status; |
||||
|
||||
char *set_exe_path; |
||||
|
||||
Ecore_Timer *frequency_check_timer;
|
||||
}; |
||||
|
||||
struct _Cpufreq_Face |
||||
{ |
||||
E_Container *con; |
||||
|
||||
E_Menu *menu; |
||||
Config_Face *conf; |
||||
Cpufreq *owner; |
||||
|
||||
Evas_Object *freq_object; |
||||
Evas_Object *event_object; |
||||
|
||||
E_Gadman_Client *gmc; |
||||
}; |
||||
|
||||
EAPI void *init (E_Module *module); |
||||
EAPI int shutdown (E_Module *module); |
||||
EAPI int save (E_Module *module); |
||||
EAPI int info (E_Module *module); |
||||
EAPI int about (E_Module *module); |
||||
|
||||
#endif |
@ -0,0 +1,57 @@ |
||||
#include <stdio.h> |
||||
|
||||
int |
||||
main(int argc, char *argv[]) |
||||
{ |
||||
int new_frequency = 0; |
||||
char *new_governor = NULL; |
||||
char buf[4096]; |
||||
FILE *f; |
||||
|
||||
if (argc != 3) |
||||
{ |
||||
fprintf(stderr, "Invalid command. Syntax:\n"); |
||||
fprintf(stderr, "\tfreqset <frequency|governor> <freq-level|governor-name>\n"); |
||||
return 1; |
||||
} |
||||
|
||||
if (seteuid(0)) |
||||
{ |
||||
fprintf(stderr, "Unable to assume root privileges\n"); |
||||
} |
||||
|
||||
if (!strcmp(argv[1], "frequency")) |
||||
{ |
||||
new_frequency = atoi(argv[2]); |
||||
|
||||
f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed", "w"); |
||||
if (!f) |
||||
{ |
||||
fprintf(stderr, "Unable to open frequency interface for writing.\n"); |
||||
return 1; |
||||
} |
||||
fprintf(f, "%d\n", new_frequency); |
||||
fclose(f); |
||||
|
||||
return 0; |
||||
} |
||||
else if (!strcmp(argv[1], "governor")) |
||||
{ |
||||
f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "w"); |
||||
if (!f) |
||||
{ |
||||
fprintf(stderr, "Unable to open governor interface for writing.\n"); |
||||
return 1; |
||||
} |
||||
fprintf(f, "%s\n", argv[2]); |
||||
fclose(f); |
||||
|
||||
return 0; |
||||
} |
||||
else |
||||
{ |
||||
fprintf(stderr, "Unknown command.\n"); |
||||
return 1; |
||||
} |
||||
seteuid(-1); |
||||
} |
After Width: | Height: | Size: 795 B |