summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2023-06-12 19:16:46 +0200
committerDave Davenport <qball@gmpclient.org>2023-06-12 19:16:46 +0200
commite409322faf2074b0fa6e30cf77011aee5f28a99d (patch)
treeffbb2c92498bb6f0e01bac96870c72b1029b93c3
parent96dabb4dd6dc23b56fd0dbf167641eef81e14ce2 (diff)
Print window manager in -help output
-rw-r--r--include/xcb.h7
-rw-r--r--source/rofi.c9
-rw-r--r--source/xcb.c20
3 files changed, 36 insertions, 0 deletions
diff --git a/include/xcb.h b/include/xcb.h
index a9d33b8c..d56b2cf3 100644
--- a/include/xcb.h
+++ b/include/xcb.h
@@ -249,4 +249,11 @@ void cairo_image_surface_blur(cairo_surface_t *surface, double radius,
void x11_event_handler_fowarding(xcb_xim_t *im, xcb_xic_t ic,
xcb_key_press_event_t *event, void *user_data);
#endif
+
+/**
+ * Get the currently detected window manager.
+ *
+ * @returns NULL when non found, otherwise a string (free with g_free)
+ */
+char *x11_helper_get_window_manager(void);
#endif
diff --git a/source/rofi.c b/source/rofi.c
index 214a78f6..ff408027 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -358,6 +358,15 @@ static void help(G_GNUC_UNUSED int argc, char **argv) {
printf("Global options:\n");
print_options();
printf("\n");
+ printf("Detected Window manager:\n");
+ char *wm = x11_helper_get_window_manager();
+ if (wm) {
+ printf("\t• %s\n", wm);
+ g_free(wm);
+ } else {
+ printf("\t• No window manager detected.\n");
+ }
+ printf("\n");
display_dump_monitor_layout();
printf("\n");
printf("Detected modes:\n");
diff --git a/source/xcb.c b/source/xcb.c
index c4079a11..62dddfbf 100644
--- a/source/xcb.c
+++ b/source/xcb.c
@@ -1607,6 +1607,26 @@ static void x11_create_frequently_used_atoms(void) {
}
}
+char *x11_helper_get_window_manager(void) {
+ char *retv = NULL;
+ xcb_window_t wm_win = 0;
+ xcb_get_property_cookie_t cc = xcb_ewmh_get_supporting_wm_check_unchecked(
+ &xcb->ewmh, xcb_stuff_get_root_window());
+
+ if (xcb_ewmh_get_supporting_wm_check_reply(&xcb->ewmh, cc, &wm_win, NULL)) {
+ xcb_ewmh_get_utf8_strings_reply_t wtitle;
+ xcb_get_property_cookie_t cookie =
+ xcb_ewmh_get_wm_name_unchecked(&(xcb->ewmh), wm_win);
+ if (xcb_ewmh_get_wm_name_reply(&(xcb->ewmh), cookie, &wtitle, (void *)0)) {
+ if (wtitle.strings_len > 0) {
+ retv = g_strdup(wtitle.strings);
+ }
+ xcb_ewmh_get_utf8_strings_reply_wipe(&wtitle);
+ }
+ }
+ return retv;
+}
+
static void x11_helper_discover_window_manager(void) {
xcb_window_t wm_win = 0;
xcb_get_property_cookie_t cc = xcb_ewmh_get_supporting_wm_check_unchecked(