不要将相同类型的特定 Xorg 应用程序分组

Do not group specific Xorg applications of the same type

我有几个相同程序的实例 (windows)。当然,Gnome 会将它们分组并将它们作为同一应用程序的多个 windows 来处理。分组会影响我使用的任务面板,但也会影响图标和 Alt+Tab 之类的东西。

并不少见,我有两个 windows 同一个应用程序,它们不应被视为相同应用程序的两个实例,而是根本不同。所以我不想将它们分组。这在实践中可能会影响以下应用程序:

我不在乎如何实现,我愿意付出更多的努力来实现这个目标,因为这是每天的一大烦恼。我将 Gnome 与 Dash-To-Panel 插件一起使用,解决方案可能特定于该设置或更广泛。


到目前为止我尝试了什么:我尝试操纵 windows 的 WM_CLASS 属性,但它并没有真正起作用,因为 属性 似乎更像是用于 group windows,而不是 ungroup。此外,WM 并不总是尊重桌面文件中的 StartupWMClass 属性,并且 xprop 命令不是那么有用。

所以我终于找到了解决这个问题的 hacky 解决方法。

the property seems more to be used to group windows, not to ungroup them.

这是一个错误的假设。事实上,WM_CLASS 是由一个 res_name 和一个 res_class (RTFM) 组成的元组。后一种通常称为WM_CLASS,也是您正常更改的一种。

所以我将代码从 扩展到一个非常相似的问题以更改 res_name

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

int main(int argc, char *argv[])
{
    unsigned long value;
    char *terminatedAt;
    XClassHint class;
    Status status;
    Display *display;
    Window window;

    if ( argc != 4 ) {
        printf( "Usage: %s <window id> <window class> <application name>\n", argv[0] );
        return 1;
    }
    window = strtoul( argv[1], &terminatedAt, 0 );
    if ( *terminatedAt != '[=10=]' ) {
        printf( "Could not parse window id: %s\n", argv[1] );
        return 2;
    }

    display = XOpenDisplay( NULL );
    status = XGetClassHint( display, window, &class );
    if ( !status ) return 4;

    XFree( class.res_class );
    XFree( class.res_name );
    class.res_class = strdup( argv[2] );
    class.res_name = strdup( argv[3] );
    printf("Setting WM_CLASS of window %lu to res_name=\"%s\", res_class=\"%s\"\n", window, class.res_name, class.res_class );
    XSetClassHint( display, window, &class );

    XCloseDisplay( display );
    XFree( class.res_name );
    XFree( class.res_class );
    return 0;
}

gcc set_wm_class.c -lX11 -o set_wm_class编译它并用xdotool getactivewindow得到需要的WID。


顺便说一下,我对不那么骇人听闻的解决方案持开放态度。对于使用 xprop -set 设置完整 WM_CLASS 从而使此脚本过时的方法,我将悬赏 100 声望。

您现在可以 'disable' Gnome 中的 alt-tab 分组。在您的 Gnome 键绑定中,将键绑定从 'Switch applications' 更改为 'Switch windows'。

https://blogs.gnome.org/fmuellner/2018/10/11/the-future-of-alternatetab-and-why-you-need-not-worry/