Skip to content
This repository has been archived by the owner on Jan 15, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into xft-port
Browse files Browse the repository at this point in the history
* upstream/master:
  Set the WM_NAME for all the windows.
  Don't use optarg directly when parsing the -n switch argument.
  Silence a warning about write() result being unused.
  Update the .travis.yml to build all the features
  Make it possible to build lemonbar w/o XINERAMA support
  Add pixel offset
  Document literal percent sign under formatting
  • Loading branch information
krypt-n committed Nov 7, 2016
2 parents a43b801 + d680ea4 commit 7890857
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ compiler:
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y libx11-xcb-dev libxcb-randr0-dev libxcb-xinerama0-dev
env:
- CFLAGS='-DWITH_XINERAMA=1'
script: make
2 changes: 1 addition & 1 deletion README.pod
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Set the underline color of the bar. Accepts the same color formats as B<-B>.

=head1 FORMATTING

lemonbar provides a screenrc-inspired formatting syntax to allow full customization at runtime. Every formatting block is opened with B<%{> and closed by B<}> and accepts the following commands, the parser tries it's best to handle malformed input.
lemonbar provides a screenrc-inspired formatting syntax to allow full customization at runtime. Every formatting block is opened with C<%{> and closed by C<}> and accepts the following commands, the parser tries it's best to handle malformed input. Use C<%%> to get a literal percent sign (C<%>).

=over

Expand Down
22 changes: 16 additions & 6 deletions lemonbar.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// vim:sw=4:ts=4:et:
#define _POSIX_C_SOURCE 200809L
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
Expand All @@ -12,7 +13,9 @@
#include <errno.h>
#include <xcb/xcb.h>
#include <xcb/xcbext.h>
#if WITH_XINERAMA
#include <xcb/xinerama.h>
#endif
#include <xcb/randr.h>

#include <X11/Xft/Xft.h>
Expand Down Expand Up @@ -1116,6 +1119,7 @@ get_randr_monitors (void)
monitor_create_chain(r, valid);
}

#ifdef WITH_XINERAMA
void
get_xinerama_monitors (void)
{
Expand Down Expand Up @@ -1144,6 +1148,7 @@ get_xinerama_monitors (void)

monitor_create_chain(rects, screens);
}
#endif

xcb_visualid_t
get_visual (void)
Expand Down Expand Up @@ -1274,8 +1279,10 @@ init (char *wm_name)
qe_reply = xcb_get_extension_data(c, &xcb_randr_id);

if (qe_reply && qe_reply->present) {
get_randr_monitors();
} else {
get_randr_monitors();
}
#if WITH_XINERAMA
else {
qe_reply = xcb_get_extension_data(c, &xcb_xinerama_id);

// Check if Xinerama extension is present and active
Expand All @@ -1289,6 +1296,7 @@ init (char *wm_name)
free(xia_reply);
}
}
#endif

if (!monhead) {
// If I fits I sits
Expand Down Expand Up @@ -1336,7 +1344,7 @@ init (char *wm_name)

// Set the WM_NAME atom to the user specified value
if (wm_name)
xcb_change_property(c, XCB_PROP_MODE_REPLACE, monhead->window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8 ,strlen(wm_name), wm_name);
xcb_change_property(c, XCB_PROP_MODE_REPLACE, mon->window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8 ,strlen(wm_name), wm_name);
}

char color[] = "#ffffff";
Expand Down Expand Up @@ -1446,7 +1454,7 @@ main (int argc, char **argv)
exit (EXIT_SUCCESS);
case 'g': (void)parse_geometry_string(optarg, geom_v); break;
case 'p': permanent = true; break;
case 'n': wm_name = optarg; break;
case 'n': wm_name = strdup(optarg); break;
case 'b': topbar = false; break;
case 'd': dock = true; break;
case 'f': font_load(optarg); break;
Expand Down Expand Up @@ -1482,6 +1490,8 @@ main (int argc, char **argv)

// Do the heavy lifting
init(wm_name);
// The string is strdup'd when the command line arguments are parsed
free(wm_name);
// Get the fd to Xserver
pollin[1].fd = xcb_get_file_descriptor(c);
for (;;) {
Expand Down Expand Up @@ -1518,8 +1528,8 @@ main (int argc, char **argv)
area_t *area = area_get(press_ev->event, press_ev->detail, press_ev->event_x);
// Respond to the click
if (area) {
write(STDOUT_FILENO, area->cmd, strlen(area->cmd));
write(STDOUT_FILENO, "\n", 1);
(void)write(STDOUT_FILENO, area->cmd, strlen(area->cmd));
(void)write(STDOUT_FILENO, "\n", 1);
}
}
break;
Expand Down

0 comments on commit 7890857

Please sign in to comment.