前提:确定网络问题已经解决并真实可用。
apt install xorg
apt install xinput
sudo apt install --no-install-recommends \
build-essential \
wget \
ca-certificates \
libx11-dev \
libxft-dev \
libxinerama-dev \
fonts-dejavu-core
mkdir -p ~/src
cd ~/src
wget https://dl.suckless.org/dwm/dwm-6.8.tar.gz
tar xf dwm-6.8.tar.gz
cd dwm-6.8
nano config.mk
将下述内容:
X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
修改为:
X11INC = /usr/include
X11LIB = /usr/lib
键盘按下以保存:
Ctrl+X
Y
Enter
make clean
make
sudo make install
/usr/local/bin/dwm -v
编辑:
nano ~/.xinitrc
复制下述内容:
#!/bin/sh
xterm &
exec /usr/local/bin/dwm
键盘按下以保存:
Ctrl+X
Y
Enter
添加执行权限:
chmod +x ~/.xinitrc
在 Hyper-V 连接器中执行:
startx
键盘按下以退出:
Alt + Shift + Q
进入 DWM 源码目录:
cd ~/src/dwm-6.8
cp config.def.h config.h
nano config.h
将整个 config.h 替换为下面的内容:
/* See LICENSE file for copyright and license details. */
/* appearance */
static const unsigned int borderpx = 0;
static const unsigned int snap = 0;
static const int showbar = 0;
static const int topbar = 1;
static const char *fonts[] = { "monospace:size=10" };
static const char col_black[] = "#000000";
static const char col_white[] = "#ffffff";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_white, col_black, col_black },
[SchemeSel] = { col_white, col_black, col_black },
};
/* one tag only */
static const char *tags[] = {
"1"
};
/* no application-specific rule yet */
static const Rule rules[] = {
/* class instance title tags mask isfloating monitor */
{ NULL, NULL, NULL, 0, 0, -1 },
};
/* layout */
static const float mfact = 0.55;
static const int nmaster = 1;
/*
* Important for our use case:
* ignore application size hints when tiled/monocle.
*/
static const int resizehints = 0;
/* keep focus on real EWMH fullscreen clients */
static const int lockfullscreen = 1;
static const int refreshrate = 120;
/*
* Only one layout:
*
* normal windows -> monocle
* dialog/transient/floating windows -> floating
*/
static const Layout layouts[] = {
/* symbol arrange function */
{ "[M]", monocle },
};
/*
* dwm.c:spawn() references these two symbols unconditionally.
* We don't use dmenu, but keep dummy definitions for vanilla dwm.
*/
/*
* Required by vanilla dwm's spawn().
* dmenu itself is NOT used or required.
*/
static char dmenumon[2] = "0";
static const char *dmenucmd[] = { NULL };
/*
* Maintenance modifier.
*
* Super + Shift + Q : quit dwm
* Super + Shift + C : close current client
*/
#define MODKEY Mod1Mask
static const Key keys[] = {
/* modifier key function argument */
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY|ShiftMask, XK_q, quit, {0} },
};
/*
* Debug/maintenance only.
*
* These are useful during phase 1 for testing floating dialogs.
*
* Super + left mouse -> move floating window
* Super + right mouse -> resize floating window
*
* They can be removed in phase 2.
*/
static const Button buttons[] = {
/* click event mask button function argument */
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
};
键盘按下以保存:
Ctrl+X
Y
Enter
make clean
make
sudo make install
/usr/local/bin/dwm -v
在 Hyper-V 连接器中执行:
startx
键盘按下以退出:
Super(Alt) + Shift + Q
sudo apt install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc \
| sudo gpg --dearmor \
-o /usr/share/keyrings/microsoft.gpg
sudo nano /etc/apt/sources.list.d/vscode.sources
将下面的内容复制粘贴进去:
Types: deb
URIs: https://packages.microsoft.com/repos/code
Suites: stable
Components: main
Architectures: amd64,arm64,armhf
Signed-By: /usr/share/keyrings/microsoft.gpg
键盘按下以保存:
Ctrl+X
Y
Enter
sudo apt update
sudo apt install code
code --version
mkdir -p ~/workspace
ls -ld ~/workspace
编辑:
nano ~/.xinitrc
将下述内容复制进去:
#!/bin/sh
export XDG_SESSION_TYPE=x11
unset WAYLAND_DISPLAY
# Hyper-V 固定显示模式
/usr/bin/xrandr \
--output Virtual-1 \
--mode 1920x1080
# 启动 dwm
/usr/local/bin/dwm &
WM_PID=$!
# 等待 dwm 注册完成
i=0
while [ "$i" -lt 50 ]; do
if /usr/bin/xprop -root _NET_SUPPORTING_WM_CHECK >/dev/null 2>&1; then
break
fi
i=$((i + 1))
sleep 0.1
done
# 关键!!!: 直接运行 VS Code GUI 主程序。
# 关键!!!: /usr/bin/code --wait。
/usr/share/code/code \
--new-window \
"$HOME/workspace"
CODE_RC=$?
# VS Code 真正退出之后,结束 WM。
kill "$WM_PID" 2>/dev/null
wait "$WM_PID" 2>/dev/null
exit "$CODE_RC"
键盘按下以保存:
Ctrl+X
Y
Enter
设置 .xinitrc 权限:
chmod 700 ~/.xinitrc
在 Hyper-V 连接器中执行:
startx
启动完成后,可以看到全屏的 VS Code。