diff options
author | David <dbphillipsnz@gmail.com> | 2014-03-30 11:50:03 +1300 |
---|---|---|
committer | David <dbphillipsnz@gmail.com> | 2014-03-30 11:55:04 +1300 |
commit | 1b7114310f135ca81dfdc228c1c188c731a2d6e6 (patch) | |
tree | 11263c755b3cd98254dfebff0fd38c6a85d8d7b7 /src | |
parent | 6532d80ed657c0cbd8c56d2e875ea093dcfadacd (diff) | |
download | paramano-1b7114310f135ca81dfdc228c1c188c731a2d6e6.tar.xz |
Moved src/* to ./
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 48 | ||||
-rw-r--r-- | src/bat_tray/bat_tray.c | 192 | ||||
-rw-r--r-- | src/bat_tray/bat_tray.h | 40 | ||||
-rw-r--r-- | src/common.c | 86 | ||||
-rw-r--r-- | src/common.h | 28 | ||||
-rw-r--r-- | src/config_file.c | 40 | ||||
-rw-r--r-- | src/config_file.h | 34 | ||||
-rw-r--r-- | src/defaults.c | 25 | ||||
-rw-r--r-- | src/defaults.h | 30 | ||||
-rw-r--r-- | src/freq_tray/getcore.c | 50 | ||||
-rw-r--r-- | src/freq_tray/getcore.h | 25 | ||||
-rw-r--r-- | src/freq_tray/getfreq.c | 129 | ||||
-rw-r--r-- | src/freq_tray/getfreq.h | 31 | ||||
-rw-r--r-- | src/freq_tray/getgov.c | 108 | ||||
-rw-r--r-- | src/freq_tray/getgov.h | 28 | ||||
-rw-r--r-- | src/tray.c | 306 | ||||
-rw-r--r-- | src/tray.h | 32 | ||||
-rw-r--r-- | src/trayfreq.c | 126 | ||||
-rw-r--r-- | src/trayfreq_set/trayfreq_set.c | 121 | ||||
-rw-r--r-- | src/trayfreq_set/trayfreq_set_interface.c | 46 | ||||
-rw-r--r-- | src/trayfreq_set/trayfreq_set_interface.h | 25 | ||||
-rw-r--r-- | src/widget_manager.c | 36 | ||||
-rw-r--r-- | src/widget_manager.h | 30 |
23 files changed, 0 insertions, 1616 deletions
diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 284321f..0000000 --- a/src/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -CC = gcc - -GLIB_CFLAGS = -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -GLIB_LIBS = -lglib-2.0 - -#GTK_CFLAGS = -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -GTK_CFLAGS = -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 - -#GTK_LIBS = -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -GTK_LIBS = -lgtk-x11-2.0 -lgobject-2.0 - -#PACKAGE_VERSION = 0.3 -#VERSION = 0.3 - -trayfreq_SOURCES = freq_tray/getcore.c \ - freq_tray/getfreq.c \ - freq_tray/getgov.c \ - tray.c \ - trayfreq.c \ - widget_manager.c \ - trayfreq_set/trayfreq_set_interface.c \ - config_file.c \ - defaults.c \ - bat_tray/bat_tray.c \ - common.c - -trayfreq_CFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) -Wall - -trayfreq_LDFLAGS = $(GTK_LIBS) $(GLIB_LIBS) -lm - - -trayfreq_set_CFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) -Wall -trayfreq_set_LDFLAGS = $(GTK_LIBS) $(GLIB_LIBS) -lm -trayfreq_set_SOURCES = trayfreq_set/trayfreq_set.c \ - freq_tray/getfreq.c \ - freq_tray/getcore.c - - -all: trayfreq trayfreq-set - -trayfreq-set: - $(CC) -o trayfreq-set $(trayfreq_set_SOURCES) $(trayfreq_set_CFLAGS) $(trayfreq_set_LDFLAGS) - -trayfreq: - $(CC) -o trayfreq $(trayfreq_SOURCES) $(trayfreq_CFLAGS) $(trayfreq_LDFLAGS) - -clean: - rm -f trayfreq trayfreq-set diff --git a/src/bat_tray/bat_tray.c b/src/bat_tray/bat_tray.c deleted file mode 100644 index 9f6adfb..0000000 --- a/src/bat_tray/bat_tray.c +++ /dev/null @@ -1,192 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#include "bat_tray.h" -#include "../common.h" - -#include <gtk/gtk.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> - -static GtkStatusIcon* tray; - - -int _BAT_NUM; -char CHARGE_VALUE_PATH[512]; -char CHARGE_STATE_PATH[512]; - -/*********************************************************************** - * Return the battery level percentage - **********************************************************************/ -//#define get_bat_percent() get_int_value_from_file(CHARGE_VALUE_PATH); -int get_bat_percent(){return get_int_value_from_file(CHARGE_VALUE_PATH); } - - -#define TOOLTIP_TEXT_SIZE 128 -gchar tooltip_text[TOOLTIP_TEXT_SIZE]; - - -/*********************************************************************** - * Updates the battery tray tooltip text - **********************************************************************/ -static gboolean update_tooltip(GtkStatusIcon* status_icon,gint x,gint y,gboolean keyboard_mode,GtkTooltip* tooltip,gpointer data) -{ - gchar msg[TOOLTIP_TEXT_SIZE]; - //memset(msg,0,TOOLTIP_TEXT_SIZE); - switch(get_battery_state()) - { - case STATE_DISCHARGING: - sprintf(msg, "Discharging (%i%% left)", get_bat_percent()); - break; - - case STATE_CHARGING: - sprintf(msg, "Charging (%i%%)", get_bat_percent()); - break; - case STATE_CHARGED: - sprintf(msg, "Fully charged"); - break; - - default: - sprintf(msg, "Unknown status"); - break; - } - - gtk_tooltip_set_text(tooltip, msg); - - return TRUE; -} - - -/*********************************************************************** - * Updates the battery tray icon based upon battery percent - **********************************************************************/ -static gboolean update_icon(gpointer user_data) -{ - gchar* icon_file; - unsigned int percent = get_bat_percent(); - unsigned int adjusted_percent; - gchar adjusted_percent_string[4]; - - if(percent > 90) - adjusted_percent=100; - else if(percent > 70) - adjusted_percent=80; - else if(percent > 50) - adjusted_percent=60; - else if(percent > 30) - adjusted_percent=40; - else if(percent > 10) - adjusted_percent=20; - else - adjusted_percent=0; - - sprintf(adjusted_percent_string, "%i", adjusted_percent); - - switch ( get_battery_state() ) - { - case STATE_DISCHARGING: - icon_file = g_strconcat("/usr/share/trayfreq/traybat-", adjusted_percent_string, ".png", NULL); - break; - case STATE_CHARGING: - icon_file = g_strconcat("/usr/share/trayfreq/traybat-", adjusted_percent_string, "-charging.png", NULL); - break; - - default: - icon_file = g_strconcat("/usr/share/trayfreq/traybat-charged.png", NULL); - break; - } - gtk_status_icon_set_from_file(tray, icon_file); - return TRUE; -} - - - - -void bat_tray_init() -{ - // Get the battery number, store it for later - _BAT_NUM = get_bat_num(); - - // Set up battery info filenames/paths - sprintf(CHARGE_VALUE_PATH, "/sys/class/power_supply/BAT%i/capacity", _BAT_NUM); - sprintf(CHARGE_STATE_PATH, "/sys/class/power_supply/BAT%i/status", _BAT_NUM); - // NOT USED : sprintf(CURRENT_PATH, "/sys/class/power_supply/BAT%i/charge_now", _BAT_NUM); - - - tray = gtk_status_icon_new(); - gchar* icon_file = g_strconcat("/usr/share/trayfreq/traybat-charged.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); - gtk_timeout_add(5000, update_icon, NULL); -} - - -void bat_tray_show() -{ - gtk_status_icon_set_visible(tray, TRUE); -} - -void bat_tray_hide() -{ - gtk_status_icon_set_visible(tray, FALSE); -} - - -/*********************************************************************** - * Return the battery state - **********************************************************************/ -int get_battery_state() -{ - if (file_has_line(CHARGE_STATE_PATH, "Discharging")) - return STATE_DISCHARGING; - - if (file_has_line(CHARGE_STATE_PATH, "Full")) - return STATE_CHARGED; - - if (file_has_line(CHARGE_STATE_PATH, "Charging")) - return STATE_CHARGING; - - return STATE_UNKNOWN; -} - -/*********************************************************************** - * Get the number of the first (who has more than one?) battery - * Returns -1 if no battery present - **********************************************************************/ -int get_bat_num() -{ - FILE* fd; - gchar file[40]; - unsigned int i; - for(i = 0; i < 3; i++) - { - sprintf(file, "/sys/class/power_supply/BAT%i/present", i); - - if( (fd = fopen(file, "r")) ) - { - if (fgetc(fd) == '1') - { - fclose(fd); - return i; - } - } - } - return -1; -} diff --git a/src/bat_tray/bat_tray.h b/src/bat_tray/bat_tray.h deleted file mode 100644 index c20a833..0000000 --- a/src/bat_tray/bat_tray.h +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#ifndef BAT_TRAY_H -#define BAT_TRAY_H 1 - -#include <glib.h> - - -// already defined in bat_tray.c : #define gb_percent get_int_value_from_file(CHARGE_VALUE_PATH); - -#define STATE_CHARGING 0 -#define STATE_DISCHARGING 1 -#define STATE_CHARGED 2 -#define STATE_FULL STATE_CHARGED -#define STATE_UNKNOWN 3 - -void bat_tray_init(); -void bat_tray_show(); -void bat_tray_hide(); - -int get_battery_state(); -int get_bat_num(); - -#endif /* ifndef BAT_TRAY_H */
\ No newline at end of file diff --git a/src/common.c b/src/common.c deleted file mode 100644 index ae858a9..0000000 --- a/src/common.c +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#include "common.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdbool.h> - -#define TRUE true -#define FALSE false - -/*********************************************************************** - * Gets integer value from file - **********************************************************************/ -int get_int_value_from_file(const char* filename) -{ - FILE* fd; - char buffer[512]; - int value; - - if(!(fd = fopen(filename, "r"))) - return -1; - - if (fgets(buffer, 100, fd)) - value = get_int(buffer); - - fclose(fd); - return value; -} - - -/*********************************************************************** - * Return true/false if a file has specified line or not - **********************************************************************/ -bool file_has_line(const char *filename, const char *line) -{ - FILE* fd; - char buffer[512]; - - if (!(fd = fopen(filename, "r"))) - return FALSE; - - while (fgets(buffer, sizeof(buffer), fd) != NULL) - { - if(strstr(buffer, line) != NULL) - { - fclose(fd); - return TRUE; - } - } - fclose(fd); - return FALSE; -} - - -/*********************************************************************** - * Fetches first number from a string - **********************************************************************/ -int get_int(const char* string) -{ - char numbers[] = "1234567890"; - char* first_num; - - first_num = strpbrk(string, numbers); - if(first_num) - return atoi(first_num); - - return 1; -} diff --git a/src/common.h b/src/common.h deleted file mode 100644 index bf59513..0000000 --- a/src/common.h +++ /dev/null @@ -1,28 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#ifndef COMMON_H -#define COMMON_H 1 - -#include <stdbool.h> - -int get_int_value_from_file(const char* filename); -bool file_has_line(const char *filename, const char *line); -int get_int(const char* string); - -#endif
\ No newline at end of file diff --git a/src/config_file.c b/src/config_file.c deleted file mode 100644 index 5bfbe65..0000000 --- a/src/config_file.c +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#include "config_file.h" - -gboolean config_open(struct config_file* config_file) -{ - if(config_file->key_file) - g_key_file_free(config_file->key_file); - - config_file->key_file = g_key_file_new(); - - gboolean success = g_key_file_load_from_file(config_file->key_file, config_file->file_name, G_KEY_FILE_NONE, NULL); - return success; -} - -void config_close(struct config_file* config_file) -{ - g_key_file_free(config_file->key_file); -} - -gchar* config_get_key(struct config_file* config_file, const gchar* group_name, const gchar* key_name) -{ - return g_key_file_get_value(config_file->key_file, group_name, key_name, NULL); -}
\ No newline at end of file diff --git a/src/config_file.h b/src/config_file.h deleted file mode 100644 index cb491d4..0000000 --- a/src/config_file.h +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#ifndef CONFIG_FILE_H -#define CONFIG_FILE_H 1 - -#include <glib.h> - -struct config_file -{ - GKeyFile* key_file; - gchar* file_name; -}; - -gboolean config_open(struct config_file* config_file); -void config_close(struct config_file* config_file); -gchar* config_get_key(struct config_file* config_file, const gchar* group_name, const gchar* key_name); - -#endif /* ifndef CONFIG_FILE_H */
\ No newline at end of file diff --git a/src/defaults.c b/src/defaults.c deleted file mode 100644 index dc54dd4..0000000 --- a/src/defaults.c +++ /dev/null @@ -1,25 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#include "defaults.h" - -char* _DEFAULT_GOV = NULL; -char* _DEFAULT_FREQ = NULL; -char* _DEFAULT_PROG = NULL; -char* _DEFAULT_BAT_GOV = NULL; -char* _DEFAULT_AC_GOV = NULL;
\ No newline at end of file diff --git a/src/defaults.h b/src/defaults.h deleted file mode 100644 index c959cbb..0000000 --- a/src/defaults.h +++ /dev/null @@ -1,30 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#ifndef DEFAULTS_H -#define DEFAULTS_H 1 - -#include <glib.h> - -char* _DEFAULT_GOV; -char* _DEFAULT_FREQ; -char* _DEFAULT_PROG; -char* _DEFAULT_BAT_GOV; -char* _DEFAULT_AC_GOV; - -#endif /* ifndef DEFAULTS_H */
\ No newline at end of file diff --git a/src/freq_tray/getcore.c b/src/freq_tray/getcore.c deleted file mode 100644 index a2ee3d3..0000000 --- a/src/freq_tray/getcore.c +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#include "getcore.h" - -#include <stdio.h> -#include <stdlib.h> -#include <glib.h> - -int NUMBER_OF_CORES; - -static gboolean core_exists(int core) -{ - FILE* fd; - char path[80]; - char corestr[4]; - - sprintf(corestr, "%i", core); - sprintf(path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_cur_freq", corestr); - - return (gboolean)(fd = fopen(path, "r")); -} - -void gc_init() -{ - NUMBER_OF_CORES = 0; - while(core_exists(++NUMBER_OF_CORES)); -} - - -/* to do */ -int gc_number() -{ - return NUMBER_OF_CORES; -} diff --git a/src/freq_tray/getcore.h b/src/freq_tray/getcore.h deleted file mode 100644 index 541d789..0000000 --- a/src/freq_tray/getcore.h +++ /dev/null @@ -1,25 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#ifndef GETCORE_H -#define GETCORE_H 1 - -void gc_init(); -int gc_number(); - -#endif diff --git a/src/freq_tray/getfreq.c b/src/freq_tray/getfreq.c deleted file mode 100644 index 5ac3948..0000000 --- a/src/freq_tray/getfreq.c +++ /dev/null @@ -1,129 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#include "getfreq.h" -#include "getcore.h" -#include "math.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <glib.h> - -/* [CORE][FREQUENCY NUMBER] */ -char AVAILABLE_FREQUENCIES[999][50][13]; -int NUMBER_OF_AVAILABLE_FREQUENCIES; - -void gf_init() -{ - gchar freq_string[500]; - - int i = 0; - int j = 0; - for(i = 0; i < gc_number(); ++i) - { - memset(freq_string, '\0', 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; - gchar* curr = &freq_string[0]; - gchar* end_of_curr = g_strstr_len(curr, strlen(curr), " "); - while(end_of_curr) - { - memset(AVAILABLE_FREQUENCIES[i][j], '\0', 13); - memmove(AVAILABLE_FREQUENCIES[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_FREQUENCIES = j; -} - -int gf_current(int core) -{ - FILE* fd; - char buff[13]; - char path[80]; - char corestr[4]; - int freq; - - sprintf(corestr, "%i", core); - - sprintf(path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_cur_freq", corestr); - - if(!(fd = fopen(path, "r"))) - return -1; - - fgets(buff, 13, fd); - - freq = atoi(buff); - fclose(fd); - return freq; -} - -int gf_available(int core, char* out, int size) -{ - FILE* fd; - char path[80]; - char corestr[4]; - - sprintf(corestr, "%i", core); - - sprintf(path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_available_frequencies", corestr); - - if(!(fd = fopen(path, "r"))) - return -1; - - fgets(out, size, fd); - - fclose(fd); - return 0; -} - -void gf_get_frequency_label(int freq, char* out) -{ - int i = 0; - while(freq/pow(10, i) >= 1) - ++i; - - if(i == 7) - sprintf(out, "%.2f GHz", freq/pow(10, i-1)); - else - sprintf(out, "%.2d MHz", freq/1000); -} - -char* gf_freqa(int core, int index) -{ - return AVAILABLE_FREQUENCIES[core][index]; -} - -int gf_freqi(int core, int index) -{ - return atoi(gf_freqa(core, index)); -} - -int gf_number() -{ - return NUMBER_OF_AVAILABLE_FREQUENCIES; -} diff --git a/src/freq_tray/getfreq.h b/src/freq_tray/getfreq.h deleted file mode 100644 index a1cbd92..0000000 --- a/src/freq_tray/getfreq.h +++ /dev/null @@ -1,31 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * trayfreq-archlinux is distributed in the hope that it will be useful,* - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with trayfreq-archlinux. If not, see * - * <http://www.gnu.org/licenses/>. * - ************************************************************************/ - -#ifndef GETFREQ_H -#define GETFREQ_H 1 - -void gf_init(); -int gf_current(int core); -int gf_available(int core, char* out, int size); -void gf_get_frequency_label(int freq, char* out); -char* gf_freqa(int core, int index); -int gf_freqi(int core, int index); -int gf_number(); - - -#endif diff --git a/src/freq_tray/getgov.c b/src/freq_tray/getgov.c deleted file mode 100644 index cbb571c..0000000 --- a/src/freq_tray/getgov.c +++ /dev/null @@ -1,108 +0,0 @@ -/************************************************************************ - * This file is part of trayfreq-archlinux. * - * * - * trayfreq-archlinux is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * |