From 1b7114310f135ca81dfdc228c1c188c731a2d6e6 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 30 Mar 2014 11:50:03 +1300 Subject: Moved src/* to ./ --- 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 --- 23 files changed, 1616 deletions(-) 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 (limited to 'src') 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 * - * 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/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 * - * . * - ************************************************************************/ - -#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/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 * - * . * - ************************************************************************/ - -#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. * - * * - * 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/src/freq_tray/getgov.h b/src/freq_tray/getgov.h deleted file mode 100644 index b4fdc29..0000000 --- a/src/freq_tray/getgov.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 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/tray.c b/src/tray.c deleted file mode 100644 index fd65296..0000000 --- a/src/tray.c +++ /dev/null @@ -1,306 +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 "tray.h" -#include "widget_manager.h" -#include "freq_tray/getfreq.h" -#include "freq_tray/getcore.h" -#include "freq_tray/getgov.h" -#include "trayfreq_set/trayfreq_set_interface.h" -#include "bat_tray/bat_tray.h" -#include "defaults.h" - -#include -#include -#include -#include - -GtkStatusIcon* tray; -#define TOOLTIP_TEXT_SIZE 500 -gchar tooltip_text[TOOLTIP_TEXT_SIZE]; - - -/* 0 = nothing, 1 = was charging, 2 = was discharging */ -//int state = 0; - - -GtkWidget* menu; -GSList* menu_items; -GtkWidget* checked_menu_item; - -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) - si_freq(freq, i); - } -} - -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) - 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; -}*/ - -static void remove_menu_item(GtkWidget* menu_item, gpointer data) -{ - 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; -} - -static void tray_init_menu() -{ - menu = gtk_menu_new(); -} - -static void tray_generate_menu() -{ - tray_clear_menu(); - gg_init(); - - gchar label[20]; - int i = 0; - - gchar current_governor[20]; - memset(current_governor, '\0', 20); - gg_current(0, current_governor, 20); - - gint current_frequency = gf_current(0); - - /* append the frequencies */ - for(i = 0; i < gf_number(); ++i) - { - memset(label, '\0', 20); - gf_get_frequency_label(gf_freqi(0, i), label); - - 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))); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - } - - /* append the seperator */ - GtkWidget* seperator = gtk_separator_menu_item_new(); - gtk_menu_append(menu, seperator); - - /* append the governors*/ - for(i = 0; i < gg_number(); ++i) - { - if(g_strcmp0(gg_gov(0, i), "userspace") == 0) - continue; - - 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)); - - if(g_strcmp0(gg_gov(0, i), current_governor) == 0) - { - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); - } - - 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) -{ - gchar msg[500]; - gchar current_governer[20]; - gchar label[20]; - int i = 0; - - memset(msg, '\0', 500); - memset(current_governer, '\0', 20); - - // Change governor based on battery state battery is discharging - if ( get_battery_state() == STATE_DISCHARGING ) - { - if(_DEFAULT_BAT_GOV) - { - for(i = 0; i < gc_number(); ++i) - si_gov(_DEFAULT_BAT_GOV, i); - } - } - /* battery is now charging (on ac) */ - else if ( get_battery_state() == STATE_CHARGING ) - { - if(_DEFAULT_AC_GOV) - { - for(i = 0; i < gc_number(); ++i) - si_gov(_DEFAULT_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"); - } - - tray_set_tooltip(msg); - gtk_tooltip_set_text(tooltip, tooltip_text); - - return TRUE; -} - -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); -} - -static void activate(GtkStatusIcon* statuc_icon,gpointer data) -{ - if(_DEFAULT_PROG) - g_spawn_command_line_async(_DEFAULT_PROG, NULL); -} - -static gboolean update_icon(gpointer user_data) -{ - tray_update_icon_percent(); - return TRUE; -} - -void tray_init() -{ - // Set defaults - int i = 0; - if(_DEFAULT_GOV) - { - for(i = 0; i < gc_number(); ++i) - si_gov(_DEFAULT_GOV, i); - - } else { - for(i = 0; i < gc_number(); ++i) - si_gov("ondemand", i); - } - - if(_DEFAULT_FREQ) - { - for(i = 0; i < gc_number(); ++i) - { - si_freq(atoi(_DEFAULT_FREQ), i); - } - } - - tray = gtk_status_icon_new(); - gchar* icon_file = g_strconcat("/usr/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)); -} - -void tray_update_icon_percent() -{ - gulong max_frequency = gf_freqi(0, 0); - gint adjusted_percent = 0; - // 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 */ - gchar adjusted_percent_string[] = {'\0', '\0', '\0', '\0'}; - sprintf(adjusted_percent_string, "%i", adjusted_percent); - - gchar* file = g_strconcat("/usr/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); -} - -void tray_hide() -{ - gtk_status_icon_set_visible(tray, FALSE); -} - -gboolean tray_visible() -{ - return gtk_status_icon_get_visible(tray); -} - -gboolean tray_embedded() -{ - return gtk_status_icon_is_embedded(tray); -} diff --git a/src/tray.h b/src/tray.h deleted file mode 100644 index afad163..0000000 --- a/src/tray.h +++ /dev/null @@ -1,32 +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 TRAY_H -#define TRAY_H 1 - -#include - -void tray_init(); -void tray_set_tooltip(const gchar* msg); -void tray_update_icon_percent(); -void tray_show(); -void tray_hide(); -gboolean tray_visible(); -gboolean tray_embedded(); - -#endif diff --git a/src/trayfreq.c b/src/trayfreq.c deleted file mode 100644 index f8b0cc8..0000000 --- a/src/trayfreq.c +++ /dev/null @@ -1,126 +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 "widget_manager.h" -#include "tray.h" -#include "bat_tray/bat_tray.h" -#include "freq_tray/getfreq.h" -#include "freq_tray/getcore.h" -#include "freq_tray/getgov.h" -#include "config_file.h" -#include "defaults.h" - -#include -#include -#include -#include - -static gboolean SHOW_BATTERY = TRUE; - -void config_init() -{ - struct config_file config; - FILE* fd = NULL; - gboolean home_config_exists; - config.key_file = NULL; - - config.file_name = g_strconcat(getenv("HOME"), "/.trayfreq.config", NULL); - - // Check if ~/.trayfreq.config exists - if( (fd = fopen(config.file_name, "r")) ) - { - // If file exists, close it, set param to TRUE - fclose(fd); - home_config_exists = TRUE; - } else { - // If file didn't exist, it's not open (don't close it), free filename var, set param to FALSE - g_free(config.file_name); - home_config_exists = FALSE; - } - - if(!home_config_exists) - config.file_name = g_strconcat("/usr/share/trayfreq/trayfreq.config", NULL); - - gboolean success = config_open(&config); - - if(!success) - { - g_warning("Failed to open config files!\n"); - return; - } - - gchar * def_prog = config_get_key(&config, "events", "activate"); - gchar * def_gov = config_get_key(&config, "governor", "default"); - gchar * def_freq = config_get_key(&config, "frequency", "default"); - gchar * show_bat = config_get_key(&config, "battery", "show"); - gchar * bat_gov = config_get_key (&config, "battery", "governor"); - gchar * ac_gov = config_get_key (&config, "ac", "governor"); - - if(def_prog) - _DEFAULT_PROG = def_prog; - - if(def_gov) - _DEFAULT_GOV = def_gov; - - if(def_freq) - _DEFAULT_FREQ = def_freq; - - if (bat_gov) - _DEFAULT_BAT_GOV = bat_gov; - - if (ac_gov) - _DEFAULT_AC_GOV = ac_gov; - - if(show_bat) - { - if(g_strcmp0(show_bat, "1") == 0) - SHOW_BATTERY = TRUE; - else - SHOW_BATTERY = FALSE; - } - g_free(config.file_name); - config_close(&config); -} - -int main(int argc, char** argv) -{ - //gboolean gtk_init_success = gtk_init_check(&argc, &argv); - - if(!gtk_init_check(&argc, &argv)) - { - g_error("Cannot initialize gtk: gtk_init_check returned FALSE.\nBailing."); - return 1; - } - - config_init(); - gc_init(); - gg_init(); - gf_init(); - tray_init(); - tray_show(); - - // Show battery tray only if we're supposed to - if(SHOW_BATTERY) - { - bat_tray_init(); - bat_tray_show(); - } - - gtk_main(); - return 0; -} \ No newline at end of file diff --git a/src/trayfreq_set/trayfreq_set.c b/src/trayfreq_set/trayfreq_set.c deleted file mode 100644 index a67dd41..0000000 --- a/src/trayfreq_set/trayfreq_set.c +++ /dev/null @@ -1,121 +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 -#include -#include - -#include "../freq_tray/getfreq.h" - -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); - - FILE* fd = fopen(file_path, "w"); - fprintf(fd, freq); - fclose(fd); -} - -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); - - 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); - - 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); - - 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); -} - -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; -} \ No newline at end of file diff --git a/src/trayfreq_set/trayfreq_set_interface.c b/src/trayfreq_set/trayfreq_set_interface.c deleted file mode 100644 index 040513a..0000000 --- a/src/trayfreq_set/trayfreq_set_interface.c +++ /dev/null @@ -1,46 +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 "trayfreq_set_interface.h" - -#include -#include -#include - -void si_gov(char* gov, int core) -{ - char corestr[4]; - sprintf(corestr, "%i", core); - - char* cmd = g_strconcat("/usr/bin/trayfreq-set -g ", gov, " -c ", corestr, NULL); - system(cmd); - g_free(cmd); -} - -void si_freq(int freq, int core) -{ - char corestr[4]; - char freqstr[13]; - - sprintf(corestr, "%i", core); - sprintf(freqstr, "%i", freq); - - char* cmd = g_strconcat("/usr/bin/trayfreq-set -f ", freqstr, " -c ", corestr, NULL); - system(cmd); - g_free(cmd); -} \ No newline at end of file diff --git a/src/trayfreq_set/trayfreq_set_interface.h b/src/trayfreq_set/trayfreq_set_interface.h deleted file mode 100644 index 3f1cdbc..0000000 --- a/src/trayfreq_set/trayfreq_set_interface.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 * - * . * - ************************************************************************/ - -#ifndef TRAYFREQ_SET_INTERFACE_H -#define TRAYFREQ_SET_INTERFACE_H 1 - -void si_gov(char* gov, int core); -void si_freq(int freq, int core); - -#endif \ No newline at end of file diff --git a/src/widget_manager.c b/src/widget_manager.c deleted file mode 100644 index 30669a6..0000000 --- a/src/widget_manager.c +++ /dev/null @@ -1,36 +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 "widget_manager.h" - -GList* wm_widgets; - -void wm_add_widget(GtkWidget* 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); - } -} diff --git a/src/widget_manager.h b/src/widget_manager.h deleted file mode 100644 index 264c79d..0000000 --- a/src/widget_manager.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 WIDGET_MANAGER_H -#define WIDGET_MANAGER_H 1 - -#include -#include - -/* The Widget Manager will be a list of widgets. The list will be traversed from the tail to the head. */ - -void wm_add_widget(GtkWidget* widget); -void wm_show_widgets(); - -#endif -- cgit v1.1