add delay option to awesome-message
This commit is contained in:
parent
0bfa880b0f
commit
bf2afc9489
|
@ -22,6 +22,7 @@
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -36,6 +37,8 @@
|
||||||
|
|
||||||
#define PROGNAME "awesome-message"
|
#define PROGNAME "awesome-message"
|
||||||
|
|
||||||
|
static Bool running = True;
|
||||||
|
|
||||||
/** Import awesome config file format */
|
/** Import awesome config file format */
|
||||||
extern cfg_opt_t awesome_opts[];
|
extern cfg_opt_t awesome_opts[];
|
||||||
|
|
||||||
|
@ -58,7 +61,7 @@ static void __attribute__ ((noreturn))
|
||||||
exit_help(int exit_code)
|
exit_help(int exit_code)
|
||||||
{
|
{
|
||||||
FILE *outfile = (exit_code == EXIT_SUCCESS) ? stdout : stderr;
|
FILE *outfile = (exit_code == EXIT_SUCCESS) ? stdout : stderr;
|
||||||
fprintf(outfile, "Usage: %s [-x xcoord] [-y ycoord] <message> <icon>\n",
|
fprintf(outfile, "Usage: %s [-x xcoord] [-y ycoord] [-d delay] <message> <icon>\n",
|
||||||
PROGNAME);
|
PROGNAME);
|
||||||
exit(exit_code);
|
exit(exit_code);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +116,12 @@ config_parse(const char *confpatharg)
|
||||||
p_delete(&confpath);
|
p_delete(&confpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
exit_on_signal(int sig __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
running = False;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -120,10 +129,10 @@ main(int argc, char **argv)
|
||||||
SimpleWindow *sw;
|
SimpleWindow *sw;
|
||||||
DrawCtx *ctx;
|
DrawCtx *ctx;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
Bool running = True;
|
|
||||||
Area geometry = { 0, 0, 200, 50, NULL },
|
Area geometry = { 0, 0, 200, 50, NULL },
|
||||||
icon_geometry = { -1, -1, -1, -1, NULL };
|
icon_geometry = { -1, -1, -1, -1, NULL };
|
||||||
int opt;
|
int opt;
|
||||||
|
int delay = 0;
|
||||||
char *configfile = NULL;
|
char *configfile = NULL;
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
|
@ -137,10 +146,13 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
globalconf.display = disp;
|
globalconf.display = disp;
|
||||||
|
|
||||||
while((opt = getopt_long(argc, argv, "vhf:b:x:y:n:c:",
|
while((opt = getopt_long(argc, argv, "vhf:b:x:y:n:c:d:",
|
||||||
long_options, NULL)) != -1)
|
long_options, NULL)) != -1)
|
||||||
switch(opt)
|
switch(opt)
|
||||||
{
|
{
|
||||||
|
case 'd':
|
||||||
|
delay = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
eprint_version(PROGNAME);
|
eprint_version(PROGNAME);
|
||||||
break;
|
break;
|
||||||
|
@ -200,20 +212,27 @@ main(int argc, char **argv)
|
||||||
XMapRaised(disp, sw->window);
|
XMapRaised(disp, sw->window);
|
||||||
XSync(disp, False);
|
XSync(disp, False);
|
||||||
|
|
||||||
while (running)
|
signal(SIGALRM, &exit_on_signal);
|
||||||
|
alarm(delay);
|
||||||
|
|
||||||
|
while(running)
|
||||||
{
|
{
|
||||||
XNextEvent(disp, &ev);
|
if(XPending(disp))
|
||||||
switch (ev.type)
|
|
||||||
{
|
{
|
||||||
case ButtonPress:
|
XNextEvent(disp, &ev);
|
||||||
case KeyPress:
|
switch(ev.type)
|
||||||
running = False;
|
{
|
||||||
case Expose:
|
case ButtonPress:
|
||||||
simplewindow_refresh_drawable(sw, DefaultScreen(disp));
|
case KeyPress:
|
||||||
break;
|
running = False;
|
||||||
default:
|
case Expose:
|
||||||
break;
|
simplewindow_refresh_drawable(sw, DefaultScreen(disp));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
sleep(0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
simplewindow_delete(sw);
|
simplewindow_delete(sw);
|
||||||
|
|
Loading…
Reference in New Issue