dwm 窗口标题栏右键菜单
dwm 的窗口标题栏右键菜单可以通过修改 dwm 的配置文件 config.h 来实现。具体步骤如下:
-
打开 dwm 的配置文件 config.h,可以在 ~/.config/dwm/ 目录下找到。
-
找到 static const char *tags[] = {...},在 tags 数组的末尾添加一个 NULL,如下所示:
static const char *tags[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", NULL};
- 找到 static const Rule rules[] = {...},在 rules 数组的末尾添加一个空的规则,如下所示:
static const Rule rules[] = { // ... { NULL, NULL, NULL, 0, 0, 0 } };
- 找到 static Button buttons[] = {...},在 buttons 数组的末尾添加一个右键菜单的配置,如下所示:
static Button buttons[] = { // ... { ClkClientWin, MODKEY, Button3, spawn, SHCMD("xdotool getwindowfocus windowkill") }, { ClkRootWin, MODKEY, Button3, spawn, SHCMD("rofi -show drun") }, { ClkRootWin, MODKEY, Button1, spawn, SHCMD("xdotool key super") }, { ClkRootWin, MODKEY, Button2, spawn, SHCMD("xdotool key super+shift+q") }, { ClkRootWin, MODKEY, Button3, spawn, SHCMD("xdotool key super+shift+c") }, };
这里添加了五个配置项:
- ClkClientWin:表示单击窗口标题栏时触发。
- MODKEY:表示使用 MODKEY 组合键触发,MODKEY 可以在 config.h 中定义。
- Button3:表示右键菜单。
- spawn:表示执行一个命令。
- SHCMD("..."):表示要执行的命令,这里使用了 xdotool 和 rofi 工具,可以根据自己的需要修改。
- 修改完成后保存并退出 config.h 文件,重新编译并安装 dwm。
完成以上步骤后,就可以在 dwm 的窗口标题栏上右键单击,打开自定义的菜单了
原文地址: https://www.cveoy.top/t/topic/deUA 著作权归作者所有。请勿转载和采集!