1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Print window manager in -help output

This commit is contained in:
Dave Davenport 2023-06-12 19:16:46 +02:00
parent 96dabb4dd6
commit e409322faf
3 changed files with 36 additions and 0 deletions

View file

@ -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

View file

@ -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");

View file

@ -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(