aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile25
-rw-r--r--bat_tray.c15
-rw-r--r--data/cpufreq-0.pngbin939 -> 0 bytes
-rw-r--r--data/cpufreq-100.pngbin1057 -> 0 bytes
-rw-r--r--data/cpufreq-25.pngbin942 -> 0 bytes
-rw-r--r--data/cpufreq-50.pngbin988 -> 0 bytes
-rw-r--r--data/cpufreq-75.pngbin1014 -> 0 bytes
-rw-r--r--data/traybat-0-charging.pngbin1270 -> 0 bytes
-rw-r--r--data/traybat-0.pngbin922 -> 0 bytes
-rw-r--r--data/traybat-100-charging.pngbin1261 -> 0 bytes
-rw-r--r--data/traybat-100.pngbin839 -> 0 bytes
-rw-r--r--data/traybat-20-charging.pngbin1297 -> 0 bytes
-rw-r--r--data/traybat-20.pngbin923 -> 0 bytes
-rw-r--r--data/traybat-40-charging.pngbin1288 -> 0 bytes
-rw-r--r--data/traybat-40.pngbin925 -> 0 bytes
-rw-r--r--data/traybat-60-charging.pngbin1305 -> 0 bytes
-rw-r--r--data/traybat-60.pngbin912 -> 0 bytes
-rw-r--r--data/traybat-80-charging.pngbin1280 -> 0 bytes
-rw-r--r--data/traybat-80.pngbin872 -> 0 bytes
-rw-r--r--data/traybat-charged.pngbin1913 -> 0 bytes
-rw-r--r--data/trayfreq.conf41
-rw-r--r--data/trayfreq.desktop7
-rw-r--r--defaults.c6
-rw-r--r--defaults.h1
-rw-r--r--tray.c5
-rw-r--r--trayfreq.c13
-rw-r--r--trayfreq_set.c2
27 files changed, 45 insertions, 70 deletions
diff --git a/Makefile b/Makefile
index f718739..379b9a5 100644
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,12 @@ MAKE = make
CC = gcc
PREFIX=/usr
BINDIR=$(PREFIX)/bin
+SHAREDIR=$(PREFIX)/share
+LOCALEDIR=$(SHAREDIR)/locale/
+
SUDO=/usr/bin/sudo
TRAYFREQ_SET=$(BINDIR)/trayfreq-set
-LOCALE_DIR=$(PREFIX)/share/locale/
+TRAYFREQ_CONF=/etc/trayfreq.conf
ifdef DEBUG
EXTRA_CFLAGS+=-DDEBUG
@@ -16,7 +19,8 @@ EXTRA_CFLAGS+= -DPREFIX=\"$(PREFIX)\" \
-DBINDIR=\"$(BINDIR)\" \
-DSUDO=\"$(SUDO)\" \
-DTRAYFREQ_SET=\"$(TRAYFREQ_SET)\" \
- -DLOCALE_DIR=\"$(LOCALE_DIR)\"
+ -DLOCALEDIR=\"$(LOCALEDIR)\" \
+ -DSHAREDIR=\"$(SHAREDIR)\"
DEPS = bat_tray.h \
@@ -111,7 +115,6 @@ trayfreq-set: \
########################################################################
-
########################################################################
# Make language file(s)
lang:
@@ -120,20 +123,26 @@ lang:
########################################################################
+# Prepare template config file
+config:
+ sed -e 's:SHAREDIR:$(SHAREDIR):g' \
+ -e 's:TRAYFREQ_CONF:$(TRAYFREQ_CONF):g' \
+ trayfreq.conf.src > trayfreq.conf
+########################################################################
+
+
+########################################################################
# Remove generated files
clean:
- rm -f trayfreq trayfreq-set *.o lang/*.mo
+ rm -f trayfreq trayfreq-set *.o lc/*.mo trayfreq.conf
########################################################################
########################################################################
# Install entire suite
install:
- mkdir -p $(DESTDIR)/usr/share/trayfreq/
- #mkdir -p $(DESTDIR)/$(LOCALE_DIR)/fr/LC_MESSAGES/
- #mkdir -p $(DESTDIR)/etc/xdg/autostart/
+ install -Dm 755 data/themes $(DESTDIR)/usr/share/trayfreq/
- cp data/*.png $(DESTDIR)/usr/share/trayfreq/
install -Dm 644 lc/fr.mo $(DESTDIR)$(LOCALE_DIR)/fr/LC_MESSAGES/trayfreq.mo
install -Dm 644 data/trayfreq.conf $(DESTDIR)/etc/trayfreq.conf
diff --git a/bat_tray.c b/bat_tray.c
index 8d0109d..1aad51a 100644
--- a/bat_tray.c
+++ b/bat_tray.c
@@ -23,6 +23,7 @@
#include <libintl.h>
#include "debug.h"
#include "common.h"
+#include "defaults.h"
static GtkStatusIcon* tray;
@@ -34,8 +35,10 @@ 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); }
+int get_bat_percent()
+{
+ return get_int_value_from_file(CHARGE_VALUE_PATH);
+}
#define TOOLTIP_TEXT_SIZE 128
@@ -110,14 +113,14 @@ static gboolean update_icon(gpointer user_data)
switch ( get_battery_state() )
{
case STATE_DISCHARGING:
- icon_file = g_strconcat("/usr/share/trayfreq/traybat-", adjusted_percent_string, ".png", NULL);
+ icon_file = g_strconcat(_DEFAULT_THEME, "/traybat-", adjusted_percent_string, ".png", NULL);
break;
case STATE_CHARGING:
- icon_file = g_strconcat("/usr/share/trayfreq/traybat-", adjusted_percent_string, "-charging.png", NULL);
+ icon_file = g_strconcat(_DEFAULT_THEME, "/traybat-", adjusted_percent_string, "-charging.png", NULL);
break;
default:
- icon_file = g_strconcat("/usr/share/trayfreq/traybat-charged.png", NULL);
+ icon_file = g_strconcat(_DEFAULT_THEME, "/traybat-charged.png", NULL);
break;
}
@@ -140,7 +143,7 @@ void bat_tray_init()
debug("Spawning new status icon\n");
tray = gtk_status_icon_new();
- gchar* icon_file = g_strconcat("/usr/share/trayfreq/traybat-charged.png", NULL);
+ gchar* icon_file = g_strconcat(_DEFAULT_THEME, "/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);
diff --git a/data/cpufreq-0.png b/data/cpufreq-0.png
deleted file mode 100644
index 9a1b3b4..0000000
--- a/data/cpufreq-0.png
+++ /dev/null
Binary files differ
diff --git a/data/cpufreq-100.png b/data/cpufreq-100.png
deleted file mode 100644
index 6b63453..0000000
--- a/data/cpufreq-100.png
+++ /dev/null
Binary files differ
diff --git a/data/cpufreq-25.png b/data/cpufreq-25.png
deleted file mode 100644
index ae2acf6..0000000
--- a/data/cpufreq-25.png
+++ /dev/null
Binary files differ
diff --git a/data/cpufreq-50.png b/data/cpufreq-50.png
deleted file mode 100644
index 03ab5e3..0000000
--- a/data/cpufreq-50.png
+++ /dev/null
Binary files differ
diff --git a/data/cpufreq-75.png b/data/cpufreq-75.png
deleted file mode 100644
index 49e9342..0000000
--- a/data/cpufreq-75.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-0-charging.png b/data/traybat-0-charging.png
deleted file mode 100644
index 9255e66..0000000
--- a/data/traybat-0-charging.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-0.png b/data/traybat-0.png
deleted file mode 100644
index 2554a6a..0000000
--- a/data/traybat-0.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-100-charging.png b/data/traybat-100-charging.png
deleted file mode 100644
index bae3a43..0000000
--- a/data/traybat-100-charging.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-100.png b/data/traybat-100.png
deleted file mode 100644
index fe4ba7f..0000000
--- a/data/traybat-100.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-20-charging.png b/data/traybat-20-charging.png
deleted file mode 100644
index aabd778..0000000
--- a/data/traybat-20-charging.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-20.png b/data/traybat-20.png
deleted file mode 100644
index 83e7065..0000000
--- a/data/traybat-20.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-40-charging.png b/data/traybat-40-charging.png
deleted file mode 100644
index c016a28..0000000
--- a/data/traybat-40-charging.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-40.png b/data/traybat-40.png
deleted file mode 100644
index 3245106..0000000
--- a/data/traybat-40.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-60-charging.png b/data/traybat-60-charging.png
deleted file mode 100644
index 1667458..0000000
--- a/data/traybat-60-charging.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-60.png b/data/traybat-60.png
deleted file mode 100644
index aa25803..0000000
--- a/data/traybat-60.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-80-charging.png b/data/traybat-80-charging.png
deleted file mode 100644
index b9c6991..0000000
--- a/data/traybat-80-charging.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-80.png b/data/traybat-80.png
deleted file mode 100644
index e649be0..0000000
--- a/data/traybat-80.png
+++ /dev/null
Binary files differ
diff --git a/data/traybat-charged.png b/data/traybat-charged.png
deleted file mode 100644
index 1e61940..0000000
--- a/data/traybat-charged.png
+++ /dev/null
Binary files differ
diff --git a/data/trayfreq.conf b/data/trayfreq.conf
deleted file mode 100644
index ad6abcf..0000000
--- a/data/trayfreq.conf
+++ /dev/null
@@ -1,41 +0,0 @@
-# Begin /usr/share/trayfreq/trayfreq.conf
-#
-# Sample config file for trayfreq-archlinux
-#
-
-[battery]
-## Uncomment to hide battery icon -- useful for desktop PCs
-## Set to anything (or leave unset/commented out) to show battery icon
-# show=0
-
-## Name of the governor to use for all cores when on battery power
-## Get a space-separated list of available governors from
-## /sys/devices/system/cpu/cpu{{CORE_NUMBER}}/cpufreq/scaling_available_governors
-# governor=powersave
-
-[ac]
-## Governor to use for all core while on AC power
-## Often set to a performance or non-power-saving governor
-# governor=ondemand
-
-[governor]
-## Governor to set all cores to when trayfreq starts
-# default=ondemand
-
-
-[frequency]
-## The frequency to set the CPU to when trayfreq starts
-## Get a space-separated list of available frequencies from
-## /sys/devices/system/cpu/cpu{{CORE_NUMBER}}/cpufreq/scaling_available_frequencies
-# default=800000
-
-
-[extra]
-## Uncomment to make trayfreq run trayfreq-set through sudo.
-## Useful if your WM doesn't run trayfreq as root, but you'll have to give the user
-## trayfreq is run as passwordless sudo access to `trayfreq-set`
-# sudo=1
-
-
-#
-# End /usr/share/trayfreq/trayfreq.conf
diff --git a/data/trayfreq.desktop b/data/trayfreq.desktop
deleted file mode 100644
index 0905549..0000000
--- a/data/trayfreq.desktop
+++ /dev/null
@@ -1,7 +0,0 @@
-[Desktop Entry]
-Version=1.0
-Encoding=UTF-8
-Name=trayfreq
-GenericName=trayfreq
-Exec=/usr/bin/trayfreq
-Type=Application
diff --git a/defaults.c b/defaults.c
index 926e1fd..79a9566 100644
--- a/defaults.c
+++ b/defaults.c
@@ -18,6 +18,8 @@
#include "defaults.h"
+#include <stdio.h>
+
char* _DEFAULT_GOV;
char* _DEFAULT_FREQ;
char* _DEFAULT_PROG;
@@ -25,6 +27,7 @@ char* _DEFAULT_BAT_GOV;
char* _DEFAULT_AC_GOV;
bool _DEFAULT_SHOW_BATTERY = TRUE;
bool _DEFAULT_USE_SUDO = FALSE;
+char _DEFAULT_THEME[2048]; // to do : make dynamic with malloc
void defaults_init()
{
@@ -34,5 +37,6 @@ void defaults_init()
_DEFAULT_BAT_GOV = NULL;
_DEFAULT_AC_GOV = NULL;
_DEFAULT_SHOW_BATTERY = TRUE;
- _DEFAULT_USE_SUDO = FALSE;
+ _DEFAULT_USE_SUDO = FALSE;
+ sprintf (_DEFAULT_THEME, SHAREDIR"/trayfreq/themes/default");
}
diff --git a/defaults.h b/defaults.h
index ed6fabd..dbd8822 100644
--- a/defaults.h
+++ b/defaults.h
@@ -29,6 +29,7 @@ char* _DEFAULT_BAT_GOV;
char* _DEFAULT_AC_GOV;
bool _DEFAULT_SHOW_BATTERY;
bool _DEFAULT_USE_SUDO;
+char _DEFAULT_THEME[2048];
void defaults_init();
diff --git a/tray.c b/tray.c
index aa96fda..3143464 100644
--- a/tray.c
+++ b/tray.c
@@ -18,7 +18,6 @@
#include "tray.h"
-//#include "widget_manager.h"
#include "getfreq.h"
#include "getcore.h"
#include "getgov.h"
@@ -262,7 +261,7 @@ void tray_init()
{
tray_set_defaults();
tray = gtk_status_icon_new();
- char* icon_file = g_strconcat("/usr/share/trayfreq/cpufreq-0.png", NULL);
+ char* icon_file = g_strconcat(_DEFAULT_THEME, "/cpufreq-0.png", NULL);
debug("Setting icon to '%s'\n",icon_file);
gtk_status_icon_set_from_file(tray, icon_file);
@@ -313,7 +312,7 @@ void tray_update_icon_percent()
char adjusted_percent_string[] = {'\0', '\0', '\0', '\0'};
sprintf(adjusted_percent_string, "%i", adjusted_percent);
- char* file = g_strconcat("/usr/share/trayfreq/cpufreq-", adjusted_percent_string, ".png", NULL);
+ char* file = g_strconcat(_DEFAULT_THEME, "/cpufreq-", adjusted_percent_string, ".png", NULL);
debug("Setting tray icon to '%s'\n",file);
gtk_status_icon_set_from_file(tray, file);
diff --git a/trayfreq.c b/trayfreq.c
index 282ccd5..3e63cd5 100644
--- a/trayfreq.c
+++ b/trayfreq.c
@@ -33,11 +33,12 @@
#include <stdio.h>
#include <libintl.h>
#include <locale.h>
+#include <string.h>
int main(int argc, char** argv)
{
setlocale(LC_ALL, "");
- bindtextdomain("trayfreq",LOCALE_DIR);
+ bindtextdomain("trayfreq",LOCALEDIR);
textdomain("trayfreq");
debug("Set gettext up\n");
@@ -130,9 +131,15 @@ void config_init()
if (temp)
{
_DEFAULT_USE_SUDO = ( temp[0] == '1' );
- debug("woo\n");
}
-
+
+ temp = config_get_key(&config, "extra", "theme");
+ if (temp && strlen(temp) < sizeof(_DEFAULT_THEME) )
+ {
+ sprintf(_DEFAULT_THEME, "%s", temp);
+ }
+
+ debug("Using theme %s\n",_DEFAULT_THEME);
debug("%s sudo\n",_DEFAULT_USE_SUDO? "Using" : "Not using");
diff --git a/trayfreq_set.c b/trayfreq_set.c
index 2b8f1d2..7a48af5 100644
--- a/trayfreq_set.c
+++ b/trayfreq_set.c
@@ -111,7 +111,7 @@ void get_argument_summary(int argc, char **argv, argument_summary *argsum)
int main(int argc, char *argv[])
{
setlocale(LC_ALL,"");
- bindtextdomain("trayfreq",LOCALE_DIR);
+ bindtextdomain("trayfreq",LOCALEDIR);
textdomain("trayfreq");
debug("Set gettext up\n");