Old code called alarm() regularly and checked for input only at certain
times. Now, the file descriptor for reading the text is added to the
select() in the main loop, and so updates are caught immediately and
efficiently.
Patch submitted by Jason Woofenden <jason@jasonwoof.com>
(Note: Minor modifications were made to formatting and a dummy version
of the bar_delay option was added to avoid breaking old conf files.)
Disable border by setting to 0.
.It Ic bar_color Ns Bq Ar x
Color of the status bar window in screen
Disable border by setting to 0.
.It Ic bar_color Ns Bq Ar x
Color of the status bar window in screen
-.Ar x .
-.It Ic bar_delay
-Update frequency, in seconds, of external script that populates the status
-bar.
.It Ic bar_enabled
Set default
.Ar bar_toggle
.It Ic bar_enabled
Set default
.Ar bar_toggle
char bar_ext[SWM_BAR_MAX];
char bar_vertext[SWM_BAR_MAX];
int bar_version = 0;
char bar_ext[SWM_BAR_MAX];
char bar_vertext[SWM_BAR_MAX];
int bar_version = 0;
-sig_atomic_t bar_alarm = 0;
-int bar_delay = 30;
int bar_enabled = 1;
int bar_border_width = 1;
int bar_at_bottom = 0;
int bar_enabled = 1;
int bar_border_width = 1;
int bar_at_bottom = 0;
char * bar_replace_seq(char *, char *, struct swm_region *, size_t *,
size_t);
void bar_setup(struct swm_region *);
char * bar_replace_seq(char *, char *, struct swm_region *, size_t *,
size_t);
void bar_setup(struct swm_region *);
void bar_title_name(char *, size_t, struct swm_region *);
void bar_toggle(struct swm_region *, union arg *);
void bar_update(void);
void bar_title_name(char *, size_t, struct swm_region *);
void bar_toggle(struct swm_region *, union arg *);
void bar_update(void);
- if (!bar_enabled)
- return;
- if (bar_extra && bar_extra_running) {
- /* ignore short reads; it'll correct itself */
+ if (bar_enabled && bar_extra && bar_extra_running) {
+ /* Ignore short reads; it'll correct itself. */
while ((b = fgetln(stdin, &len)) != NULL)
if (b && b[len - 1] == '\n') {
b[len - 1] = '\0';
while ((b = fgetln(stdin, &len)) != NULL)
if (b && b[len - 1] == '\n') {
b[len - 1] = '\0';
warn("bar_update: bar_extra failed");
bar_extra_stop();
}
warn("bar_update: bar_extra failed");
bar_extra_stop();
}
- } else
- strlcpy(bar_ext, "", sizeof bar_ext);
+ } else {
+ /*
+ * Attempt to drain stdin, so it doesn't cause the main loop to
+ * call us as fast as it can.
+ */
+ fgetln(stdin, &len);
- bar_fmt_print();
- alarm(bar_delay);
-}
+ if (!bar_enabled)
+ return;
-void
-bar_signal(int sig)
-{
- /* suppress unused warning since var is needed */
- (void)sig;
err(1, "pipe error");
socket_setnonblock(bar_pipe[0]);
socket_setnonblock(bar_pipe[1]); /* XXX hmmm, really? */
err(1, "pipe error");
socket_setnonblock(bar_pipe[0]);
socket_setnonblock(bar_pipe[1]); /* XXX hmmm, really? */
+
+ /* Set stdin to read from the pipe. */
if (dup2(bar_pipe[0], 0) == -1)
err(1, "dup2");
if (dup2(bar_pipe[0], 0) == -1)
err(1, "dup2");
+
+ /* Set stdout to write to the pipe. */
if (dup2(bar_pipe[1], 1) == -1)
err(1, "dup2");
if (dup2(bar_pipe[1], 1) == -1)
err(1, "dup2");
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
err(1, "could not disable SIGPIPE");
switch (bar_pid = fork()) {
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
err(1, "could not disable SIGPIPE");
switch (bar_pid = fork()) {
xcb_change_window_attributes(conn, r->bar->id,
XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL, wa);
}
xcb_change_window_attributes(conn, r->bar->id,
XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL, wa);
}
"%d x %d\n", WINID(r->bar), X(r->bar), Y(r->bar), WIDTH(r->bar),
HEIGHT(r->bar));
"%d x %d\n", WINID(r->bar), X(r->bar), Y(r->bar), WIDTH(r->bar),
HEIGHT(r->bar));
- if (signal(SIGALRM, bar_signal) == SIG_ERR)
- err(1, "could not install bar_signal");
bar_border_width = 0;
break;
case SWM_S_BAR_DELAY:
bar_border_width = 0;
break;
case SWM_S_BAR_DELAY:
- bar_delay = atoi(value);
+ /* No longer needed; leave to not break old conf files. */
break;
case SWM_S_BAR_ENABLED:
bar_enabled = atoi(value);
break;
case SWM_S_BAR_ENABLED:
bar_enabled = atoi(value);
xcb_generic_event_t *evt;
struct timeval tv;
fd_set rd;
xcb_generic_event_t *evt;
struct timeval tv;
fd_set rd;
+ int rd_max;
+ int do_bar_update = 0;
+ int num_readable;
/* suppress unused warning since var is needed */
(void)argc;
/* suppress unused warning since var is needed */
(void)argc;
xcb_ungrab_server(conn);
xcb_flush(conn);
xcb_ungrab_server(conn);
xcb_flush(conn);
+ rd_max = xfd > STDIN_FILENO ? xfd : STDIN_FILENO;
+
while (running) {
while ((evt = xcb_poll_for_event(conn))) {
if (!running)
while (running) {
while ((evt = xcb_poll_for_event(conn))) {
if (!running)
+ FD_SET(STDIN_FILENO, &rd);
FD_SET(xfd, &rd);
tv.tv_sec = 1;
tv.tv_usec = 0;
FD_SET(xfd, &rd);
tv.tv_sec = 1;
tv.tv_usec = 0;
- if (select(xfd + 1, &rd, NULL, NULL, &tv) == -1)
- if (errno != EINTR) {
- DNPRINTF(SWM_D_MISC, "select failed");
- }
+ num_readable = select(rd_max + 1, &rd, NULL, NULL, &tv);
+ if (num_readable == -1 && errno != EINTR)
+ DNPRINTF(SWM_D_MISC, "select failed");
+ else if (num_readable > 0 && FD_ISSET(STDIN_FILENO, &rd))
+ do_bar_update = 1;
+
if (restart_wm)
restart(NULL, NULL);
if (restart_wm)
restart(NULL, NULL);
if (search_resp)
search_do_resp();
if (search_resp)
search_do_resp();
- if (bar_alarm) {
- bar_alarm = 0;
+
+ if (do_bar_update) {
+ do_bar_update = 0;
# bar_font_color[1] = rgb:a0/a0/a0
# bar_font = -*-terminus-medium-*-*-*-*-*-*-*-*-*-*-*
# bar_action = baraction.sh
# bar_font_color[1] = rgb:a0/a0/a0
# bar_font = -*-terminus-medium-*-*-*-*-*-*-*-*-*-*-*
# bar_action = baraction.sh
# bar_justify = left
# bar_format = +N:+I +S <+D>+4<%a %b %d %R %Z %Y+8<+A+4<+V
# bar_at_bottom = 1
# bar_justify = left
# bar_format = +N:+I +S <+D>+4<%a %b %d %R %Z %Y+8<+A+4<+V
# bar_at_bottom = 1
.It Cm bar_action
Scripts externos con populares agregados de información para la barra
de estado, como la vida de la bateria.
.It Cm bar_action
Scripts externos con populares agregados de información para la barra
de estado, como la vida de la bateria.
-.It Cm bar_delay
-Frecuencia de actualización, en segundos, de los scripts de la barra de
-estado.
.It Cm bar_at_bottom
Puedes posicionar la statusbar en la parte inferior de la pantalla.
.It Cm stack_enabled
.It Cm bar_at_bottom
Puedes posicionar la statusbar en la parte inferior de la pantalla.
.It Cm stack_enabled
.It Cm bar_action
Script esterno che aggiunge informazioni come la carica della batteria alla
barra di stato.
.It Cm bar_action
Script esterno che aggiunge informazioni come la carica della batteria alla
barra di stato.
-.It Cm bar_delay
-Frequenza di aggiornamento, in secondi, dello script esterno che aggiunge
-informazioni alla barra di stato.
.It Cm bar_at_bottom
Posiziona la barra di stato sul fondo dello schermo anzich? in cima.
.It Cm stack_enabled
.It Cm bar_at_bottom
Posiziona la barra di stato sul fondo dello schermo anzich? in cima.
.It Cm stack_enabled
.It Cm bar_action
Script externo que preenche a barra de status com informa\(,c\(~oes adicionais,
como tempo de vida da bateria.
.It Cm bar_action
Script externo que preenche a barra de status com informa\(,c\(~oes adicionais,
como tempo de vida da bateria.
-.It Cm bar_delay
-Freq\(:u\(^encia da atualiza\(,c\(~ao, em segundos, do script externo que preenche
-a barra de status.
.It Cm bar_at_bottom
Coloca a barra de status na parte inferior de cada regi\(~ao, ao inv\('es da parte superior.
.It Cm stack_enabled
.It Cm bar_at_bottom
Coloca a barra de status na parte inferior de cada regi\(~ao, ao inv\('es da parte superior.
.It Cm stack_enabled
.It Cm bar_action
Внешний файл скрипта для статусной строки, выводящий туда информацию,
например, уровень заряда батарей.
.It Cm bar_action
Внешний файл скрипта для статусной строки, выводящий туда информацию,
например, уровень заряда батарей.
-.It Cm bar_delay
-Частота выполнения внешнего скрипта статусной строки, секунды.
.It Cm stack_enabled
Включить отображение способа укладки окон в статусной строке.
.It Cm clock_enabled
.It Cm stack_enabled
Включить отображение способа укладки окон в статусной строке.
.It Cm clock_enabled