aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--trayfreq.c2
-rw-r--r--trayfreq_set/trayfreq_set.c28
2 files changed, 22 insertions, 8 deletions
diff --git a/trayfreq.c b/trayfreq.c
index f8b0cc8..ec82705 100644
--- a/trayfreq.c
+++ b/trayfreq.c
@@ -39,6 +39,8 @@ void config_init()
gboolean home_config_exists;
config.key_file = NULL;
+ printf("Battery governor: %s",_DEFAULT_BAT_GOV);
+
config.file_name = g_strconcat(getenv("HOME"), "/.trayfreq.config", NULL);
// Check if ~/.trayfreq.config exists
diff --git a/trayfreq_set/trayfreq_set.c b/trayfreq_set/trayfreq_set.c
index 083d993..d90717a 100644
--- a/trayfreq_set/trayfreq_set.c
+++ b/trayfreq_set/trayfreq_set.c
@@ -29,8 +29,11 @@ void set_freq_max(char* freq, char* core)
sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_max_freq", core);
FILE* fd = fopen(file_path, "w");
- fprintf(fd, freq);
- fclose(fd);
+ if (fd)
+ {
+ fprintf(fd, freq);
+ fclose(fd);
+ }
}
void set_freq_min(char* freq, char* core)
@@ -39,8 +42,11 @@ void set_freq_min(char* freq, char* core)
sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_min_freq", core);
FILE* fd = fopen(file_path, "w");
- fprintf(fd, freq);
- fclose(fd);
+ if (fd)
+ {
+ fprintf(fd, freq);
+ fclose(fd);
+ }
}
static void set_speed(char* freq, char* core)
@@ -49,8 +55,11 @@ static void set_speed(char* freq, char* core)
sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_setspeed", core);
FILE* fd = fopen(file_path, "w");
- fprintf(fd, freq);
- fclose(fd);
+ if (fd)
+ {
+ fprintf(fd, freq);
+ fclose(fd);
+ }
}
void set_gov(char* gov, char* core)
@@ -59,8 +68,11 @@ void set_gov(char* gov, char* core)
sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_governor", core);
FILE* fd = fopen(file_path, "w");
- fprintf(fd, gov);
- fclose(fd);
+ if (fd)
+ {
+ fprintf(fd, gov);
+ fclose(fd);
+ }
}
void set_freq(char* freq, char* core)