aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid <dbphillipsnz@gmail.com>2014-05-10 13:31:43 +1200
committerDavid <dbphillipsnz@gmail.com>2014-06-06 20:29:36 +1200
commitc537b4cc6d0bf2cedcb95848328e902c5be50ace (patch)
treeb6bda9925afbef3f4266ba15f3d9e931eee06512
parentbf04ee460a3221f8d4b6caa628a5820375642545 (diff)
downloadparamano-c537b4cc6d0bf2cedcb95848328e902c5be50ace.tar.xz
Better makefile (I got sidetracked)
-rw-r--r--Makefile62
-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.c1
-rw-r--r--defaults.h1
-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.c11
-rw-r--r--reload.h6
-rw-r--r--tray.h10
-rw-r--r--trayfreq.c36
-rw-r--r--trayfreq.h43
-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
diff --git a/Makefile b/Makefile
index 3f7d098..0e49f28 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/defaults.c b/defaults.c
index 6b605fc..1e59095 100644
--- a/defaults.c
+++ b/defaults.c
@@ -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;
diff --git a/defaults.h b/defaults.h
index f1d4202..d1565d2 100644
--- a/defaults.h
+++ b/defaults.h
@@ -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
diff --git a/reload.c b/reload.c
index fcc5ca9..2026365 100644
--- a/reload.c
+++ b/reload.c
@@ -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();
+ }
}
diff --git a/reload.h b/reload.h
index 6ca7cf4..f3b974a 100644
--- a/reload.h
+++ b/reload.h
@@ -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
diff --git a/tray.h b/tray.h
index 223ac26..a9b0eed 100644
--- a/tray.h
+++ b/tray.h
@@ -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>
diff --git a/trayfreq.c b/trayfreq.c
index 4c23982..743bbaf 100644
--- a/trayfreq.c
+++ b/trayfreq.c
@@ -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);