1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
Description: Updates for man page and source.
Author: Julien Lemoine <speedblue@debian.org>
Forwarded: no
Last-Update: 2024-06-16
---
diff -Naur osd_clock-0.5.orig/osd_clock.1 osd_clock-0.5/osd_clock.1
--- osd_clock-0.5.orig/osd_clock.1 2001-03-27 19:22:41.000000000 +0000
+++ osd_clock-0.5/osd_clock.1 2007-04-01 07:09:14.000000000 +0000
@@ -1,9 +1,9 @@
.\" Emacs, -*- nroff -*- please
-.TH OSDClock 1osd_clock "March 2001" "X OSD Clock"
+.TH OSDClock 1 "March 2001" "X OSD Clock"
.SH NAME
osd_clock - X on-screen clock displayer
.SH SYNOPSIS
-.B osd_cat
+.B osd_clock
[\fIOPTION\fR]... [\fI+FORMAT\fR]
.SH DESCRIPTION
.PP
@@ -26,15 +26,28 @@
\fB\-i\fR \fIINTERVAL\fR
This specifies the interval between displays. Default is 1 (display every second).
.TP
+\fB\-H\fR \fIINTEGER\fR
+The "chimes per hour" count overrides \fB\-i\fR. Default is 0 (no effect).
+
+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.
+.TP
\fB\-s\fR \fISHADOW\fR
This option sets the shadow depth. Default 2.
.TP
+\fB\-t
+locate clock at top left (default: bottom left).
+.TP
+\fB\-b
+locate clock at bottom left (default).
+.TP
\fB\-o\fR \fIOFFSET\fR
-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.
+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.
.TP
\fB\-h\fR, \fB\-\-help\fR
display this help and exit
.PP
+.SH BUGS
+The per-hour mode may fire up to one second late, or worse if the system is busy.
.SH AUTHOR
Jon Beckham <leftorium@leftorium.net>
.br
diff -Naur osd_clock-0.5.orig/osd_clock.c osd_clock-0.5/osd_clock.c
--- osd_clock-0.5.orig/osd_clock.c 2001-04-07 22:50:01.000000000 +0000
+++ osd_clock-0.5/osd_clock.c 2007-04-01 07:24:10.000000000 +0000
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <getopt.h>
#include <time.h>
+#include <locale.h>
static struct option long_options[] = {
{"font", 1, NULL, 'f'},
@@ -33,6 +34,7 @@
{"delay", 1, NULL, 'd'},
{"format", 1, NULL, 'F'},
{"interval", 1, NULL, 'i'},
+ {"perhour", 1, NULL, 'H'},
{"shadow", 1, NULL, 's'},
{"top", 0, NULL, 't'},
{"bottom", 0, NULL, 'b'},
@@ -40,9 +42,20 @@
{"help", 0, NULL, 'h'},
{NULL, 0, NULL, 0}
};
+
+int secondspast (void) // seconds past the current hour
+{
+ time_t now = time(NULL);
+ struct tm* now_parts = localtime(&now);
+
+ return now_parts->tm_min * 60 + now_parts->tm_sec;
+ // 0 <= x <= 3600, maximum only happens with a leap second
+}
+
int main (int argc, char *argv[])
{
+ setlocale(LC_ALL, "");
char c;
static const char *format;
@@ -51,14 +64,17 @@
xosd *osd;
xosd_pos pos = XOSD_bottom;
- char *font = "fixed";
+ char *font = osd_default_font;
char *color = "red";
+ char *align = "left";
int delay = 3;
int offset = 0;
int shadow = 2;
int interval = 1;
-
- while ((c = getopt_long(argc ,argv,"f:c:d:F:i:s:o:tbh",
+ int perhour = 0; // feature off by default
+ int wait = 0;
+
+ while ((c = getopt_long(argc ,argv,"f:c:d:F:i:H:s:o:w:tbhr",
long_options, NULL)) != -1)
{
switch(c)
@@ -75,9 +91,15 @@
case 'd':
delay = atoi(optarg);
break;
+ case 'w':
+ wait = atoi(optarg);
+ break;
case 'i':
interval = atoi(optarg);
break;
+ case 'H':
+ perhour = atoi(optarg);
+ break;
case 's':
shadow = atoi(optarg);
break;
@@ -90,32 +112,45 @@
case 'b':
pos = XOSD_bottom;
break;
+ case 'r':
+ align = "right";
+ break;
case 'h':
printf("USAGE: %s [-flag args]\n"
- "\t-f\tfully qualified font. default: fixed\n"
+ "\t-f\tfully qualified font. default: %s\n"
"\t-c\tcolor. default: red\n"
"\t-s\tdrop shadow offset. default: 2\n"
- "\t-t\tlocate clock at top left (default: bottom left)\n"
- "\t-b\tlocate clock at bottom left (default)\n"
+ "\t-t\tlocate clock at top of screen (default: bottom)\n"
+ "\t-b\tlocate clock at bottom of screen(default)\n"
+ "\t-r\tlocate clock at right side (default: left)\n"
"\t-o\toffset value to raise or lower around panels. def: 0\n"
"\t-F\tSpecify time/date format (in strftime(3) style)\n"
"\t-d\tDelay (time the clock stays on screen when it's updated)\n"
"\t\tin seconds\n"
+ "\t-w\tSeconds to wait before first display (default: 0)\n"
"\t-i\tInterval (time between updates) in seconds\n"
+ "\t-H\tInteger (displayed this many times each hour)\n"
"\t-h\tthis help message\n",
- argv[0]);
+ argv[0], osd_default_font);
return EXIT_SUCCESS;
break;
}
}
+
+ sleep(wait);
- osd = xosd_init (font, color, delay, pos, offset, shadow);
+ osd = xosd_init (font, color, delay, pos, offset, shadow, 2);
if (!osd)
{
fprintf (stderr, "Error initializing osd\n");
return EXIT_FAILURE;
}
+ if(align == "right")
+ {
+ xosd_set_align(osd, XOSD_right);
+ }
+
/* If no format is specified, we revert to ctime-ish display */
if(!format) format = "%a %b %e %H:%M:%S %G";
@@ -127,10 +162,19 @@
strftime(output, 255, format, localtime(&curr_time));
xosd_display (osd, 1, XOSD_string, output);
+
+ if (perhour)
+ {
+ int secs = secondspast();
+ int gapseconds = 3600 / perhour; // ick, constant
+ int nextshow = (secs / gapseconds) + 1;
+
+ interval = nextshow * gapseconds - secs;
+ }
sleep(interval);
}
- xosd_uninit (osd);
+ xosd_destroy (osd);
return EXIT_SUCCESS;
}
|