2020-03-03 23:49:26 +00:00
|
|
|
/*
|
|
|
|
* Mlclock is "Macintsh like clock" .
|
|
|
|
* Written by Hideki Kimata.
|
|
|
|
* Send Email to hideki@hry.info.gifu-u.ac.jp.
|
|
|
|
* Access to http://www.hry.info.gifu-u.ac.jp/~hideki/index.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xlocale.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#define VERSION "1.1"
|
|
|
|
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
#define NONE -1
|
|
|
|
#define MAX_FORM 1000
|
|
|
|
|
|
|
|
#ifndef RCFILE
|
|
|
|
#define RCFILE ".mlclockrc"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FOCUS 0
|
|
|
|
#define CLICK 1
|
|
|
|
#define DEFAULTFONT "-*-*-medium-r-normal--14-*"
|
|
|
|
#define NEAR 10
|
|
|
|
#define FORM1 "(%a)%p%l:%M:%S"
|
|
|
|
#define FORM2 "(%a)%Y.%b.%d"
|
|
|
|
#define DEFAULTLANG "C"
|
|
|
|
|
2020-03-07 16:55:16 +00:00
|
|
|
int Mode; /* timing of change form */
|
|
|
|
int Near; /* the distance of activity */
|
|
|
|
int Head; /* space of window head */
|
|
|
|
char *Form1; /* display form of main */
|
|
|
|
char *Form2; /* display form of second */
|
|
|
|
char *LocaleName; /* locale name */
|
|
|
|
char *FSName; /* font set name */
|
|
|
|
char *RCFile; /* path of config file */
|
|
|
|
int Color[2][3]; /* the color for font and background */
|
|
|
|
int Bold = False; /* software bold font */
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
void SetFont(char *localename, Display *dpy, char *fsname);
|
2020-03-07 15:55:43 +00:00
|
|
|
void readrc();
|
2020-03-07 16:28:09 +00:00
|
|
|
void getRGB(char *color, int *store);
|
|
|
|
void usage(char *name);
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:55:16 +00:00
|
|
|
Display *dpy;
|
|
|
|
Window win;
|
|
|
|
XEvent eve;
|
2020-03-04 00:04:10 +00:00
|
|
|
XRectangle ink, logical;
|
2020-03-07 16:55:16 +00:00
|
|
|
GC gc;
|
|
|
|
XFontSet fs;
|
|
|
|
Colormap cmap;
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 15:55:43 +00:00
|
|
|
struct timeval wait;
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
int main(int argc, char **argv) {
|
2020-03-07 16:55:16 +00:00
|
|
|
char str[MAX_FORM], str2[MAX_FORM], *form = NULL;
|
|
|
|
int screen, sw = False, lsec = 0, uhead, width, height, i;
|
2020-03-07 15:55:43 +00:00
|
|
|
struct tm *tmm;
|
|
|
|
time_t tmt;
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:55:16 +00:00
|
|
|
Window root, child;
|
|
|
|
int rootx, rooty, wx, wy;
|
2020-03-07 15:55:43 +00:00
|
|
|
unsigned int key;
|
2020-03-07 16:55:16 +00:00
|
|
|
XColor xcol;
|
|
|
|
XSizeHints hint;
|
|
|
|
int iro[2];
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 15:55:43 +00:00
|
|
|
wait.tv_usec = 200000;
|
|
|
|
wait.tv_sec = 0;
|
2020-03-06 16:01:08 +00:00
|
|
|
|
2020-03-07 15:55:43 +00:00
|
|
|
str[0] = '\0';
|
|
|
|
i = 1;
|
2020-03-07 16:28:09 +00:00
|
|
|
while ( i < argc ) {
|
|
|
|
if ( !strcmp("-display", argv[i]) ) {
|
2020-03-07 15:55:43 +00:00
|
|
|
i++;
|
2020-03-03 23:49:26 +00:00
|
|
|
if ( argc >= argc )
|
2020-03-07 16:46:51 +00:00
|
|
|
usage(argv[0]);
|
2020-03-07 16:28:09 +00:00
|
|
|
strcpy(str, argv[i]);
|
2020-03-07 15:55:43 +00:00
|
|
|
break;
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 15:55:43 +00:00
|
|
|
usage(argv[0]);
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-03 23:49:26 +00:00
|
|
|
dpy = XOpenDisplay(NULL);
|
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( dpy == NULL ) {
|
|
|
|
fprintf(stderr, "Can't open display.\n");
|
2020-03-07 15:55:43 +00:00
|
|
|
exit(0);
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
screen = DefaultScreen(dpy);
|
|
|
|
gc = DefaultGC(dpy, screen);
|
|
|
|
cmap = DefaultColormap(dpy, screen);
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 15:55:43 +00:00
|
|
|
readrc();
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( XSupportsLocale() == False )
|
2020-03-03 23:49:26 +00:00
|
|
|
fprintf(stderr,"X does not support the locale\n");
|
2020-03-07 16:28:09 +00:00
|
|
|
SetFont(LocaleName, dpy, FSName);
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
XSetForeground(dpy, gc, BlackPixel(dpy, screen));
|
|
|
|
setlocale(LC_TIME, LocaleName);
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
time(&tmt);
|
|
|
|
tmm = localtime(&tmt);
|
2020-03-03 23:49:26 +00:00
|
|
|
tmm->tm_sec = 59;
|
|
|
|
tmm->tm_min = 59;
|
|
|
|
tmm->tm_hour = 23;
|
|
|
|
tmm->tm_mday = 30;
|
|
|
|
tmm->tm_yday = 365;
|
|
|
|
|
2020-03-07 16:01:56 +00:00
|
|
|
strftime(str, MAX_FORM, Form1, tmm);
|
2020-03-07 16:28:09 +00:00
|
|
|
XmbTextExtents(fs, str, strlen(str), &ink, &logical);
|
2020-03-07 15:55:43 +00:00
|
|
|
width=logical.width;
|
|
|
|
uhead = logical.y;
|
|
|
|
height = logical.height;
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:01:56 +00:00
|
|
|
strftime(str, MAX_FORM, Form2, tmm);
|
2020-03-07 16:28:09 +00:00
|
|
|
XmbTextExtents(fs, str, strlen(str), &ink, &logical);
|
2020-03-04 00:04:10 +00:00
|
|
|
if ( width < logical.width )
|
2020-03-07 15:55:43 +00:00
|
|
|
width = logical.width;
|
2020-03-04 00:04:10 +00:00
|
|
|
if ( uhead < logical.y )
|
2020-03-07 15:55:43 +00:00
|
|
|
uhead = logical.y;
|
2020-03-04 00:04:10 +00:00
|
|
|
if ( height < logical.height )
|
2020-03-07 15:55:43 +00:00
|
|
|
height = logical.height;
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 15:55:43 +00:00
|
|
|
xcol.flags = DoRed|DoGreen|DoBlue;
|
2020-03-07 16:30:06 +00:00
|
|
|
for ( i = 0; i < 2; i++ ) {
|
2020-03-07 15:55:43 +00:00
|
|
|
xcol.red = Color[i][0];
|
|
|
|
xcol.green = Color[i][1];
|
|
|
|
xcol.blue = Color[i][2];
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( XAllocColor(dpy, cmap, &xcol) )
|
2020-03-07 15:55:43 +00:00
|
|
|
iro[i] = xcol.pixel;
|
2020-03-07 16:46:51 +00:00
|
|
|
else
|
|
|
|
fprintf(stderr,"Can't allocate Color \n");
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
|
2020-03-07 16:01:56 +00:00
|
|
|
0, 0, width + 3, height + Head + 2, 0,
|
2020-03-07 16:50:48 +00:00
|
|
|
iro[0], iro[1]);
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 15:55:43 +00:00
|
|
|
hint.max_width = hint.min_width = width + 3;
|
|
|
|
hint.max_height = hint.min_height = height + Head + 2;
|
2020-03-03 23:49:26 +00:00
|
|
|
hint.flags = PMinSize | PMaxSize;
|
2020-03-07 16:01:56 +00:00
|
|
|
XSetNormalHints(dpy, win, &hint);
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
XSelectInput(dpy, win, ButtonReleaseMask);
|
|
|
|
XStoreName(dpy, win, "mlclock");
|
|
|
|
XSetForeground(dpy, gc, iro[0]);
|
2020-03-07 16:50:48 +00:00
|
|
|
XSync(dpy, 0);
|
2020-03-07 16:28:09 +00:00
|
|
|
XMapWindow(dpy, win);
|
2020-03-07 16:50:48 +00:00
|
|
|
XSync(dpy, 0);
|
|
|
|
|
2020-03-07 15:55:43 +00:00
|
|
|
str2[0] = '\0';
|
|
|
|
form = Form1;
|
2020-03-07 16:28:09 +00:00
|
|
|
while (1) {
|
|
|
|
select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &wait);
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
time(&tmt);
|
|
|
|
tmm = localtime(&tmt);
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( Mode == FOCUS ) {
|
|
|
|
XQueryPointer(dpy, win, &root, &child, &rootx, &rooty, &wx, &wy, &key);
|
|
|
|
if ( (-Near < wx) && (wx < width + Near) &&
|
2020-03-07 16:46:51 +00:00
|
|
|
(-Near < wy) && (wy < height + Near + Head) )
|
2020-03-07 15:55:43 +00:00
|
|
|
form = Form2;
|
2020-03-07 16:46:51 +00:00
|
|
|
else
|
2020-03-07 15:55:43 +00:00
|
|
|
form = Form1;
|
2020-03-07 16:46:51 +00:00
|
|
|
} else if ( Mode == CLICK ) {
|
|
|
|
if ( XEventsQueued(dpy, QueuedAfterFlush) ) {
|
|
|
|
XNextEvent(dpy, &eve);
|
|
|
|
if ( eve.type == ButtonRelease ) {
|
|
|
|
if ( !sw ) {
|
|
|
|
sw = True;
|
|
|
|
lsec = tmm->tm_sec;
|
|
|
|
form = Form2;
|
|
|
|
} else {
|
|
|
|
sw = False;
|
|
|
|
form = Form1;
|
|
|
|
}
|
|
|
|
}
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:46:51 +00:00
|
|
|
|
|
|
|
if ( sw ) {
|
2020-03-07 16:50:48 +00:00
|
|
|
if ( tmm->tm_sec < lsec )
|
2020-03-07 16:46:51 +00:00
|
|
|
tmm->tm_sec += 60;
|
|
|
|
if ( tmm->tm_sec > lsec + 2 ) {
|
|
|
|
sw = False;
|
|
|
|
form = Form1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:01:56 +00:00
|
|
|
strftime(str, sizeof(str), form, tmm);
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( strcmp(str, str2) ) {
|
|
|
|
XClearWindow(dpy, win);
|
|
|
|
XmbDrawString(dpy, win, fs, gc, 1, - uhead + Head + 1, str, strlen(str));
|
2020-03-03 23:49:26 +00:00
|
|
|
if ( Bold )
|
2020-03-07 16:46:51 +00:00
|
|
|
XmbDrawString(dpy, win, fs, gc, 2, - uhead + Head + 1, str, strlen(str));
|
2020-03-07 16:28:09 +00:00
|
|
|
XSync(dpy, 0);
|
|
|
|
strcpy(str2, str);
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-04 00:04:10 +00:00
|
|
|
|
|
|
|
return 0;
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-07 16:46:51 +00:00
|
|
|
void SetFont(char *localename, Display *dpy, char *fsname) {
|
2020-03-03 23:49:26 +00:00
|
|
|
char **miss, *def;
|
2020-03-07 16:55:16 +00:00
|
|
|
int nMiss;
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( setlocale(LC_ALL, localename) == NULL )
|
2020-03-03 23:49:26 +00:00
|
|
|
fprintf(stderr,"Can't set the locale\n");
|
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
fs = XCreateFontSet(dpy, fsname, &miss, &nMiss, &def);
|
|
|
|
if ( fs == NULL )
|
|
|
|
fprintf(stderr,"Can't get fontset.\n");
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
void readrc() {
|
2020-03-07 16:55:16 +00:00
|
|
|
int i, end, len, sw1, cn = 0;
|
|
|
|
char string[501], work[201], code[100], data[100], *ptr;
|
|
|
|
char *fore, *back;
|
2020-03-03 23:49:26 +00:00
|
|
|
struct _name {
|
2020-03-07 15:55:43 +00:00
|
|
|
char name[10];
|
|
|
|
int sw;
|
|
|
|
};
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:55:16 +00:00
|
|
|
FILE *file;
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:46:51 +00:00
|
|
|
struct _name N[] = {
|
2020-03-07 16:01:56 +00:00
|
|
|
{ "FORM1", 1 },
|
|
|
|
{ "FORM2", 2 },
|
|
|
|
{ "NEAR", 3 },
|
|
|
|
{ "EVENT", 4 },
|
|
|
|
{ "LOCALE", 5 },
|
|
|
|
{ "FONTSET", 6 },
|
|
|
|
{ "HEAD", 7 },
|
|
|
|
{ "FONTCOLOR", 8 },
|
|
|
|
{ "BACKCOLOR", 9 },
|
|
|
|
{ "BOLD", 10 },
|
2020-03-07 16:46:51 +00:00
|
|
|
{ "", 0 }
|
|
|
|
};
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 15:55:43 +00:00
|
|
|
Mode = Near = Head = NONE;
|
|
|
|
Form1 = Form2 = LocaleName = FSName = NULL;
|
2020-03-06 16:01:08 +00:00
|
|
|
|
2020-03-07 16:30:06 +00:00
|
|
|
for ( i = 0; i < 3; i++ ) {
|
2020-03-07 15:55:43 +00:00
|
|
|
Color[0][i] = 0;
|
|
|
|
Color[1][i] = 0xffff;
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
RCFile = malloc(sizeof(RCFILE) + strlen(getenv("HOME")) + 3);
|
|
|
|
sprintf(RCFile, "%s/%s", getenv("HOME"), RCFILE);
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( (file = fopen(RCFile, "r")) == NULL ) {
|
|
|
|
fprintf(stderr, "Can't open \"%s\" file.\n", RCFile);
|
2020-03-07 17:02:09 +00:00
|
|
|
fprintf(stderr, "Now making rc file '%s'.\n", RCFile);
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( (file = fopen(RCFile, "a")) == NULL )
|
|
|
|
fprintf(stderr, "You can't make rc file in your own dirctory.\n");
|
2020-03-07 16:46:51 +00:00
|
|
|
else {
|
2020-03-07 16:28:09 +00:00
|
|
|
fprintf(file, "FORM1 = \"(%%a)%%l:%%M:%%S%%p\"\n");
|
|
|
|
fprintf(file, "FORM2 = \"(%%a)%%b-%%d\"\n");
|
|
|
|
fprintf(file, "EVENT = FOCUS ; FOCUS or CLICK\n");
|
|
|
|
fprintf(file, "NEAR = 10\n");
|
|
|
|
fprintf(file, "LOCALE = \"C\"\n");
|
|
|
|
fprintf(file, "FONTSET = \"-*-*-medium-r-normal--12-*\"\n");
|
|
|
|
fprintf(file, "HEAD = 5\n");
|
|
|
|
fprintf(file, "FONTCOLOR = \"blue\"\n");
|
|
|
|
fprintf(file, "BACKCOLOR = \"white\"\n");
|
|
|
|
fprintf(file, "BOLD = FALSE ; TRUE or FALSE\n");
|
|
|
|
fclose(file);
|
|
|
|
fprintf(stderr, "Created %s file.\n", RCFile);
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:46:51 +00:00
|
|
|
} else {
|
|
|
|
while ( fgets(string, 500, file) ) {
|
|
|
|
end = FALSE;
|
|
|
|
i = 0;
|
|
|
|
sw1 = False;
|
|
|
|
while ( string[i] != ';' && string[i] != '\0' && string[i] != '\n' ) {
|
|
|
|
if ( string[i] == '=' && sw1 == False ) {
|
|
|
|
string[i] = ' ';
|
|
|
|
sw1 = True;
|
|
|
|
}
|
|
|
|
work[i] = string[i];
|
|
|
|
i++;
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:46:51 +00:00
|
|
|
work[i] = '\0';
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:46:51 +00:00
|
|
|
if ( sw1 == False )
|
|
|
|
continue;
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:46:51 +00:00
|
|
|
code[0] = '\0';
|
|
|
|
data[0] = '\0';
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:46:51 +00:00
|
|
|
sscanf(work, "%s %s", code, data);
|
2020-03-07 16:50:48 +00:00
|
|
|
if ( code[0] == '\0' )
|
2020-03-07 16:46:51 +00:00
|
|
|
continue;
|
2020-03-03 23:49:26 +00:00
|
|
|
|
2020-03-07 16:46:51 +00:00
|
|
|
i = 0;
|
|
|
|
while ( True ) {
|
|
|
|
if ( N[i].name[0] == '\0' ) {
|
|
|
|
cn = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( !strcmp(N[i].name, code) ) {
|
|
|
|
cn = N[i].sw;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:46:51 +00:00
|
|
|
switch ( cn ) {
|
|
|
|
case 1:
|
|
|
|
len = strlen(data);
|
|
|
|
Form1 = malloc(len);
|
|
|
|
strcpy(Form1, &data[1]);
|
|
|
|
Form1[len-2] = '\0';
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
len = strlen(data);
|
|
|
|
Form2 = malloc(len);
|
|
|
|
strcpy(Form2, &data[1]);
|
|
|
|
Form2[len-2] = '\0';
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Near = atoi(data);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if ( !strcmp(data, "FOCUS") ) {
|
|
|
|
Mode = FOCUS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( !strcmp(data, "CLICK") ) {
|
|
|
|
Mode = CLICK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
len = strlen(data);
|
|
|
|
LocaleName = malloc(len);
|
|
|
|
strcpy(LocaleName, &data[1]);
|
|
|
|
LocaleName[len-2] = '\0';
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
len = strlen(data);
|
|
|
|
FSName = malloc(len);
|
|
|
|
strcpy(FSName, &data[1]);
|
|
|
|
FSName[len-2] = '\0';
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
Head = atoi(data);
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
len = strlen(data);
|
|
|
|
fore = malloc(len);
|
|
|
|
strcpy(fore, &data[1]);
|
|
|
|
fore[len-2] = '\0';
|
|
|
|
getRGB(fore, Color[0]);
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
len = strlen(data);
|
|
|
|
back = malloc(len);
|
|
|
|
strcpy(back, &data[1]);
|
|
|
|
back[len-2] = '\0';
|
|
|
|
getRGB(back, Color[1]);
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
if ( !strcmp(data, "TRUE") ) {
|
|
|
|
Bold = True;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( !strcmp(data, "FALSE") ) {
|
|
|
|
Bold = False;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-03 23:49:26 +00:00
|
|
|
if ( Mode == NONE )
|
2020-03-07 15:55:43 +00:00
|
|
|
Mode = FOCUS;
|
2020-03-03 23:49:26 +00:00
|
|
|
if ( Near == NONE )
|
2020-03-07 15:55:43 +00:00
|
|
|
Near = NEAR;
|
2020-03-03 23:49:26 +00:00
|
|
|
if ( Head == NONE )
|
2020-03-07 15:55:43 +00:00
|
|
|
Head = 0;
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( Form1 == NULL ) {
|
|
|
|
Form1 = malloc(strlen(FORM1) + 1);
|
|
|
|
strcpy(Form1, FORM1);
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( Form2 == NULL ) {
|
|
|
|
Form2 = malloc(strlen(FORM2) + 1);
|
|
|
|
strcpy(Form2, FORM2);
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( FSName == NULL ) {
|
|
|
|
FSName = malloc(strlen(DEFAULTFONT) + 1);
|
|
|
|
strcpy(FSName, DEFAULTFONT);
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( LocaleName == NULL ) {
|
|
|
|
ptr = getenv("LANG");
|
2020-03-03 23:49:26 +00:00
|
|
|
if ( ptr == NULL )
|
2020-03-07 15:55:43 +00:00
|
|
|
ptr = DEFAULTLANG;
|
2020-03-07 16:28:09 +00:00
|
|
|
LocaleName = malloc(strlen(ptr) + 1);
|
|
|
|
strcpy(LocaleName, ptr);
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
void getRGB(char *color, int *store) {
|
2020-03-07 16:55:16 +00:00
|
|
|
int i;
|
|
|
|
char tmpcolor[3];
|
2020-03-07 16:01:56 +00:00
|
|
|
XColor rgb, hard;
|
2020-03-07 16:50:48 +00:00
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
if ( color[0] == '#' ) {
|
2020-03-07 16:30:06 +00:00
|
|
|
color++;
|
|
|
|
for ( i = 0; i < 3; i++ ) {
|
2020-03-07 16:28:09 +00:00
|
|
|
strncpy(tmpcolor, color, 2);
|
|
|
|
sscanf(tmpcolor, "%x", store);
|
2020-03-07 15:55:43 +00:00
|
|
|
(*store) *= 256;
|
|
|
|
color += 2;
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2020-03-07 16:28:09 +00:00
|
|
|
XLookupColor(dpy, cmap, color, &rgb, &hard);
|
2020-03-07 15:55:43 +00:00
|
|
|
store[0] = hard.red;
|
|
|
|
store[1] = hard.green;
|
|
|
|
store[2] = hard.blue;
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-07 16:28:09 +00:00
|
|
|
void usage(char *name) {
|
|
|
|
printf("%s: usage\n", name);
|
|
|
|
printf(" -display display name\n\n");
|
|
|
|
printf(" Version %s\n", VERSION);
|
2020-03-07 15:55:43 +00:00
|
|
|
printf(" Written by Hideki Kimata\n");
|
2020-03-07 16:28:09 +00:00
|
|
|
printf(" EMail hideki@hry.info.gifu-u.ac.jp\n");
|
|
|
|
printf(" Access to http://www.hry.info.gifu-u.ac.jp/~hideki/index.html\n");
|
2020-03-07 15:55:43 +00:00
|
|
|
exit(0);
|
2020-03-03 23:49:26 +00:00
|
|
|
}
|