From 1b7114310f135ca81dfdc228c1c188c731a2d6e6 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 30 Mar 2014 11:50:03 +1300 Subject: Moved src/* to ./ --- Makefile | 71 ++++++- bat_tray/bat_tray.c | 192 +++++++++++++++++++ bat_tray/bat_tray.h | 40 ++++ common.c | 86 +++++++++ common.h | 28 +++ config_file.c | 40 ++++ config_file.h | 34 ++++ defaults.c | 25 +++ defaults.h | 30 +++ freq_tray/getcore.c | 50 +++++ freq_tray/getcore.h | 25 +++ freq_tray/getfreq.c | 129 +++++++++++++ freq_tray/getfreq.h | 31 +++ freq_tray/getgov.c | 108 +++++++++++ freq_tray/getgov.h | 28 +++ src/Makefile | 48 ----- src/bat_tray/bat_tray.c | 192 ------------------- src/bat_tray/bat_tray.h | 40 ---- src/common.c | 86 --------- src/common.h | 28 --- src/config_file.c | 40 ---- src/config_file.h | 34 ---- src/defaults.c | 25 --- src/defaults.h | 30 --- src/freq_tray/getcore.c | 50 ----- src/freq_tray/getcore.h | 25 --- src/freq_tray/getfreq.c | 129 ------------- src/freq_tray/getfreq.h | 31 --- src/freq_tray/getgov.c | 108 ----------- src/freq_tray/getgov.h | 28 --- src/tray.c | 306 ------------------------------ src/tray.h | 32 ---- src/trayfreq.c | 126 ------------ src/trayfreq_set/trayfreq_set.c | 121 ------------ src/trayfreq_set/trayfreq_set_interface.c | 46 ----- src/trayfreq_set/trayfreq_set_interface.h | 25 --- src/widget_manager.c | 36 ---- src/widget_manager.h | 30 --- tray.c | 306 ++++++++++++++++++++++++++++++ tray.h | 32 ++++ trayfreq.c | 126 ++++++++++++ trayfreq_set/trayfreq_set.c | 122 ++++++++++++ trayfreq_set/trayfreq_set_interface.c | 46 +++++ trayfreq_set/trayfreq_set_interface.h | 25 +++ widget_manager.c | 36 ++++ widget_manager.h | 30 +++ 46 files changed, 1636 insertions(+), 1620 deletions(-) create mode 100644 bat_tray/bat_tray.c create mode 100644 bat_tray/bat_tray.h create mode 100644 common.c create mode 100644 common.h create mode 100644 config_file.c create mode 100644 config_file.h create mode 100644 defaults.c create mode 100644 defaults.h create mode 100644 freq_tray/getcore.c create mode 100644 freq_tray/getcore.h create mode 100644 freq_tray/getfreq.c create mode 100644 freq_tray/getfreq.h create mode 100644 freq_tray/getgov.c create mode 100644 freq_tray/getgov.h delete mode 100644 src/Makefile delete mode 100644 src/bat_tray/bat_tray.c delete mode 100644 src/bat_tray/bat_tray.h delete mode 100644 src/common.c delete mode 100644 src/common.h delete mode 100644 src/config_file.c delete mode 100644 src/config_file.h delete mode 100644 src/defaults.c delete mode 100644 src/defaults.h delete mode 100644 src/freq_tray/getcore.c delete mode 100644 src/freq_tray/getcore.h delete mode 100644 src/freq_tray/getfreq.c delete mode 100644 src/freq_tray/getfreq.h delete mode 100644 src/freq_tray/getgov.c delete mode 100644 src/freq_tray/getgov.h delete mode 100644 src/tray.c delete mode 100644 src/tray.h delete mode 100644 src/trayfreq.c delete mode 100644 src/trayfreq_set/trayfreq_set.c delete mode 100644 src/trayfreq_set/trayfreq_set_interface.c delete mode 100644 src/trayfreq_set/trayfreq_set_interface.h delete mode 100644 src/widget_manager.c delete mode 100644 src/widget_manager.h create mode 100644 tray.c create mode 100644 tray.h create mode 100644 trayfreq.c create mode 100644 trayfreq_set/trayfreq_set.c create mode 100644 trayfreq_set/trayfreq_set_interface.c create mode 100644 trayfreq_set/trayfreq_set_interface.h create mode 100644 widget_manager.c create mode 100644 widget_manager.h diff --git a/Makefile b/Makefile index 9a7873f..1b222da 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,79 @@ +# Tabsize: 4 + +MAKE = make +CC = gcc INSTALL_PATH=/ -all: - make all --directory=./src/ +GLIB_CFLAGS = -I/usr/include/glib-2.0 \ + -I/usr/lib/glib-2.0/include +GLIB_LIBS = -lglib-2.0 + +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 \ + -lgobject-2.0 + + +trayfreq_CFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) -Wall +trayfreq_LDFLAGS = $(GTK_LIBS) $(GLIB_LIBS) -lm +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_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 + + +######################################################################## +# Make entire suite +all: trayfreq trayfreq-set +######################################################################## + +######################################################################## +# Make trayfreq-set program for setting governors +trayfreq-set: + $(CC) -o trayfreq-set $(trayfreq_set_SOURCES) $(trayfreq_set_CFLAGS) $(trayfreq_set_LDFLAGS) +######################################################################## + + +######################################################################## +# Make main trayfreq system tray program +trayfreq: + $(CC) -o trayfreq $(trayfreq_SOURCES) $(trayfreq_CFLAGS) $(trayfreq_LDFLAGS) +######################################################################## + + +######################################################################## +# Remove generated files clean: - make clean --directory=./src/ + rm -f trayfreq trayfreq-set +######################################################################## + +######################################################################## +# Install entire suite install: mkdir -p $(INSTALL_PATH)/usr/share/trayfreq/ cp data/*.png $(INSTALL_PATH)/usr/share/trayfreq/ install -D data/trayfreq.config $(INSTALL_PATH)/usr/share/trayfreq/trayfreq.config install -D data/trayfreq.desktop $(INSTALL_PATH)/etc/xdg/autostart/trayfreq.desktop - install -Dm 755 src/trayfreq $(INSTALL_PATH)/usr/bin/trayfreq install -Dm 755 src/trayfreq-set $(INSTALL_PATH)/usr/bin/trayfreq-set +######################################################################## \ No newline at end of file diff --git a/bat_tray/bat_tray.c b/bat_tray/bat_tray.c new file mode 100644 index 0000000..9f6adfb --- /dev/null +++ b/bat_tray/bat_tray.c @@ -0,0 +1,192 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#include "bat_tray.h" +#include "../common.h" + +#include +#include +#include +#include + +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/bat_tray/bat_tray.h b/bat_tray/bat_tray.h new file mode 100644 index 0000000..c20a833 --- /dev/null +++ b/bat_tray/bat_tray.h @@ -0,0 +1,40 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#ifndef BAT_TRAY_H +#define BAT_TRAY_H 1 + +#include + + +// 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/common.c b/common.c new file mode 100644 index 0000000..ae858a9 --- /dev/null +++ b/common.c @@ -0,0 +1,86 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#include "common.h" + +#include +#include +#include +#include + +#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/common.h b/common.h new file mode 100644 index 0000000..bf59513 --- /dev/null +++ b/common.h @@ -0,0 +1,28 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#ifndef COMMON_H +#define COMMON_H 1 + +#include + +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/config_file.c b/config_file.c new file mode 100644 index 0000000..5bfbe65 --- /dev/null +++ b/config_file.c @@ -0,0 +1,40 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#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/config_file.h b/config_file.h new file mode 100644 index 0000000..cb491d4 --- /dev/null +++ b/config_file.h @@ -0,0 +1,34 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#ifndef CONFIG_FILE_H +#define CONFIG_FILE_H 1 + +#include + +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/defaults.c b/defaults.c new file mode 100644 index 0000000..dc54dd4 --- /dev/null +++ b/defaults.c @@ -0,0 +1,25 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#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/defaults.h b/defaults.h new file mode 100644 index 0000000..c959cbb --- /dev/null +++ b/defaults.h @@ -0,0 +1,30 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#ifndef DEFAULTS_H +#define DEFAULTS_H 1 + +#include + +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/freq_tray/getcore.c b/freq_tray/getcore.c new file mode 100644 index 0000000..a2ee3d3 --- /dev/null +++ b/freq_tray/getcore.c @@ -0,0 +1,50 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#include "getcore.h" + +#include +#include +#include + +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/freq_tray/getcore.h b/freq_tray/getcore.h new file mode 100644 index 0000000..541d789 --- /dev/null +++ b/freq_tray/getcore.h @@ -0,0 +1,25 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#ifndef GETCORE_H +#define GETCORE_H 1 + +void gc_init(); +int gc_number(); + +#endif diff --git a/freq_tray/getfreq.c b/freq_tray/getfreq.c new file mode 100644 index 0000000..5ac3948 --- /dev/null +++ b/freq_tray/getfreq.c @@ -0,0 +1,129 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#include "getfreq.h" +#include "getcore.h" +#include "math.h" + +#include +#include +#include +#include + +/* [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/freq_tray/getfreq.h b/freq_tray/getfreq.h new file mode 100644 index 0000000..a1cbd92 --- /dev/null +++ b/freq_tray/getfreq.h @@ -0,0 +1,31 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#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/freq_tray/getgov.c b/freq_tray/getgov.c new file mode 100644 index 0000000..cbb571c --- /dev/null +++ b/freq_tray/getgov.c @@ -0,0 +1,108 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#include "getgov.h" +#include "getcore.h" + +#include +#include +#include +#include + +/* [CORE][GOVERNOR NUMBER] */ +gchar AVAILABLE_GOVERNORS[999][50][13]; +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) + { + 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; +} + +int gg_current(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_governor", corestr); + + if(!(fd = fopen(path, "r"))) + return -1; + + fgets(out, size, fd); + + /* remove newline at the end */ + gchar* newline = g_strrstr(out, "\n"); + *newline = '\0'; + + fclose(fd); + return 0; +} + +int gg_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_governors", corestr); + + if(!(fd = fopen(path, "r"))) + return -1; + + fgets(out, size, fd); + + fclose(fd); + return 0; +} + +char* gg_gov(int core, int index) +{ + return AVAILABLE_GOVERNORS[core][index]; +} + +int gg_number() +{ + return NUMBER_OF_AVAILABLE_GOVERNORS; +} diff --git a/freq_tray/getgov.h b/freq_tray/getgov.h new file mode 100644 index 0000000..b4fdc29 --- /dev/null +++ b/freq_tray/getgov.h @@ -0,0 +1,28 @@ +/************************************************************************ + * 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 * + * . * + ************************************************************************/ + +#ifndef GETGOV_H +#define GETGOV_H 1 + +void gg_init(); +int gg_current(int core, char* out, int size); +int gg_available(int core, char* out, int size); +char* gg_gov(int core, int index); +int gg_number(); + +#endif 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 * - * . * - ************************************************************************/ - -#include "bat_tray.h" -#include "../common.h" - -#include -#include -#include -#include - -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 * - * . * - ************************************************************************/ - -#ifndef BAT_TRAY_H -#define BAT_TRAY_H 1 - -#include - - -// 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 * - * . * - ************************************************************************/ - -#include "common.h" - -#include -#include -#include -#include - -#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 * - * . * - ************************************************************************/ - -#ifndef COMMON_H -#define COMMON_H 1 - -#include - -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 * - * . * - ************************************************************************/ - -#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 * - * . * - ************************************************************************/ - -#ifndef CONFIG_FILE_H -#define CONFIG_FILE_H 1 - -#include - -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 * - * . * - ************************************************************************/ - -#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 * - * . * - ************************************************************************/ - -#ifndef DEFAULTS_H -#define DEFAULTS_H 1 - -#include - -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 * - * . * - ************************************************************************/ - -#include "getcore.h" - -#include -#include -#include - -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 *