~ubuntu-branches/ubuntu/raring/osdclock/raring

« back to all changes in this revision

Viewing changes to debian/patches/01-conglomeration.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-06-20 09:52:00 UTC
  • mfrom: (4.1.4 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080620095200-6fofqvnwb3g6vcd1
Tags: 0.5-22
Orphaning package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh /usr/share/dpatch/dpatch-run
 
2
## 01-conglomeration.dpatch
 
3
##
 
4
## DP: Needs to be broken out (FIXME).
 
5
 
 
6
@DPATCH@
 
7
 
 
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
 
11
@@ -13,10 +13,10 @@
 
12
 INSTALL=/usr/bin/install -c
 
13
 INSTALL_DATA=$(INSTALL) -m 644
 
14
 
 
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
 
18
 
 
19
-XOSDLIBS=-lxosd
 
20
+XOSDLIBS=-lxosd -lXinerama
 
21
 
 
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
 
27
@@ -1,9 +1,9 @@
 
28
 .\" Emacs, -*- nroff -*- please
 
29
-.TH OSDClock 1osd_clock "March 2001" "X OSD Clock"
 
30
+.TH OSDClock 1 "March 2001" "X OSD Clock"
 
31
 .SH NAME
 
32
 osd_clock - X on-screen clock displayer
 
33
 .SH SYNOPSIS
 
34
-.B osd_cat
 
35
+.B osd_clock
 
36
 [\fIOPTION\fR]... [\fI+FORMAT\fR]
 
37
 .SH DESCRIPTION
 
38
 .PP
 
39
@@ -26,15 +26,28 @@
 
40
 \fB\-i\fR \fIINTERVAL\fR
 
41
 This specifies the interval between displays.  Default is 1 (display every second).
 
42
 .TP
 
43
+\fB\-H\fR \fIINTEGER\fR
 
44
+The "chimes per hour" count overrides \fB\-i\fR. Default is 0 (no effect).
 
45
+
 
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.
 
47
+.TP
 
48
 \fB\-s\fR \fISHADOW\fR
 
49
 This option sets the shadow depth.  Default 2.
 
50
 .TP
 
51
+\fB\-t
 
52
+locate clock at top left (default: bottom left).
 
53
+.TP
 
54
+\fB\-b
 
55
+locate clock at bottom left (default).
 
56
+.TP
 
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.
 
60
 .TP
 
61
 \fB\-h\fR, \fB\-\-help\fR
 
62
 display this help and exit
 
63
 .PP
 
64
+.SH BUGS
 
65
+The per-hour mode may fire up to one second late, or worse if the system is busy.
 
66
 .SH AUTHOR
 
67
 Jon Beckham <leftorium@leftorium.net>
 
68
 .br
 
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
 
72
@@ -26,6 +26,7 @@
 
73
 #include <unistd.h>
 
74
 #include <getopt.h>
 
75
 #include <time.h>
 
76
+#include <locale.h>
 
77
 
 
78
 static struct option long_options[] = {
 
79
   {"font",     1, NULL, 'f'},
 
80
@@ -33,6 +34,7 @@
 
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'},
 
88
@@ -40,9 +42,20 @@
 
89
   {"help",     0, NULL, 'h'},
 
90
   {NULL,       0, NULL, 0}
 
91
 };
 
92
+
 
93
+int secondspast (void) // seconds past the current hour
 
94
+{
 
95
+  time_t now = time(NULL);
 
96
+  struct tm* now_parts = localtime(&now);
 
97
+
 
98
+  return now_parts->tm_min * 60 + now_parts->tm_sec;
 
99
+  // 0 <= x <= 3600, maximum only happens with a leap second
 
100
+}
 
101
+
 
102
 
 
103
 int main (int argc, char *argv[])
 
104
 {
 
105
+  setlocale(LC_ALL, "");
 
106
   char c;
 
107
   
 
108
   static const char *format;
 
109
@@ -51,14 +64,17 @@
 
110
   xosd *osd;
 
111
   xosd_pos pos = XOSD_bottom;
 
112
 
 
113
-  char *font = "fixed";
 
114
+  char *font = osd_default_font;
 
115
   char *color = "red";
 
116
+  char *align = "left";
 
117
   int delay = 3; 
 
118
   int offset = 0;
 
119
   int shadow = 2;
 
120
   int interval = 1;
 
121
-
 
122
-  while ((c = getopt_long(argc ,argv,"f:c:d:F:i:s:o:tbh",
 
123
+  int perhour = 0; // feature off by default
 
124
+  int wait = 0;
 
125
+
 
126
+  while ((c = getopt_long(argc ,argv,"f:c:d:F:i:H:s:o:w:tbhr",
 
127
                          long_options, NULL)) != -1)
 
128
   {
 
129
     switch(c)
 
130
@@ -75,9 +91,15 @@
 
131
       case 'd':
 
132
        delay = atoi(optarg);
 
133
        break;
 
134
+      case 'w':
 
135
+       wait = atoi(optarg);
 
136
+       break;
 
137
       case 'i':
 
138
        interval = atoi(optarg);
 
139
        break;
 
140
+      case 'H':
 
141
+        perhour = atoi(optarg);
 
142
+        break;
 
143
       case 's':
 
144
        shadow = atoi(optarg);
 
145
        break;
 
146
@@ -90,32 +112,45 @@
 
147
       case 'b':
 
148
        pos = XOSD_bottom;
 
149
        break;
 
150
+      case 'r':
 
151
+       align = "right";
 
152
+       break;
 
153
       case 'h':
 
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"
 
167
                "\t\tin seconds\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",
 
172
-               argv[0]);
 
173
+               argv[0], osd_default_font);
 
174
        return EXIT_SUCCESS;
 
175
        break;
 
176
     }
 
177
   }
 
178
+
 
179
+  sleep(wait);
 
180
   
 
181
-  osd = xosd_init (font, color, delay, pos, offset, shadow);
 
182
+  osd = xosd_init (font, color, delay, pos, offset, shadow, 2);
 
183
   if (!osd)
 
184
   {
 
185
     fprintf (stderr, "Error initializing osd\n");
 
186
     return EXIT_FAILURE;
 
187
   }
 
188
 
 
189
+  if(align == "right")
 
190
+  {
 
191
+    xosd_set_align(osd, XOSD_right);
 
192
+  }
 
193
+  
 
194
   /* If no format is specified, we revert to ctime-ish display */ 
 
195
   if(!format) format = "%a %b %e %H:%M:%S %G";
 
196
 
 
197
@@ -127,10 +162,19 @@
 
198
     strftime(output, 255, format, localtime(&curr_time));
 
199
 
 
200
     xosd_display (osd, 1, XOSD_string, output);
 
201
+
 
202
+    if (perhour)
 
203
+    {
 
204
+      int secs = secondspast();
 
205
+      int gapseconds = 3600 / perhour; // ick, constant
 
206
+      int nextshow = (secs / gapseconds) + 1;
 
207
+
 
208
+      interval = nextshow * gapseconds - secs;
 
209
+    }
 
210
     sleep(interval);
 
211
   }
 
212
 
 
213
-  xosd_uninit (osd);
 
214
+  xosd_destroy (osd);
 
215
   
 
216
   return EXIT_SUCCESS;
 
217
 }