aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile6
-rw-r--r--src/bat_tray.c15
-rw-r--r--src/getbat.c8
-rw-r--r--src/getfreq.c7
-rw-r--r--src/tray.c32
5 files changed, 31 insertions, 37 deletions
diff --git a/src/Makefile b/src/Makefile
index d7f69d8..8dd15a9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -17,12 +17,12 @@ VERSION = 0.2
trayfreq_SOURCES = getcore.c getcore.h getfreq.c getfreq.h getgov.c getgov.h tray.c tray.h trayfreq.c utilities.c utilities.h widget_manager.c widget_manager.h trayfreq_set_interface.c trayfreq_set_interface.h config_file.c config_file.h defaults.c defaults.h getbat.c getbat.h bat_tray.c bat_tray.h
#trayfreq_SOURCES = getcore.c getcore.h getfreq.c getfreq.h getgov.c getgov.h tray.c tray.h trayfreq.c utilities.c utilities.h widget_manager.c widget_manager.h config_file.c config_file.h defaults.c defaults.h getbat.c getbat.h bat_tray.c bat_tray.h
-trayfreq_CFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) -Wall -mfpmath=387
+trayfreq_CFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) -Wall
trayfreq_LDFLAGS = $(GTK_LIBS) $(GLIB_LIBS) -lm
-trayfreq_set_CFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) -Wall -mfpmath=387
+trayfreq_set_CFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) -Wall
trayfreq_set_LDFLAGS = $(GTK_LIBS) $(GLIB_LIBS) -lm
trayfreq_set_SOURCES = trayfreq_set.c getfreq.c getcore.c
@@ -36,4 +36,4 @@ trayfreq:
$(CC) -o trayfreq $(trayfreq_SOURCES) $(trayfreq_CFLAGS) $(trayfreq_LDFLAGS)
clean:
- rm trayfreq trayfreq-set \ No newline at end of file
+ rm trayfreq trayfreq-set
diff --git a/src/bat_tray.c b/src/bat_tray.c
index e93b2a2..c4b7d61 100644
--- a/src/bat_tray.c
+++ b/src/bat_tray.c
@@ -43,12 +43,12 @@ static gboolean update_tooltip(GtkStatusIcon* status_icon,gint x,gint y,gboolean
if(gb_discharging())
{
- gchar time[50];
- memset(time, '\0', 50);
+ //gchar time[50];
+ //memset(time, '\0', 50);
sprintf(msg, "Discharging (%i%% left)", gb_percent());
} else if(gb_charging()) {
- gchar time[50];
- memset(time, '\0', 50);
+ //gchar time[50];
+ //memset(time, '\0', 50);
sprintf(msg, "Charging (%i%%)", gb_percent());
} else if(gb_charged()) {
sprintf(msg, "Fully Charged\nAC Plugged In");
@@ -88,13 +88,10 @@ void bat_tray_update_icon_percent()
if(gb_discharging())
{
file = g_strconcat(util_get_prefix(), "/share/trayfreq/traybat-", adjusted_percent_string, ".png", NULL);
- }
- else if(gb_charging())
+ } else if(gb_charging())
{
file = g_strconcat(util_get_prefix(), "/share/trayfreq/traybat-", adjusted_percent_string, "-charging.png", NULL);
- }
- else
- {
+ } else {
file = g_strconcat(util_get_prefix(), "/share/trayfreq/traybat-charged.png", NULL);
}
diff --git a/src/getbat.c b/src/getbat.c
index 363e725..ad3a760 100644
--- a/src/getbat.c
+++ b/src/getbat.c
@@ -174,14 +174,6 @@ gint gb_low_capacity()
gint gb_percent()
{
return get_int_value_from_file(CHARGE_VALUE_PATH);
- /*
- int percent, max_capacity;
- if ( (max_capacity = gb_max_capacity()) == 0 )
- return 0;
- percent = (gb_current_capacity() * 100) / max_capacity;
- if (percent > 100)
- percent = 100;
- return percent;*/
}
/*
void gb_time(gchar* time)
diff --git a/src/getfreq.c b/src/getfreq.c
index 6322dc8..3195166 100644
--- a/src/getfreq.c
+++ b/src/getfreq.c
@@ -37,7 +37,10 @@ void gf_init()
for(i = 0; i < gc_number(); ++i)
{
memset(freq_string, '\0', 500);
- gf_available(i, freq_string, 500);
+
+ // Get available governor freqs. If no governor, try next cpu
+ if (gf_available(i, freq_string, 500) == -1)
+ continue;
/* go through every frequency in freq_string */
j = 0;
@@ -89,7 +92,7 @@ int gf_available(int core, char* out, int size)
sprintf(path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_available_frequencies", corestr);
if(!(fd = fopen(path, "r")))
- return -1;
+ return -1;
fgets(out, size, fd);
diff --git a/src/tray.c b/src/tray.c
index d3672f1..0ba95a2 100644
--- a/src/tray.c
+++ b/src/tray.c
@@ -258,22 +258,25 @@ void tray_set_tooltip(const gchar* 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 {
+ // If no governor, set percentage to 0. This if statement fixes an FPE a few lines down
+ if (max_frequency == 0)
+ {
adjusted_percent = 0;
+ } else {
+ // Percentages need to be {25,50,75,100}. Round to one of these numbers.
+ gint percent = (gf_current(0) * 100)/max_frequency;
+ 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 */
@@ -284,7 +287,6 @@ void tray_update_icon_percent()
gtk_status_icon_set_from_file(tray, file);
g_free(file);
-
}
void tray_show()