summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile9
-rw-r--r--config.def.h36
-rw-r--r--udev-block-notify.c47
-rw-r--r--udev-block-notify.h36
5 files changed, 83 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore
index 297e368..b407e5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
*~
*.o
+config.h
udev-block-notify
README.html
version.h
diff --git a/Makefile b/Makefile
index 811b227..a14daa5 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ CC := gcc
MD := markdown
INSTALL := install
RM := rm
+CP := cp
CFLAGS += -std=c11 -O2 -Wall -Werror
CFLAGS += $(shell pkg-config --cflags --libs libudev)
CFLAGS += $(shell pkg-config --cflags --libs libnotify)
@@ -13,9 +14,12 @@ VERSION := 0.7.4
all: udev-block-notify README.html
-udev-block-notify: udev-block-notify.c version.h
+udev-block-notify: udev-block-notify.c config.h version.h
$(CC) $(CFLAGS) -o udev-block-notify udev-block-notify.c
+config.h: config.def.h
+ $(CP) config.def.h config.h
+
version.h: $(wildcard .git/HEAD .git/index .git/refs/tags/*) Makefile
echo "#ifndef VERSION" > $@
echo "#define VERSION \"$(shell git describe --tags --long 2>/dev/null || echo ${VERSION})\"" >> $@
@@ -38,6 +42,9 @@ install-doc: README.html
clean:
$(RM) -f *.o *~ README.html udev-block-notify version.h
+distclean:
+ $(RM) -f *.o *~ README.html udev-block-notify config.h version.h
+
release:
git archive --format=tar.xz --prefix=udev-block-notify-$(VERSION)/ $(VERSION) > udev-block-notify-$(VERSION).tar.xz
gpg -ab udev-block-notify-$(VERSION).tar.xz
diff --git a/config.def.h b/config.def.h
new file mode 100644
index 0000000..543c390
--- /dev/null
+++ b/config.def.h
@@ -0,0 +1,36 @@
+/*
+ * (C) 2011-2015 by Christian Hesse <mail@eworm.de>
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ */
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#define NOTIFICATION_TIMEOUT 10000
+
+#define ICON_DEVICE_MAPPER "media-playlist-shuffle"
+#define ICON_DRIVE_HARDDISK "drive-harddisk"
+#define ICON_DRIVE_HARDDISK_IEEE1394 "drive-harddisk-ieee1394"
+#define ICON_DRIVE_HARDDISK_USB "drive-harddisk-usb"
+#define ICON_DRIVE_OPTICAL "drive-optical"
+#define ICON_DRIVE_MULTIDISK "drive-multidisk"
+#define ICON_LOOP "media-playlist-repeat"
+#define ICON_MEDIA_FLASH "media-flash"
+#define ICON_MEDIA_FLOPPY "media-floppy"
+#define ICON_MEDIA_REMOVABLE "media-removable"
+#define ICON_MEDIA_ZIP "media-zip"
+#define ICON_MULTIMEDIA_PLAYER "multimedia-player"
+#define ICON_NETWORK_SERVER "network-server"
+#define ICON_UNKNOWN "dialog-question"
+
+#define TEXT_TOPIC "Udev Block Notification"
+#define TEXT_ADD "Device <b>%s</b> (%i:%i) <b>appeared</b>."
+#define TEXT_REMOVE "Device <b>%s</b> (%i:%i) <b>disappeared</b>."
+#define TEXT_MOVE "Device <b>%s</b> (%i:%i) was <b>renamed</b>."
+#define TEXT_CHANGE "Device <b>%s</b> (%i:%i) media <b>changed</b>."
+#define TEXT_DEFAULT "Anything happend to <b>%s</b> (%i:%i)... Don't know."
+#define TEXT_TAG "\n%s: <i>%s</i>"
+
+#endif /* CONFIG_H */
diff --git a/udev-block-notify.c b/udev-block-notify.c
index 210b0e8..ef9ba18 100644
--- a/udev-block-notify.c
+++ b/udev-block-notify.c
@@ -5,47 +5,10 @@
* of the GNU General Public License, incorporated herein by reference.
*/
-#define _GNU_SOURCE
-
-#include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <libnotify/notify.h>
-#include <libudev.h>
-
+#include "udev-block-notify.h"
+#include "config.h"
#include "version.h"
-#define PROGNAME "udev-block-notify"
-
-#define NOTIFICATION_TIMEOUT 10000
-
-#define ICON_DEVICE_MAPPER "media-playlist-shuffle"
-#define ICON_DRIVE_HARDDISK "drive-harddisk"
-#define ICON_DRIVE_HARDDISK_IEEE1394 "drive-harddisk-ieee1394"
-#define ICON_DRIVE_HARDDISK_USB "drive-harddisk-usb"
-#define ICON_DRIVE_OPTICAL "drive-optical"
-#define ICON_DRIVE_MULTIDISK "drive-multidisk"
-#define ICON_LOOP "media-playlist-repeat"
-#define ICON_MEDIA_FLASH "media-flash"
-#define ICON_MEDIA_FLOPPY "media-floppy"
-#define ICON_MEDIA_REMOVABLE "media-removable"
-#define ICON_MEDIA_ZIP "media-zip"
-#define ICON_MULTIMEDIA_PLAYER "multimedia-player"
-#define ICON_NETWORK_SERVER "network-server"
-#define ICON_UNKNOWN "dialog-question"
-
-#define TEXT_TOPIC "Udev Block Notification"
-#define TEXT_ADD "Device <b>%s</b> (%i:%i) <b>appeared</b>."
-#define TEXT_REMOVE "Device <b>%s</b> (%i:%i) <b>disappeared</b>."
-#define TEXT_MOVE "Device <b>%s</b> (%i:%i) was <b>renamed</b>."
-#define TEXT_CHANGE "Device <b>%s</b> (%i:%i) media <b>changed</b>."
-#define TEXT_DEFAULT "Anything happend to <b>%s</b> (%i:%i)... Don't know."
-#define TEXT_TAG "\n%s: <i>%s</i>"
-
const static char optstring[] = "hv";
const static struct option options_long[] = {
/* name has_arg flag val */
@@ -54,12 +17,6 @@ const static struct option options_long[] = {
{ 0, 0, 0, 0 }
};
-struct notifications {
- dev_t devnum;
- NotifyNotification *notification;
- struct notifications *next;
-};
-
uint8_t verbose = 0;
/*** get_notification ***/
diff --git a/udev-block-notify.h b/udev-block-notify.h
new file mode 100644
index 0000000..da3c2ba
--- /dev/null
+++ b/udev-block-notify.h
@@ -0,0 +1,36 @@
+/*
+ * (C) 2011-2015 by Christian Hesse <mail@eworm.de>
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ */
+
+#ifndef UDEV_BLOCK_NOTIFY_H
+#define UDEV_BLOCK_NOTIFY_H
+
+#define _GNU_SOURCE
+
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <libnotify/notify.h>
+#include <libudev.h>
+
+#define PROGNAME "udev-block-notify"
+
+struct notifications {
+ dev_t devnum;
+ NotifyNotification *notification;
+ struct notifications *next;
+};
+
+NotifyNotification * get_notification(struct notifications *notifications, dev_t devnum);
+char * newstr(const char *text, char *device, unsigned short int major, unsigned short int minor);
+char * appendstr(const char *text, char *notifystr, char *property, const char *value);
+int main (int argc, char ** argv);
+
+#endif /* UDEV_BLOCK_NOTIFY_H */