diff options
-rw-r--r-- | Makefile | 62 | ||||
-rw-r--r-- | bat_tray.c (renamed from bat_tray/bat_tray.c) | 1 | ||||
-rw-r--r-- | bat_tray.h (renamed from bat_tray/bat_tray.h) | 3 | ||||
-rw-r--r-- | defaults.c | 1 | ||||
-rw-r--r-- | defaults.h | 1 | ||||
-rw-r--r-- | getcore.c (renamed from freq_tray/getcore.c) | 0 | ||||
-rw-r--r-- | getcore.h (renamed from freq_tray/getcore.h) | 2 | ||||
-rw-r--r-- | getfreq.c (renamed from freq_tray/getfreq.c) | 0 | ||||
-rw-r--r-- | getfreq.h (renamed from freq_tray/getfreq.h) | 0 | ||||
-rw-r--r-- | getgov.c (renamed from freq_tray/getgov.c) | 0 | ||||
-rw-r--r-- | getgov.h (renamed from freq_tray/getgov.h) | 0 | ||||
-rw-r--r-- | reload.c | 11 | ||||
-rw-r--r-- | reload.h | 6 | ||||
-rw-r--r-- | tray.h | 10 | ||||
-rw-r--r-- | trayfreq.c | 36 | ||||
-rw-r--r-- | trayfreq.h | 43 | ||||
-rw-r--r-- | trayfreq_set.c (renamed from trayfreq_set/trayfreq_set.c) | 6 | ||||
-rw-r--r-- | trayfreq_set_interface.c (renamed from trayfreq_set/trayfreq_set_interface.c) | 0 | ||||
-rw-r--r-- | trayfreq_set_interface.h (renamed from trayfreq_set/trayfreq_set_interface.h) | 2 |
19 files changed, 138 insertions, 46 deletions
@@ -6,11 +6,24 @@ INSTALL_PATH=/ ifdef DEBUG EXTRA_CFLAGS+=-DDEBUG -else - EXTRA_CFLAGS= endif +DEPS = bat_tray.h \ + bool.h \ + common.h \ + config_file.h \ + debug.h \ + defaults.h \ + getcore.h \ + getfreq.h \ + getgov.h \ + reload.h \ + trayfreq.h \ + tray.h \ + trayfreq_set_interface.h \ + widget_manager.h + GLIB_CFLAGS = -I/usr/include/glib-2.0 \ -I/usr/lib/glib-2.0/include @@ -56,19 +69,41 @@ all: trayfreq trayfreq-set lang ######################################################################## -# Make trayfreq-set program for setting governors -trayfreq-set: - $(CC) -o trayfreq-set $(trayfreq_set_SOURCES) $(trayfreq_set_CFLAGS) $(trayfreq_set_LDFLAGS) $(EXTRA_CFLAGS) +# Make main trayfreq system tray program +trayfreq: bat_tray.o \ + common.o \ + config_file.o \ + defaults.o \ + getcore.o \ + getfreq.o \ + getgov.o \ + reload.o \ + trayfreq.o \ + tray.o \ + trayfreq_set_interface.o \ + widget_manager.o + $(CC) -o $@ $? $(trayfreq_LDFLAGS) + +######################################################################## +# Make trayfreq-set utility +trayfreq-set: \ + trayfreq_set.o \ + getcore.o \ + getfreq.o \ + getgov.o + + $(CC) -o $@ $? $(trayfreq_set_LDFLAGS) ######################################################################## + ######################################################################## -# Make main trayfreq system tray program -trayfreq: - $(CC) -o trayfreq $(trayfreq_SOURCES) $(trayfreq_CFLAGS) $(trayfreq_LDFLAGS) $(EXTRA_CFLAGS) +%.o: %.c $(DEPS) + $(CC) -c -o $@ $< $(trayfreq_CFLAGS) $(EXTRA_CFLAGS) ######################################################################## + ######################################################################## # Make language files lang: @@ -79,7 +114,7 @@ lang: ######################################################################## # Remove generated files clean: - rm -f trayfreq trayfreq-set lc/*.mo + rm -f trayfreq trayfreq-set *.o lang/*.mo ######################################################################## @@ -87,14 +122,17 @@ clean: # Install entire suite install: mkdir -p $(INSTALL_PATH)/usr/share/trayfreq/ - cp data/*.png $(INSTALL_PATH)/usr/share/trayfreq/ - mkdir -p $(INSTALL_PATH)/usr/share/locale/fr/LC_MESSAGES/ + mkdir -p $(INSTALL_PATH)/etc/ + + cp data/*.png $(INSTALL_PATH)/usr/share/trayfreq/ cp lc/fr.mo $(INSTALL_PATH)/usr/share/locale/fr/LC_MESSAGES/trayfreq.mo - install -Dm 644 data/trayfreq.conf $(INSTALL_PATH)/usr/share/trayfreq/trayfreq.conf + install -Dm 644 data/trayfreq.conf $(INSTALL_PATH)/etc/trayfreq.conf install -Dm 644 data/trayfreq.desktop $(INSTALL_PATH)/etc/xdg/autostart/trayfreq.desktop install -Dm 755 trayfreq $(INSTALL_PATH)/usr/bin/trayfreq install -Dm 755 trayfreq-set $(INSTALL_PATH)/usr/bin/trayfreq-set + ln -s /usr/share/licenses/common/GLPv3/license.txt $(INSTALL_PATH)/usr/share/trayfreq/LICENCE + ln -s ../../../etc/trayfreq.conf $(INSTALL_PATH)/usr/share/trayfreq/trayfreq.conf ######################################################################## diff --git a/bat_tray/bat_tray.c b/bat_tray.c index 0037ce4..2f6c7d3 100644 --- a/bat_tray/bat_tray.c +++ b/bat_tray.c @@ -18,7 +18,6 @@ #include "bat_tray.h" -#include "../common.h" #include <gtk/gtk.h> #include <string.h> diff --git a/bat_tray/bat_tray.h b/bat_tray.h index 1d4c993..583de57 100644 --- a/bat_tray/bat_tray.h +++ b/bat_tray.h @@ -20,7 +20,8 @@ #define BAT_TRAY_H #include <glib.h> -#include "../debug.h" +#include "debug.h" +#include "common.h" #define STATE_CHARGING 0 #define STATE_DISCHARGING 1 @@ -23,4 +23,5 @@ char* _DEFAULT_FREQ; char* _DEFAULT_PROG; char* _DEFAULT_BAT_GOV; char* _DEFAULT_AC_GOV; +bool _DEFAULT_SHOW_BATTERY = TRUE; bool _DEFAULT_USE_SUDO = FALSE; @@ -26,6 +26,7 @@ char* _DEFAULT_FREQ; char* _DEFAULT_PROG; char* _DEFAULT_BAT_GOV; char* _DEFAULT_AC_GOV; +bool _DEFAULT_SHOW_BATTERY; bool _DEFAULT_USE_SUDO; #endif /* ifndef DEFAULTS_H */ diff --git a/freq_tray/getcore.c b/getcore.c index ad4878f..ad4878f 100644 --- a/freq_tray/getcore.c +++ b/getcore.c diff --git a/freq_tray/getcore.h b/getcore.h index 43dcd12..67d2f41 100644 --- a/freq_tray/getcore.h +++ b/getcore.h @@ -19,7 +19,7 @@ #ifndef GETCORE_H #define GETCORE_H -#include "../debug.h" +#include "debug.h" void gc_init(); int gc_number(); diff --git a/freq_tray/getfreq.c b/getfreq.c index 4b00775..4b00775 100644 --- a/freq_tray/getfreq.c +++ b/getfreq.c diff --git a/freq_tray/getfreq.h b/getfreq.h index 8df9eca..8df9eca 100644 --- a/freq_tray/getfreq.h +++ b/getfreq.h diff --git a/freq_tray/getgov.c b/getgov.c index 181ad41..181ad41 100644 --- a/freq_tray/getgov.c +++ b/getgov.c diff --git a/freq_tray/getgov.h b/getgov.h index fca341d..fca341d 100644 --- a/freq_tray/getgov.h +++ b/getgov.h @@ -16,7 +16,16 @@ * <http://www.gnu.org/licenses/>. * ************************************************************************/ +#include "reload.h" + void reload_config() { - printf("USR1\n"); + config_init(); + if (_DEFAULT_SHOW_BATTERY) + { + bat_tray_hide(); + bat_tray_show(); + } else { + bat_tray_hide(); + } } @@ -17,5 +17,11 @@ ************************************************************************/ #ifndef RELOAD_H +#define RELOAD_H +#include "trayfreq.h" +#include "defaults.h" +#include "bat_tray.h" +#include <stdio.h> + void reload_config(); #endif @@ -22,11 +22,11 @@ #include <glib.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 "getfreq.h" +#include "getcore.h" +#include "getgov.h" +#include "trayfreq_set_interface.h" +#include "bat_tray.h" #include "defaults.h" #include <gtk/gtk.h> @@ -16,24 +16,7 @@ * <http://www.gnu.org/licenses/>. * ************************************************************************/ -#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 "debug.h" - -#include <gtk/gtk.h> -#include <glib.h> -#include <stdlib.h> -#include <stdio.h> -#include <libintl.h> -#include <locale.h> - -static gboolean SHOW_BATTERY = TRUE; +#include "trayfreq.h" void config_init() { @@ -76,12 +59,12 @@ void config_init() char* temp = config_get_key(&config, "battery", "show"); if (temp) - SHOW_BATTERY = ( temp[0] == '1' ); + _DEFAULT_SHOW_BATTERY = ( temp[0] == '1' ); temp = config_get_key(&config, "extra", "sudo"); if (temp) { - _DEFAULT_USE_SUDO = ( temp[0] == '1' ); + _DEFAULT_USE_SUDO = ( temp[0] == '1' ); debug("woo\n"); } @@ -105,6 +88,16 @@ int main(int argc, char** argv) g_error( _("GTK Error: gtk_init_check returned FALSE.\nBailing.") ); return 1; } + + struct sigaction sig_act; + sig_act.sa_handler = reload_config; + sig_act.sa_flags = 0; + sigemptyset(&sig_act.sa_mask); + + if (sigaction(SIGUSR1, &sig_act, NULL) == -1) + { + debug("WARN: Couldn't set sigaction for SIGUSR1\n"); + } config_init(); gc_init(); gg_init(); @@ -113,12 +106,13 @@ int main(int argc, char** argv) tray_show(); // Show battery tray only if we're supposed to - if(SHOW_BATTERY) + if(_DEFAULT_SHOW_BATTERY) { debug("Showing battery info this time around\n"); bat_tray_init(); bat_tray_show(); } + debug("Passing control to Gtk\n"); gtk_main(); diff --git a/trayfreq.h b/trayfreq.h new file mode 100644 index 0000000..f64ecf4 --- /dev/null +++ b/trayfreq.h @@ -0,0 +1,43 @@ +/************************************************************************ + * This file is part of trayfreq-archlinux. * + * * + * trayfreq-archlinux is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * trayfreq-archlinux is distributed in the hope that it will be useful,* + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with trayfreq-archlinux. If not, see * + * <http://www.gnu.org/licenses/>. * + ************************************************************************/ + +#ifndef TRAYFREQ_H +#define TRAYFREQ_H + +#include "widget_manager.h" +#include "tray.h" +#include "bat_tray.h" +#include "getfreq.h" +#include "getcore.h" +#include "getgov.h" +#include "config_file.h" +#include "reload.h" +#include "defaults.h" +#include "debug.h" + +#include <gtk/gtk.h> +#include <glib.h> +#include <stdlib.h> +#include <stdio.h> +#include <libintl.h> +#include <locale.h> + +void config_init(); +//int main(int argc, char** argv); + +#endif diff --git a/trayfreq_set/trayfreq_set.c b/trayfreq_set.c index 0d65138..785b93b 100644 --- a/trayfreq_set/trayfreq_set.c +++ b/trayfreq_set.c @@ -25,9 +25,9 @@ #include <libintl.h> #include <locale.h> -#include "../freq_tray/getfreq.h" -#include "../freq_tray/getcore.h" -#include "../debug.h" +#include "getfreq.h" +#include "getcore.h" +#include "debug.h" #define FILE_PATH_STRING_SIZE 100 diff --git a/trayfreq_set/trayfreq_set_interface.c b/trayfreq_set_interface.c index 3e26112..3e26112 100644 --- a/trayfreq_set/trayfreq_set_interface.c +++ b/trayfreq_set_interface.c diff --git a/trayfreq_set/trayfreq_set_interface.h b/trayfreq_set_interface.h index c5681e4..bdc13a3 100644 --- a/trayfreq_set/trayfreq_set_interface.h +++ b/trayfreq_set_interface.h @@ -19,7 +19,7 @@ #ifndef TRAYFREQ_SET_INTERFACE_H #define TRAYFREQ_SET_INTERFACE_H -#include "../defaults.h" +#include "defaults.h" void si_gov(char* gov, int core); void si_freq(int freq, int core); |