From 531c575575e04fd7d6bd34b8347f420497e017a4 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 24 Oct 2015 14:44:41 +0200 Subject: [PATCH] Allow the user to set the WM_NAME atom value --- README.pod | 6 +++++- lemonbar.c | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.pod b/README.pod index a38a7df..ea7eb7f 100644 --- a/README.pod +++ b/README.pod @@ -6,7 +6,7 @@ lemonbar - Featherweight lemon-scented bar =head1 SYNOPSIS -I [-h | -g IBIB<+>IB<+>I | -b | -d | -f I | -p | -u I | -B I | -F I] +I [-h | -g IBIB<+>IB<+>I | -b | -d | -f I | -p | -n | -u I | -B I | -F I] =head1 DESCRIPTION @@ -41,6 +41,10 @@ changing the MAX_FONT_COUNT parameter in the source code). Make the bar permanent, don't exit after the standard input is closed. +=item B<-n> + +Set the WM_NAME atom value for the bar. + =item B<-u> I Sets the underline width in pixels. The default is 1. diff --git a/lemonbar.c b/lemonbar.c index 73d3ff1..6582160 100644 --- a/lemonbar.c +++ b/lemonbar.c @@ -1080,7 +1080,7 @@ xconn (void) } void -init (void) +init (char *wm_name) { // Try to load a default font if (!font_count) @@ -1168,6 +1168,10 @@ init (void) // Make sure that the window really gets in the place it's supposed to be // Some WM such as Openbox need this xcb_configure_window(c, mon->window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, (const uint32_t []){ mon->x, mon->y }); + + // 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_flush(c); @@ -1225,6 +1229,7 @@ main (int argc, char **argv) bool permanent = false; int geom_v[4] = { -1, -1, 0, 0 }; int ch, areas; + char *wm_name; // Install the parachute! atexit(cleanup); @@ -1239,12 +1244,13 @@ main (int argc, char **argv) // A safe default areas = 10; + wm_name = NULL; - while ((ch = getopt(argc, argv, "hg:bdf:a:pu:B:F:")) != -1) { + while ((ch = getopt(argc, argv, "hg:bdf:a:pu:B:F:n:")) != -1) { switch (ch) { case 'h': printf ("lemonbar version %s\n", VERSION); - printf ("usage: %s [-h | -g | -b | -d | -f | -a | -p | -u | -B | -F]\n" + printf ("usage: %s [-h | -g | -b | -d | -f | -a | -p | -n | -u | -B | -F]\n" "\t-h Show this help\n" "\t-g Set the bar geometry {width}x{height}+{xoffset}+{yoffset}\n" "\t-b Put the bar at the bottom of the screen\n" @@ -1252,12 +1258,14 @@ main (int argc, char **argv) "\t-f Set the font name to use\n" "\t-a Number of clickable areas available (default is 10)\n" "\t-p Don't close after the data ends\n" + "\t-n Set the WM_NAME atom to the specified value for this bar\n" "\t-u Set the underline/overline height in pixels\n" "\t-B Set background color in #AARRGGBB\n" "\t-F Set foreground color in #AARRGGBB\n", argv[0]); 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 'b': topbar = false; break; case 'd': dock = true; break; case 'f': font_load(optarg); break; @@ -1293,7 +1301,7 @@ main (int argc, char **argv) xconn(); // Do the heavy lifting - init(); + init(wm_name); // Get the fd to Xserver pollin[1].fd = xcb_get_file_descriptor(c);