+VERSION=1.0
+ARCHIVE=osdd-$(VERSION).tar.gz
+
CFLAGS=-O2 -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wredundant-decls -std=gnu99
all: osdd osdc osd-batt
osdd: osdd.o util.o
osdc: osdc.o util.o client.o
-osd-batt: osd-batt.o util.o client.o loop.o
+osd-batt: osd-batt.o util.o client.o
osdd.o: CFLAGS+=$(shell xosd-config --cflags)
osdd: LDFLAGS+=$(shell xosd-config --libs)
clean:
rm -f *~ *.o TAGS core osdd osdc
+
+release:
+ git tag v$(VERSION)
+ git push --tags
+ git archive --format=tar --prefix=osdd-$(VERSION)/ HEAD | gzip >$(ARCHIVE)
+ scp $(ARCHIVE) atrey:~ftp/pub/local/mj/linux/
+ ssh jw "cd www && bin/release-prog osdd $(VERSION)"
+ mv $(ARCHIVE) ~/archives/mj/
--- /dev/null
+================================================================================
+
+ On-Screen Display Daemon
+
+ (c) 2010 Martin Mares <mj@ucw.cz>
+
+ You can use and distribute this program under the terms of GPLv2.
+
+================================================================================
+
+
+OSDD is a simple daemon whose purpose is to wait for messages sent by other
+programs and display them on the screen using libxosd. Unlike other such
+daemons, it handles message attributes (like colors), keeps its eye on
+message timing and uses X properties to pass messages, so it works over SSH
+connections with X forwarding.
+
+I have developed osdd on Linux, but it should work on any recent POSIX-compliant
+system equipped with libX11 and libxosd.
+
+Please send all bug reports and suggestions to the author.
+
+Usage
+~~~~~
+When you run `osdd' without any parameters, it forks and waits in the background
+to serve the messages. It is convenient to invoke it from ~/.xsession, so that
+it is started with your X session. It should exit properly when the session
+terminates.
+
+The simplest way of sending messages to the daemon is using the `osdc' client,
+e.g., `osdc "Hello world!"'. Use multiple parameters to create a multi-line
+message (however, the maximum number of lines is fixed and it can be changed
+only by the `--lines' switch on daemon startup).
+
+You can also add attributes to the message (written as command-line options):
+
+ --color=c Set foreground color of the message. Colors are specified
+ either as #RGB, or #RRGGBB, or color names from X11 rgb.txt,
+ or any other method documented in XParseColor(3).
+
+ --outline-color=c Set color of character outlines.
+
+ --duration=ms Show the message for a given number of miliseconds.
+
+ --min-duration=ms When another message arrives while this one is displayed,
+ the duration of this message can be shortened, but not
+ below this parameter.
+
+ --percent=p Draw a line with a percentage bar (p=0..100)
+
+ --slider=p Draw a line with a slider (p=0..100)
+
+The default values of most of these attributes can be given by command-line
+options of the daemon, use `osdd --help' to get the full list.
+
+Any value can be replaced by "-", meaning "read from standard input".
+
+
+Example clients
+~~~~~~~~~~~~~~~
+
+osd-clock Display current date and time (a shell script piping
+ its output to osdc).
+
+osd-mpc-volume Adjust volume of the MPD music player daemon and show
+ a slider with the new value.
+
+osd-batt A slightly more complex client written in C, showing
+ the current status of laptop batteries. It can be asked
+ to show status immediately or to run in background and
+ croak whenever the battery is low.
#include <unistd.h>
#include <poll.h>
#include <getopt.h>
+#include <locale.h>
#include <xosd.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
static char *default_color = "green";
static char *default_outline_color = "black";
static int default_duration = 1000;
-static int default_min_duration = 1000;
+static int default_min_duration = 250;
static int debug_mode;
static const char short_opts[] = "c:d:Df:l:m:o:";
main(int argc, char **argv)
{
parse_opts(argc, argv);
+ setlocale(LC_CTYPE, "");
XInitThreads();
Display *dpy = XOpenDisplay(NULL);