aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid <dbphillipsnz@gmail.com>2014-02-13 19:32:49 +1300
committerDavid <dbphillipsnz@gmail.com>2014-02-13 19:32:49 +1300
commitf01a21b103f655652aa58dcbd2ffbae1413e01df (patch)
treeae2db9898000576b922333395907afcc8c9dc495
parent68f5774cb6a8a8a31f6f530b99fdcb7f1c5695fa (diff)
downloadparamano-f01a21b103f655652aa58dcbd2ffbae1413e01df.tar.xz
Updated readme
-rw-r--r--README10
-rw-r--r--src/getgov.c43
-rw-r--r--src/tray.c384
-rw-r--r--src/trayfreq.c34
-rw-r--r--src/trayfreq_set.c148
-rw-r--r--src/trayfreq_set_interface.c24
-rw-r--r--src/utilities.c22
-rw-r--r--src/widget_manager.c14
8 files changed, 309 insertions, 370 deletions
diff --git a/README b/README
index 2510096..ee55689 100644
--- a/README
+++ b/README
@@ -1,6 +1,4 @@
-To set the frequency or governor of the CPU, you must have root
-permissions. To avoid having to run trayfreq as root since it
-constantly runs, when you install, the SUID bit of trayfreq-set is
-changed so that it is ran as root without needing a password. To
-disable this, append --disable-setsuid when running ./configure
-and run trayfreq as root.
+This machine is out of order
+===
+
+This code's mostly the old and stale stuff from the original project. Don't expect this code to be working yet :) \ No newline at end of file
diff --git a/src/getgov.c b/src/getgov.c
index 9d9620b..48b41c4 100644
--- a/src/getgov.c
+++ b/src/getgov.c
@@ -29,30 +29,29 @@ gint NUMBER_OF_AVAILABLE_GOVERNORS;
void gg_init()
{
- gchar gov_string[500];
-
- int i = 0;
- int j = 0;
- for(i = 0; i < gc_number(); ++i)
- {
- memset(gov_string, '\0', 500);
- gg_available(i, gov_string, 500);
-
- /* go through every governor in gov_string */
- j = 0;
- gchar* curr = &gov_string[0];
- gchar* end_of_curr = g_strstr_len(curr, strlen(curr), " ");
- while(end_of_curr)
+ gchar gov_string[500];
+ int i = 0;
+ int j = 0;
+ for(i = 0; i < gc_number(); ++i)
{
- memset(AVAILABLE_GOVERNORS[i][j], '\0', 13);
- memmove(AVAILABLE_GOVERNORS[i][j], curr, end_of_curr - curr);
-
- curr = end_of_curr+1;
- end_of_curr = g_strstr_len(curr, strlen(curr), " ");
- ++j;
+ memset(gov_string, '\0', 500);
+ gg_available(i, gov_string, 500);
+
+ /* go through every governor in gov_string */
+ j = 0;
+ gchar* curr = &gov_string[0];
+ gchar* end_of_curr = g_strstr_len(curr, strlen(curr), " ");
+ while(end_of_curr)
+ {
+ memset(AVAILABLE_GOVERNORS[i][j], '\0', 13);
+ memmove(AVAILABLE_GOVERNORS[i][j], curr, end_of_curr - curr);
+
+ curr = end_of_curr+1;
+ end_of_curr = g_strstr_len(curr, strlen(curr), " ");
+ ++j;
+ }
}
- }
- NUMBER_OF_AVAILABLE_GOVERNORS = j;
+ NUMBER_OF_AVAILABLE_GOVERNORS = j;
}
int gg_current(int core, char* out, int size)
diff --git a/src/tray.c b/src/tray.c
index 366cbf8..fb65b33 100644
--- a/src/tray.c
+++ b/src/tray.c
@@ -41,314 +41,266 @@ GtkWidget* menu;
GSList* menu_items;
GtkWidget* checked_menu_item;
-static void freq_menu_item_toggled(GtkCheckMenuItem* item,
- gpointer data)
+static void freq_menu_item_toggled(GtkCheckMenuItem* item, gpointer data)
{
- if(gtk_check_menu_item_get_active(item))
- {
- checked_menu_item = GTK_WIDGET(item);
- gint freq = GPOINTER_TO_INT(data);
- int i = 0;
- for(i = 0; i < gc_number(); ++i)
+ if(gtk_check_menu_item_get_active(item))
{
- si_freq(freq, i);
+ checked_menu_item = GTK_WIDGET(item);
+ gint freq = GPOINTER_TO_INT(data);
+ int i = 0;
+ for(i = 0; i < gc_number(); ++i)
+ si_freq(freq, i);
}
- }
}
-static void gov_menu_item_toggled(GtkCheckMenuItem* item,
- gpointer data)
+static void gov_menu_item_toggled(GtkCheckMenuItem* item, gpointer data)
{
- if(gtk_check_menu_item_get_active(item))
- {
- checked_menu_item = GTK_WIDGET(item);
- gchar* gov = (gchar*)data;
- int i = 0;
- for(i = 0; i < gc_number(); ++i)
+ if(gtk_check_menu_item_get_active(item))
{
- si_gov(gov, i);
+ checked_menu_item = GTK_WIDGET(item);
+ gchar* gov = (gchar*)data;
+ int i = 0;
+ for(i = 0; i < gc_number(); ++i)
+ si_gov(gov, i);
}
- }
}
static gboolean governor_exists(gchar* governor)
{
- int i = 0;
- for(i = 0; i < gf_number(); ++i)
- {
- if(g_strcmp0(governor, gg_gov(0, i)) == 0)
- return TRUE;
- }
- return FALSE;
+ int i = 0;
+ for(i = 0; i < gf_number(); ++i)
+ {
+ if(g_strcmp0(governor, gg_gov(0, i)) == 0)
+ return TRUE;
+ }
+ return FALSE;
}
static void remove_menu_item(GtkWidget* menu_item, gpointer data)
{
- gtk_widget_destroy(menu_item);
+ gtk_widget_destroy(menu_item);
}
static void tray_clear_menu()
{
- GtkContainer* cont = GTK_CONTAINER(menu);
- gtk_container_foreach(cont, remove_menu_item, NULL);
- menu_items = NULL;
+ GtkContainer* cont = GTK_CONTAINER(menu);
+ gtk_container_foreach(cont, remove_menu_item, NULL);
+ menu_items = NULL;
}
static void tray_init_menu()
{
- menu = gtk_menu_new();
+ menu = gtk_menu_new();
}
static void tray_generate_menu()
{
- tray_clear_menu();
- gg_init();
-
- gchar label[20];
- int i = 0;
+ tray_clear_menu();
+ gg_init();
- gchar current_governor[20];
- memset(current_governor, '\0', 20);
- gg_current(0, current_governor, 20);
+ gchar label[20];
+ int i = 0;
- gint current_frequency = gf_current(0);
+ gchar current_governor[20];
+ memset(current_governor, '\0', 20);
+ gg_current(0, current_governor, 20);
- /* append the frequencies */
- for(i = 0; i < gf_number(); ++i)
- {
- memset(label, '\0', 20);
- gf_get_frequency_label(gf_freqi(0, i), label);
+ gint current_frequency = gf_current(0);
- GtkWidget* item = gtk_radio_menu_item_new_with_label(menu_items, label);
- menu_items = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM (item));
-
- if(g_strcmp0(current_governor, "userspace") == 0 && gf_freqi(0, i) == current_frequency)
- {
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
- }
-
- g_signal_connect(G_OBJECT(item), "toggled", GTK_SIGNAL_FUNC(freq_menu_item_toggled), GINT_TO_POINTER(gf_freqi(0, i)));
+ /* append the frequencies */
+ for(i = 0; i < gf_number(); ++i)
+ {
+ memset(label, '\0', 20);
+ gf_get_frequency_label(gf_freqi(0, i), label);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- }
+ GtkWidget* item = gtk_radio_menu_item_new_with_label(menu_items, label);
+ menu_items = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM (item));
- /* append the seperator */
- GtkWidget* seperator = gtk_separator_menu_item_new();
- gtk_menu_append(menu, seperator);
+ if(g_strcmp0(current_governor, "userspace") == 0 && gf_freqi(0, i) == current_frequency)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
- /* append the governors*/
- for(i = 0; i < gg_number(); ++i)
- {
- if(g_strcmp0(gg_gov(0, i), "userspace") == 0)
- continue;
+ g_signal_connect(G_OBJECT(item), "toggled", GTK_SIGNAL_FUNC(freq_menu_item_toggled), GINT_TO_POINTER(gf_freqi(0, i)));
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ }
- GtkWidget* item = gtk_radio_menu_item_new_with_label(menu_items, gg_gov(0, i));
- menu_items = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM (item));
+ /* append the seperator */
+ GtkWidget* seperator = gtk_separator_menu_item_new();
+ gtk_menu_append(menu, seperator);
- if(g_strcmp0(gg_gov(0, i), current_governor) == 0)
- {
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
- }
+ /* append the governors*/
+ for(i = 0; i < gg_number(); ++i)
+ {
+ if(g_strcmp0(gg_gov(0, i), "userspace") == 0)
+ continue;
- g_signal_connect(G_OBJECT(item), "toggled", GTK_SIGNAL_FUNC(gov_menu_item_toggled), gg_gov(0, i));
+ GtkWidget* item = gtk_radio_menu_item_new_with_label(menu_items, gg_gov(0, i));
+ menu_items = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM (item));
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- }
+ if(g_strcmp0(gg_gov(0, i), current_governor) == 0)
+ {
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
+ }
- gtk_widget_show_all(menu);
+ g_signal_connect(G_OBJECT(item), "toggled", GTK_SIGNAL_FUNC(gov_menu_item_toggled), gg_gov(0, i));
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ }
+ gtk_widget_show_all(menu);
}
-static gboolean update_tooltip(GtkStatusIcon* status_icon,
- gint x,
- gint y,
- gboolean keyboard_mode,
- GtkTooltip* tooltip,
- gpointer data)
+static gboolean update_tooltip(GtkStatusIcon* status_icon,gint x,gint y,gboolean keyboard_mode,GtkTooltip* tooltip,gpointer data)
{
- gchar msg[500];
- gchar current_governer[20];
- gchar label[20];
- int i = 0;
+ gchar msg[500];
+ gchar current_governer[20];
+ gchar label[20];
+ int i = 0;
- memset(msg, '\0', 500);
- memset(current_governer, '\0', 20);
+ memset(msg, '\0', 500);
+ memset(current_governer, '\0', 20);
- /* change governor based on battery state */
- /* battery is discharging */
- if ((state == 0 || state == 1) && gb_discharging ())
- {
- state = 2;
-
- if(def_get_bat_gov ())
+ /* change governor based on battery state */
+ /* battery is discharging */
+ if ((state == 0 || state == 1) && gb_discharging ())
{
- for(i = 0; i < gc_number(); ++i)
- {
- si_gov(def_get_bat_gov (), i);
- }
+ state = 2;
+ if(def_get_bat_gov ())
+ {
+ for(i = 0; i < gc_number(); ++i)
+ si_gov(def_get_bat_gov (), i);
+ }
}
- }
- /* battery is now charging (on ac) */
- else if ((state == 0 || state == 2) && gb_charging ())
- {
- state = 1;
-
- if(def_get_ac_gov ())
+ /* battery is now charging (on ac) */
+ else if ((state == 0 || state == 2) && gb_charging ())
{
- for(i = 0; i < gc_number(); ++i)
- {
- si_gov(def_get_ac_gov (), i);
- }
+ state = 1;
+ if(def_get_ac_gov ())
+ {
+ for(i = 0; i < gc_number(); ++i)
+ si_gov(def_get_ac_gov (), i);
+ }
}
- }
-
+ gg_current(0, current_governer, 20);
+ sprintf(msg, "%sGovernor: %s\n", msg, current_governer);
+ for(i = 0; i < gc_number(); ++i)
+ {
+ memset(label, '\0', 20);
+ gf_get_frequency_label(gf_current(i), label);
+ sprintf(msg, "%sCPU%i: %s%s", msg, i, label, i == gc_number()-1 ? "" : "\n");
+ }
- gg_current(0, current_governer, 20);
- sprintf(msg, "%sGovernor: %s\n", msg, current_governer);
-
- for(i = 0; i < gc_number(); ++i)
- {
- memset(label, '\0', 20);
- gf_get_frequency_label(gf_current(i), label);
- sprintf(msg, "%sCPU%i: %s%s", msg, i, label, i == gc_number()-1 ? "" : "\n");
- }
-
- tray_set_tooltip(msg);
- gtk_tooltip_set_text(tooltip, tooltip_text);
+ tray_set_tooltip(msg);
+ gtk_tooltip_set_text(tooltip, tooltip_text);
- return TRUE;
-};
+ return TRUE;
+}
-static void popup_menu(GtkStatusIcon* statuc_icon,
- guint button,
- guint activate_time,
- gpointer data)
+static void popup_menu(GtkStatusIcon* statuc_icon,guint button,guint activate_time,gpointer data)
{
- tray_generate_menu();
- gtk_menu_popup(GTK_MENU(menu),
- NULL,
- NULL,
- gtk_status_icon_position_menu,
- tray,
- button,
- activate_time);
+ tray_generate_menu();
+ gtk_menu_popup(GTK_MENU(menu),NULL,NULL,gtk_status_icon_position_menu,tray,button,activate_time);
}
-static void activate(GtkStatusIcon* statuc_icon,
- gpointer data)
+static void activate(GtkStatusIcon* statuc_icon,gpointer data)
{
- gchar* def_prog = def_get_prog();
- if(def_prog)
- g_spawn_command_line_async (def_prog, NULL);
+ gchar* def_prog = def_get_prog();
+ if(def_prog)
+ g_spawn_command_line_async (def_prog, NULL);
}
static gboolean update_icon(gpointer user_data)
{
- tray_update_icon_percent();
+ tray_update_icon_percent();
}
void tray_init()
{
- // set defaults
- gchar* def_gov = def_get_gov();
- int i = 0;
- if(def_gov)
- {
- for(i = 0; i < gc_number(); ++i)
+ // set defaults
+ gchar* def_gov = def_get_gov();
+ int i = 0;
+ if(def_gov)
{
- si_gov(def_gov, i);
+ for(i = 0; i < gc_number(); ++i)
+ {
+ si_gov(def_gov, i);
+ }
+ } else {
+ for(i = 0; i < gc_number(); ++i)
+ si_gov("ondemand", i);
}
- }
- else
- {
- for(i = 0; i < gc_number(); ++i)
+ gchar* def_freq = def_get_freq();
+ if(def_freq)
{
- si_gov("ondemand", i);
+ for(i = 0; i < gc_number(); ++i)
+ {
+ si_freq(atoi(def_freq), i);
+ }
}
- }
- gchar* def_freq = def_get_freq();
- if(def_freq)
- {
- for(i = 0; i < gc_number(); ++i)
- {
- si_freq(atoi(def_freq), i);
- }
- }
-
- tray = gtk_status_icon_new();
- gchar* icon_file = g_strconcat(util_get_prefix(), "/share/trayfreq/cpufreq-0.png", NULL);
- gtk_status_icon_set_from_file(tray, icon_file);
- gtk_status_icon_set_has_tooltip (tray, TRUE);
- g_signal_connect(G_OBJECT(tray), "query-tooltip", GTK_SIGNAL_FUNC(update_tooltip), NULL);
- g_signal_connect(G_OBJECT(tray), "popup-menu", GTK_SIGNAL_FUNC(popup_menu), NULL);
- g_signal_connect(G_OBJECT(tray), "activate", GTK_SIGNAL_FUNC(activate), NULL);
- gtk_timeout_add(1000, update_icon, NULL);
- tray_init_menu();
+
+ tray = gtk_status_icon_new();
+ gchar* icon_file = g_strconcat(util_get_prefix(), "/share/trayfreq/cpufreq-0.png", NULL);
+ gtk_status_icon_set_from_file(tray, icon_file);
+ gtk_status_icon_set_has_tooltip (tray, TRUE);
+ g_signal_connect(G_OBJECT(tray), "query-tooltip", GTK_SIGNAL_FUNC(update_tooltip), NULL);
+ g_signal_connect(G_OBJECT(tray), "popup-menu", GTK_SIGNAL_FUNC(popup_menu), NULL);
+ g_signal_connect(G_OBJECT(tray), "activate", GTK_SIGNAL_FUNC(activate), NULL);
+ gtk_timeout_add(1000, update_icon, NULL);
+ tray_init_menu();
}
void tray_set_tooltip(const gchar* msg)
{
- memset(tooltip_text, '\0', TOOLTIP_TEXT_SIZE);
- memmove(tooltip_text, msg, strlen(msg));
+ memset(tooltip_text, '\0', TOOLTIP_TEXT_SIZE);
+ memmove(tooltip_text, msg, strlen(msg));
}
void tray_update_icon_percent()
{
- gulong max_frequency = gf_freqi(0, 0);
-
- /* The percentange should only be 25, 50, 75, or 100, so we need to
- round to one of these numbers. */
- gint percent = (gf_current(0) * 100)/max_frequency;
- gint adjusted_percent = 0;
-
- if(percent == 100)
- {
- adjusted_percent = 100;
- }
- else if(percent >= 65.5)
- {
- adjusted_percent = 75;
- }
- else if(percent >= 37.5)
- {
- adjusted_percent = 50;
- }
- else if(percent >= 12.5)
- {
- adjusted_percent = 25;
- }
- else
- {
- adjusted_percent = 0;
- }
-
- /* convert the int to a string */
- gchar adjusted_percent_string[] = {'\0', '\0', '\0', '\0'};
- sprintf(adjusted_percent_string, "%i", adjusted_percent);
-
- gchar* file = g_strconcat(util_get_prefix(), "/share/trayfreq/cpufreq-", adjusted_percent_string, ".png", NULL);
- gtk_status_icon_set_from_file(tray, file);
-
- g_free(file);
+ gulong max_frequency = gf_freqi(0, 0);
+
+ /* The percentange should only be 25, 50, 75, or 100, so we need to
+ round to one of these numbers. */
+ gint percent = (gf_current(0) * 100)/max_frequency;
+ gint adjusted_percent = 0;
+
+ if(percent == 100) {
+ adjusted_percent = 100;
+ } else if(percent >= 65.5) {
+ adjusted_percent = 75;
+ } else if(percent >= 37.5) {
+ adjusted_percent = 50;
+ } else if(percent >= 12.5) {
+ adjusted_percent = 25;
+ } else {
+ adjusted_percent = 0;
+ }
+
+ /* convert the int to a string */
+ gchar adjusted_percent_string[] = {'\0', '\0', '\0', '\0'};
+ sprintf(adjusted_percent_string, "%i", adjusted_percent);
+
+ gchar* file = g_strconcat(util_get_prefix(), "/share/trayfreq/cpufreq-", adjusted_percent_string, ".png", NULL);
+ gtk_status_icon_set_from_file(tray, file);
+
+ g_free(file);
}
void tray_show()
{
- gtk_status_icon_set_visible(tray, TRUE);
+ gtk_status_icon_set_visible(tray, TRUE);
}
void tray_hide()
{
- gtk_status_icon_set_visible(tray, FALSE);
+ gtk_status_icon_set_visible(tray, FALSE);
}
gboolean tray_visible()
{
- return gtk_status_icon_get_visible(tray);
+ return gtk_status_icon_get_visible(tray);
}
gboolean tray_embedded()
{
- return gtk_status_icon_is_embedded(tray);
+ return gtk_status_icon_is_embedded(tray);
}
diff --git a/src/trayfreq.c b/src/trayfreq.c
index 4db2444..2b65af5 100644
--- a/src/trayfreq.c
+++ b/src/trayfreq.c
@@ -34,27 +34,25 @@ static gboolean SHOW_BATTERY = TRUE;
void config_init()
{
- struct config_file config;
- gboolean home_config_exists = TRUE;
- config.key_file = NULL;
-
- gchar* home = getenv("HOME");
- config.file_name = g_strconcat(home, "/.trayfreq.config", NULL);
- FILE* fd = fopen(config.file_name, "r");
- if(!fd)
- {
- g_free(config.file_name);
- home_config_exists = FALSE;
- }
- else
- {
- fclose(fd);
+ struct config_file config;
+ gboolean home_config_exists = TRUE;
+ config.key_file = NULL;
+
+ gchar* home = getenv("HOME");
+ config.file_name = g_strconcat(home, "/.trayfreq.config", NULL);
+ FILE* fd = fopen(config.file_name, "r");
+ if(!fd)
+ {
+ g_free(config.file_name);
+ home_config_exists = FALSE;
+ } else {
+ fclose(fd);
}
- if(!home_config_exists)
- config.file_name = g_strconcat(util_get_prefix(), "/share/trayfreq/trayfreq.config", NULL);
+ if(!home_config_exists)
+ config.file_name = g_strconcat(util_get_prefix(), "/share/trayfreq/trayfreq.config", NULL);
- gboolean success = config_open(&config);
+ gboolean success = config_open(&config);
if(!success)
{
diff --git a/src/trayfreq_set.c b/src/trayfreq_set.c
index b1ded2d..1719447 100644
--- a/src/trayfreq_set.c
+++ b/src/trayfreq_set.c
@@ -23,106 +23,98 @@
static void set_freq_max(char* freq, char* core)
{
- char file_path[100];
- sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_max_freq", core);
+ char file_path[100];
+ 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);
+ FILE* fd = fopen(file_path, "w");
+ fprintf(fd, freq);
+ fclose(fd);
}
static void set_freq_min(char* freq, char* core)
{
- char file_path[100];
- sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_min_freq", core);
+ char file_path[100];
+ 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);
+ FILE* fd = fopen(file_path, "w");
+ fprintf(fd, freq);
+ fclose(fd);
}
static void set_speed(char* freq, char* core)
{
- char file_path[100];
- sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_setspeed", core);
+ char file_path[100];
+ sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_setspeed", core);
- FILE* fd = fopen(file_path, "w");
- fprintf(fd, freq);
- fclose(fd);
+ FILE* fd = fopen(file_path, "w");
+ fprintf(fd, freq);
+ fclose(fd);
}
void set_gov(char* gov, char* core)
{
- char file_path[100];
- sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_governor", core);
+ char file_path[100];
+ sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_governor", core);
- FILE* fd = fopen(file_path, "w");
- fprintf(fd, gov);
- fclose(fd);
+ FILE* fd = fopen(file_path, "w");
+ fprintf(fd, gov);
+ fclose(fd);
}
void set_freq(char* freq, char* core)
{
- set_gov("userspace", core);
- set_speed(freq, core);
+ set_gov("userspace", core);
+ set_speed(freq, core);
}
int main(int argc, char *argv[])
{
- gc_init();
- gf_init();
-
- if(!argv[1])
- printf("Use -g to set the governor or -f to set the frequency.\n");
-
- else if(strcmp(argv[1], "-g") == 0)
- {
- if(!argv[2])
- printf("Pass the governor to set after the -g.\n");
- else
- {
- if(!argv[3])
- printf("Use -c to set the core.\n");
-
- else if(strcmp(argv[3], "-c") == 0)
- {
- if(!argv[4])
- printf("Pass the core to set after the -c.\n");
- else
- set_gov(argv[2], argv[4]);
- }
-
- else
- printf("Use -c to set the core.\n");
- }
- }
-
- else if(strcmp(argv[1], "-f") == 0)
- {
- if(!argv[2])
- printf("Pass the frequency to set after the -f.\n");
- else
- {
- if(!argv[3])
- printf("Use -c to set the core.\n");
-
- else if(strcmp(argv[3], "-c") == 0)
- {
- if(!argv[4])
- printf("Pass the core to set after the -c.\n");
- else
- set_freq(argv[2], argv[4]);
- }
-
- else
- printf("Use -c to set the core.\n");
- }
- }
-
- else
- {
- printf("Use -g to set the governor or -f to set the frequency.\n");
- }
-
- return 0;
+ gc_init();
+ gf_init();
+
+ if(!argv[1])
+ {
+ printf("Use -g to set the governor or -f to set the frequency.\n");
+ }
+ else if(strcmp(argv[1], "-g") == 0)
+ {
+ if(!argv[2])
+ printf("Pass the governor to set after the -g.\n");
+ else
+ {
+ if(!argv[3])
+ printf("Use -c to set the core.\n");
+ else if(strcmp(argv[3], "-c") == 0)
+ {
+ if(!argv[4])
+ printf("Pass the core to set after the -c.\n");
+ else
+ set_gov(argv[2], argv[4]);
+ } else
+ printf("Use -c to set the core.\n");
+ }
+ }
+ else if(strcmp(argv[1], "-f") == 0)
+ {
+ if(!argv[2])
+ {
+ printf("Pass the frequency to set after the -f.\n");
+ } else {
+ if(!argv[3])
+ {
+ printf("Use -c to set the core.\n");
+ } else if(strcmp(argv[3], "-c") == 0)
+ {
+ if(!argv[4])
+ printf("Pass the core to set after the -c.\n");
+ else
+ set_freq(argv[2], argv[4]);
+ } else {
+ printf("Use -c to set the core.\n");
+ }
+ }
+ } else {
+ printf("Use -g to set the governor or -f to set the frequency.\n");
+ }
+ return 0;
}
diff --git a/src/trayfreq_set_interface.c b/src/trayfreq_set_interface.c
index 00adeff..81c9299 100644
--- a/src/trayfreq_set_interface.c
+++ b/src/trayfreq_set_interface.c
@@ -23,23 +23,23 @@
void si_gov(char* gov, int core)
{
- char corestr[4];
- sprintf(corestr, "%i", core);
+ char corestr[4];
+ sprintf(corestr, "%i", core);
- gchar* cmd = g_strconcat(util_get_prefix(), "/bin/trayfreq-set -g ", gov, " -c ", corestr, NULL);
- system(cmd);
- g_free(cmd);
+ gchar* cmd = g_strconcat(util_get_prefix(), "/bin/trayfreq-set -g ", gov, " -c ", corestr, NULL);
+ system(cmd);
+ g_free(cmd);
}
void si_freq(int freq, int core)
{
- char corestr[4];
- sprintf(corestr, "%i", core);
+ char corestr[4];
+ sprintf(corestr, "%i", core);
- char freqstr[13];
- sprintf(freqstr, "%i", freq);
+ char freqstr[13];
+ sprintf(freqstr, "%i", freq);
- gchar* cmd = g_strconcat(util_get_prefix(), "/bin/trayfreq-set -f ", freqstr, " -c ", corestr, NULL);
- system(cmd);
- g_free(cmd);
+ gchar* cmd = g_strconcat(util_get_prefix(), "/bin/trayfreq-set -f ", freqstr, " -c ", corestr, NULL);
+ system(cmd);
+ g_free(cmd);
}
diff --git a/src/utilities.c b/src/utilities.c
index fa17743..52825cb 100644
--- a/src/utilities.c
+++ b/src/utilities.c
@@ -19,19 +19,19 @@
gint util_compare_gdouble(gdouble a, gdouble b)
{
- gdouble diff = a - b;
- if(diff < .0001)
- return 0;
- else if(diff > 0)
- return 1;
- else
- return -1;
+ gdouble diff = a - b;
+ if(diff < .0001)
+ return 0;
+ else if(diff > 0)
+ return 1;
+ else
+ return -1;
}
const gchar* util_get_prefix()
{
- if(g_strcmp0(PREFIX, "NONE") == 0)
- return "/usr/local";
- else
- return PREFIX;
+ if(g_strcmp0(PREFIX, "NONE") == 0)
+ return "/usr/local";
+ else
+ return PREFIX;
}
diff --git a/src/widget_manager.c b/src/widget_manager.c
index fca65eb..9472604 100644
--- a/src/widget_manager.c
+++ b/src/widget_manager.c
@@ -21,15 +21,15 @@ GList* wm_widgets;
void wm_add_widget(GtkWidget* widget)
{
- wm_widgets = g_list_prepend(wm_widgets, widget);
+ wm_widgets = g_list_prepend(wm_widgets, widget);
}
void wm_show_widgets()
{
- GList* curr = g_list_last(wm_widgets);
- while(curr)
- {
- gtk_widget_show(curr->data);
- curr = g_list_previous(curr);
- }
+ GList* curr = g_list_last(wm_widgets);
+ while(curr)
+ {
+ gtk_widget_show(curr->data);
+ curr = g_list_previous(curr);
+ }
}