diff options
author | sabetts <sabetts> | 2001-01-02 15:31:27 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2001-01-02 15:31:27 +0000 |
commit | 9c8531f93556e3b7fe1e2c900c6913532f90b818 (patch) | |
tree | a9c8efdf1d6f62863e8853662912a5a4e5c9524c /src | |
parent | 3f6a681c54a8984c84959d4eaf5e222467bd3d00 (diff) | |
download | ratpoison-9c8531f93556e3b7fe1e2c900c6913532f90b818.zip |
* actions.h (show_clock): added prototype
* actions.c (show_clock): added
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 6 | ||||
-rw-r--r-- | src/actions.c | 38 | ||||
-rw-r--r-- | src/actions.h | 1 | ||||
-rw-r--r-- | src/config.h.in | 3 |
4 files changed, 47 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 653c81c..bd202b9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2001-01-02 shawn <sabetts@diggin.lamenet.tmp> + + * actions.h (show_clock): added prototype + + * actions.c (show_clock): added + 2000-12-15 shawn <sabetts@badbox.secure.basis.org> * actions.c (maximize): increment size in hints->width_inc and hints->height_inc intervals diff --git a/src/actions.c b/src/actions.c index 84be700..eb1549c 100644 --- a/src/actions.c +++ b/src/actions.c @@ -4,12 +4,14 @@ #include <unistd.h> #include <sys/wait.h> #include <X11/keysym.h> +#include <string.h> +#include <time.h> #include "ratpoison.h" /* Initialization of the key structure */ rp_action key_actions[] = { {KEY_PREFIX, 0, 0, generate_prefix}, - {XK_c, -1, "xterm", spawn}, + {XK_c, -1, TERM_PROG, spawn}, {XK_e, -1, "emacs", spawn}, {XK_p, -1, 0, prev_window}, {XK_n, -1, 0, next_window}, @@ -226,6 +228,40 @@ bye(void *dummy) exit (EXIT_SUCCESS); } +/* Show the current time on the bar. Thanks to + Martin Samuelsson <cosis@lysator.liu.se> for the patch. */ +void +show_clock (void *data) +{ + screen_info *s; + char *msg; + time_t timep; + + msg = malloc(9); + if(msg == NULL) + { + PRINT_DEBUG ("Error allocation memory in show_clock()\n"); + return; + } + + timep = time(NULL); + if(timep == ((time_t)-1)) + { + perror("In show_clock() "); + return; + } + + strncpy(msg, ctime(&timep) + 11, 8); /* FIXME: a little bit hardcoded looking */ + msg[8] = '\0'; + + if (rp_current_window) + { + s = rp_current_window->scr; + display_msg_in_bar (s, msg); + } + free(msg); +} + void goto_window_number (int n) { diff --git a/src/actions.h b/src/actions.h index b1690a5..b9fc2a1 100644 --- a/src/actions.h +++ b/src/actions.h @@ -26,5 +26,6 @@ void next_window (void *data); void prev_window (void *data); void toggle_bar (void *data); void maximize (void *data); +void show_clock (void *data); extern rp_action key_actions[]; diff --git a/src/config.h.in b/src/config.h.in index 76ebff8..5916cce 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -15,6 +15,9 @@ /* When defined, ratpoison will print debugging information */ #undef DEBUG +/* X terminal emulator to user */ +#undef TERM_PROG + /* Define if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H |