我有一台带有外接显示器的笔记本电脑,我想将外接显示器用作主要显示器。我也在用 dwm 运行 Debian。xrandr -q
给了我这个:
Screen 0: minimum 320 x 200, current 3286 x 1080, maximum 8192 x 8192
LVDS1 connected 1366x768+1920+0 (normal left inverted right x axis y axis) 345mm x 194mm
1366x768 60.0*+ 50.0
VGA1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 509mm x 286mm
1920x1080 60.0*+
(为了简洁起见,我省略了一些其他决议)。我的 dwm config.h 文件有几个如下标记规则:
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ "Chromium", NULL, NULL, 1, False, -1 },
{ "xxxterm", NULL, NULL, 1, False, -1 },
{ "Surf", NULL, NULL, 1, False, -1 },
{ "Iceweasel", NULL, NULL, 1 << 1, False, -1 },
{ "Vlc", NULL, NULL, 1 << 3, False, -1 },
};
我的 ~/.xinitrc 文件中有这个 xrandr 命令,可以在运行时正确配置监视器startx
:
xrandr --output VGA1 --auto --output LVDS1 --auto --right-of VGA1
我希望每当我打开程序时都应用我的标记规则,并让该程序自动分配给具有焦点的监视器。我找到了一个红迪网帖子也就是说 -1 会执行此操作,但对于任何具有标记规则的程序,它们总是在我的笔记本电脑 (LVDS1) 上打开,而不是在外部显示器 (VGA1) 上打开。
对于没有标签规则的程序(例如 st),它们将在具有焦点的监视器/标签上打开。我尝试将监视器值更改为0或1,重建dwm并重新启动X,结果是相同的。
如何配置 dwm,以便具有标记规则的程序在具有焦点的监视器上的各自标记中打开?
我的完整config.h
:
/* appearance */
static const char font[] = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
static const char normbordercolor[] = "#333333";
static const char normbgcolor[] = "#101010";
static const char normfgcolor[] = "#999999";
static const char selbordercolor[] = "#224488";
static const char selbgcolor[] = "#224488";
static const char selfgcolor[] = "#ffffff";
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const unsigned int minwsz = 20; /* Minimal heigt of a client */
static const Bool showbar = True; /* False means no bar */
static const Bool topbar = True; /* False means bottom bar */
static const Bool viewontag = False; /* Switch view on tag switch */
static const Bool extrabar = True; /* False means no extra bar */
/* tagging */
static const char *tags[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ "Chromium", NULL, NULL, 1, False, -1 },
{ "xxxterm", NULL, NULL, 1, False, -1 },
{ "Surf", NULL, NULL, 1, False, -1 },
{ "Iceweasel", NULL, NULL, 1 << 1, False, -1 },
{ "Vlc", NULL, NULL, 1 << 3, False, -1 },
{ NULL, NULL, "IPython", 1 << 4, False, -1 },
{ "Eclipse", NULL, NULL, 1 << 4, False, -1 },
{ "Quodlibet", NULL, NULL, 1 << 5, False, -1 },
{ "Icedove", NULL, NULL, 1 << 6, False, -1 },
{ "libreoffice", NULL, NULL, 1 << 7, False, -1 },
{ "Gnumeric", NULL, NULL, 1 << 7, False, -1 },
{ "Abiword", NULL, NULL, 1 << 7, False, -1 },
{ "Keepassx", NULL, NULL, 1 << 8, False, -1 },
};
/* layout(s) */
static const float mfact = 0.50; /* factor of master area size [0.05..0.95] */
static const float smfact = 0.00; /* factor of tiled clients [0.00..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const Bool resizehints = False; /* True means respect size hints in tiled resizals */
#include "patchlibs/bstack.c"
#include "patchlibs/bstackhoriz.c"
#include "patchlibs/fibonacci.c"
#include "patchlibs/gaplessgrid.c"
#include "patchlibs/tcl.c"
static const Layout layouts[] = {
/* symbol arrange function */
{ "T", tile }, /* first entry is default */
{ "F", NULL }, /* no layout function means floating behavior */
{ "B", bstack },
{ "G", gaplessgrid },
{ "M", monocle },
{ "H", bstackhoriz },
{ "C", tcl },
{ "S", spiral },
{ "D", dwindle },
};
/* key definitions */
#define MODKEY Mod1Mask
#define WINKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[] = { "st", NULL };
static const char *chromiumcmd[] = {"chromium-incognito", NULL};
static const char *icedovecmd[] = {"icedove", NULL};
static const char *xxxtermcmd[] = {"xxxterm", NULL};
static const char *musiccmd[] = {"quodlibet", NULL};
static const char *ipythoncmd[] = {"ipython3qt", NULL};
static const char *iceweaselcmd[] = {"iceweasel", NULL};
static const char *texteditcmd[] = {"scite", NULL};
static const char *lockcmd[] = {"lock", NULL};
static const char *videocmd[] = {"vlc", NULL};
static const char *screenshotcmd[] = {"screenshot", NULL};
#include "patchlibs/movestack.c"
static Key keys[] = {
/* modifier key function argument */
{ WINKEY, XK_t, spawn, {.v = termcmd } },
{ WINKEY, XK_c, spawn, {.v = chromiumcmd } },
{ WINKEY, XK_d, spawn, {.v = icedovecmd } },
{ WINKEY, XK_x, spawn, {.v = xxxtermcmd } },
{ WINKEY, XK_i, spawn, {.v = iceweaselcmd } },
{ WINKEY, XK_m, spawn, {.v = musiccmd } },
{ WINKEY, XK_e, spawn, {.v = texteditcmd } },
{ WINKEY, XK_p, spawn, {.v = ipythoncmd } },
{ WINKEY, XK_l, spawn, {.v = lockcmd } },
{ WINKEY, XK_v, spawn, {.v = videocmd } },
{ WINKEY, XK_s, spawn, {.v = screenshotcmd } },
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_b, toggleextrabar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_u, setsmfact, {.f = -0.05} },
{ MODKEY, XK_m, setsmfact, {.f = +0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ ControlMask|ShiftMask, XK_t, setlayout, {.v = &layouts[0]} },
{ ControlMask|ShiftMask, XK_f, setlayout, {.v = &layouts[1]} },
{ ControlMask|ShiftMask, XK_b, setlayout, {.v = &layouts[2]} },
{ ControlMask|ShiftMask, XK_g, setlayout, {.v = &layouts[3]} },
{ ControlMask|ShiftMask, XK_m, setlayout, {.v = &layouts[4]} },
{ ControlMask|ShiftMask, XK_h, setlayout, {.v = &layouts[5]} },
{ ControlMask|ShiftMask, XK_c, setlayout, {.v = &layouts[6]} },
{ ControlMask|ShiftMask, XK_s, setlayout, {.v = &layouts[7]} },
{ ControlMask|ShiftMask, XK_d, setlayout, {.v = &layouts[8]} },
{ ControlMask, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
TAGKEYS( XK_4, 3)
TAGKEYS( XK_5, 4)
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
};
/* button definitions */
/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[3]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
};
答案1
默认的 dwm 行为是在具有焦点的监视器/屏幕上打开应用程序(无论是否有规则)。
要在当前聚焦的监视器的第三个标签上打开 Surf,规则为:
{ "Surf", NULL, NULL, 1 << 2, True, -1 },
要在主显示器的第二个标签上打开 VLC,无论焦点在哪里,规则是:
{ "VLC", NULL, NULL, 1 << 1, True, 1 },
如果您的规则不符合此行为,则您配置 dwm 的方式可能存在其他问题。粘贴整个内容config.h
可能会有所帮助。