1
#!/bin/sh /usr/share/dpatch/dpatch-run
2
## 01-conglomeration.dpatch
4
## DP: Needs to be broken out (FIXME).
8
diff -Naur osd_clock-0.5.orig/Makefile osd_clock-0.5/Makefile
9
--- osd_clock-0.5.orig/Makefile 2001-03-27 16:38:52.000000000 +0000
10
+++ osd_clock-0.5/Makefile 2007-04-01 07:09:14.000000000 +0000
12
INSTALL=/usr/bin/install -c
13
INSTALL_DATA=$(INSTALL) -m 644
15
-CFLAGS=-O2 -Wall -pipe -I. -DXOSD_VERSION=\"$(VERSION)\" -I/usr/X11R6/include
16
+CFLAGS=$(DCFLAGS) -pipe -I. -DXOSD_VERSION=\"$(VERSION)\" -I/usr/X11R6/include
17
LDFLAGS=-L. -L/usr/X11R6/lib -lX11 -lXext -lpthread -lXt
20
+XOSDLIBS=-lxosd -lXinerama
22
SOURCES=NEWS AUTHORS ChangeLog README COPYING Makefile \
23
osd_clock.c osd_clock.1
24
diff -Naur osd_clock-0.5.orig/osd_clock.1 osd_clock-0.5/osd_clock.1
25
--- osd_clock-0.5.orig/osd_clock.1 2001-03-27 19:22:41.000000000 +0000
26
+++ osd_clock-0.5/osd_clock.1 2007-04-01 07:09:14.000000000 +0000
28
.\" Emacs, -*- nroff -*- please
29
-.TH OSDClock 1osd_clock "March 2001" "X OSD Clock"
30
+.TH OSDClock 1 "March 2001" "X OSD Clock"
32
osd_clock - X on-screen clock displayer
36
[\fIOPTION\fR]... [\fI+FORMAT\fR]
40
\fB\-i\fR \fIINTERVAL\fR
41
This specifies the interval between displays. Default is 1 (display every second).
43
+\fB\-H\fR \fIINTEGER\fR
44
+The "chimes per hour" count overrides \fB\-i\fR. Default is 0 (no effect).
46
+The time will be displayed this many times each hour (notwithstanding signals interrupting sleep, and leap seconds). The first display of the hour will be on the hour exactly. Use \fB-H 4\fR for a display at 0, 15, 30 and 45 minutes past.
48
\fB\-s\fR \fISHADOW\fR
49
This option sets the shadow depth. Default 2.
52
+locate clock at top left (default: bottom left).
55
+locate clock at bottom left (default).
57
\fB\-o\fR \fIOFFSET\fR
58
-This option specifies the offset from the top or bottom of screen the text is displayed. The default is \fI0\fR. Useful to move above or below panels or epplets.
59
+This option specifies the offset from the top or bottom of screen the text is displayed. The default is \fI0\fR. Useful to move above or below panels or applets.
61
\fB\-h\fR, \fB\-\-help\fR
62
display this help and exit
65
+The per-hour mode may fire up to one second late, or worse if the system is busy.
67
Jon Beckham <leftorium@leftorium.net>
69
diff -Naur osd_clock-0.5.orig/osd_clock.c osd_clock-0.5/osd_clock.c
70
--- osd_clock-0.5.orig/osd_clock.c 2001-04-07 22:50:01.000000000 +0000
71
+++ osd_clock-0.5/osd_clock.c 2007-04-01 07:24:10.000000000 +0000
78
static struct option long_options[] = {
79
{"font", 1, NULL, 'f'},
81
{"delay", 1, NULL, 'd'},
82
{"format", 1, NULL, 'F'},
83
{"interval", 1, NULL, 'i'},
84
+ {"perhour", 1, NULL, 'H'},
85
{"shadow", 1, NULL, 's'},
86
{"top", 0, NULL, 't'},
87
{"bottom", 0, NULL, 'b'},
89
{"help", 0, NULL, 'h'},
93
+int secondspast (void) // seconds past the current hour
95
+ time_t now = time(NULL);
96
+ struct tm* now_parts = localtime(&now);
98
+ return now_parts->tm_min * 60 + now_parts->tm_sec;
99
+ // 0 <= x <= 3600, maximum only happens with a leap second
103
int main (int argc, char *argv[])
105
+ setlocale(LC_ALL, "");
108
static const char *format;
111
xosd_pos pos = XOSD_bottom;
113
- char *font = "fixed";
114
+ char *font = osd_default_font;
116
+ char *align = "left";
122
- while ((c = getopt_long(argc ,argv,"f:c:d:F:i:s:o:tbh",
123
+ int perhour = 0; // feature off by default
126
+ while ((c = getopt_long(argc ,argv,"f:c:d:F:i:H:s:o:w:tbhr",
127
long_options, NULL)) != -1)
132
delay = atoi(optarg);
135
+ wait = atoi(optarg);
138
interval = atoi(optarg);
141
+ perhour = atoi(optarg);
144
shadow = atoi(optarg);
154
printf("USAGE: %s [-flag args]\n"
155
- "\t-f\tfully qualified font. default: fixed\n"
156
+ "\t-f\tfully qualified font. default: %s\n"
157
"\t-c\tcolor. default: red\n"
158
"\t-s\tdrop shadow offset. default: 2\n"
159
- "\t-t\tlocate clock at top left (default: bottom left)\n"
160
- "\t-b\tlocate clock at bottom left (default)\n"
161
+ "\t-t\tlocate clock at top of screen (default: bottom)\n"
162
+ "\t-b\tlocate clock at bottom of screen(default)\n"
163
+ "\t-r\tlocate clock at right side (default: left)\n"
164
"\t-o\toffset value to raise or lower around panels. def: 0\n"
165
"\t-F\tSpecify time/date format (in strftime(3) style)\n"
166
"\t-d\tDelay (time the clock stays on screen when it's updated)\n"
168
+ "\t-w\tSeconds to wait before first display (default: 0)\n"
169
"\t-i\tInterval (time between updates) in seconds\n"
170
+ "\t-H\tInteger (displayed this many times each hour)\n"
171
"\t-h\tthis help message\n",
173
+ argv[0], osd_default_font);
181
- osd = xosd_init (font, color, delay, pos, offset, shadow);
182
+ osd = xosd_init (font, color, delay, pos, offset, shadow, 2);
185
fprintf (stderr, "Error initializing osd\n");
189
+ if(align == "right")
191
+ xosd_set_align(osd, XOSD_right);
194
/* If no format is specified, we revert to ctime-ish display */
195
if(!format) format = "%a %b %e %H:%M:%S %G";
197
@@ -127,10 +162,19 @@
198
strftime(output, 255, format, localtime(&curr_time));
200
xosd_display (osd, 1, XOSD_string, output);
204
+ int secs = secondspast();
205
+ int gapseconds = 3600 / perhour; // ick, constant
206
+ int nextshow = (secs / gapseconds) + 1;
208
+ interval = nextshow * gapseconds - secs;
214
+ xosd_destroy (osd);