遍历x11相关的ubuntu package
https://packages.ubuntu.com/bionic/x11/
X11 环境下我们通常说的桌面环境最基础的应该包含两个部分:
登录管理器
常见的有:
gdm, kdm, xdm, lightdm, slim
具体区别可以参考archlinux的wiki https://wiki.archlinux.org/index.php/display_manager
如果安装有多个登录管理器可以使用下面方式指定默认登录管理器
sudo dpkg-reconfigure gdm
桌面管理器
桌面管理器有很多种,可以通过下面的链接查看大众的评比结果
https://www.slant.co/topics/390/~best-window-managers-for-linux
gnome, kde, xfce等都属于桌面管理器,它们的窗口管理都是悬浮和分层来组织排放的,与windows的差异很小。而平铺式桌面管理器(tiling window manager)是桌面管理器中的一种小众类型,更专注于键盘控制,效率提升和定制化。下面分享自己经常使用的几种平铺式桌面管理器的使用记录。
可以参考下面的配置文件
https://github.com/aggresss/dotfiles/blob/master/awesome/rc.lua_ubuntu18.04
使用说明
https://awesomewm.org/doc/manpages/awesome.1.html
默认配置文件 ~/.config/awesome/rc.lua
默认Modkey
为Mod4(win)
键。
下面是整理的 awesome 默认快捷键:
Window manager control
Mod4 + Control + R
Restart awesome.
Mod4 + Shift + Q
Quit awesome.
Mod4 + R
Run prompt.
Mod4 + X
Run Lua code prompt.
Mod4 + Return
Spawn terminal emulator.
Mod4 + W
Open main menu.
Clients
Mod4 + M
Maximize client.
Mod4 + N
Minimize client.
Mod4 + Control + n
Restore client.
Mod4 + F
Set client fullscreen.
Mod4 + Shift + C
Kill focused client.
Mod4 + T
Set client on-top.
Navigation
Mod4 + J
Focus next client.
Mod4 + K
Focus previous client.
Mod4 + U
Focus first urgent client.
Mod4 + Left
View previous tag.
Mod4 + Right
View next tag.
Mod4 + 1-9
Switch to tag 1-9.
Mod4 + Control + J
Focus next screen.
Mod4 + Control + K
Focus previous screen.
Mod4 + Escape
Focus previously selected tag set.
Layout modification
Mod4 + Shift + J
Switch client with next client.
Mod4 + Shift + K
Switch client with previous client.
Mod4 + O
Send client to next screen.
Mod4 + H
Decrease master width factor by 5%.
Mod4 + L
Increase master width factor by 5%.
Mod4 + Shift + H
Increase number of master windows by 1.
Mod4 + Shift + L
Decrease number of master windows by 1.
Mod4 + Control + H
Increase number of columns for non-master windows by 1.
Mod4 + Control + L
Decrease number of columns for non-master windows by 1.
Mod4 + space
Switch to next layout.
Mod4 + Shift + space
Switch to previous layout.
Mod4 + Control + space
Toggle client floating status.
Mod4 + Control + Return
Swap focused client with master.
Mod4 + Control + 1-9
Toggle tag view.
Mod4 + Shift + 1-9
Tag client with tag.
Mod4 + Shift + Control + 1-9
Toggle tag on client.
默认配置文件 ~/.config/i3/config
~/.config/i3staus/config
默认Modkey
为Alt
键
下面整理了一些常用的默认快捷键:
Mod+ Enter
启动虚拟终端
Mod + D
启动 dmenu
Mod + A
焦点转义到父窗口上
Mod + S
堆叠布局
Mod + W
标签布局
Mod + E
默认布局
Mod + H
水平分割窗口
Mod + V
垂直分割窗口
Mod + R
調整窗口大小,使用方向键
Mod + F
全屏模式
Mod + J
焦点往左窗口移
Mod + K
焦点往下窗口移
Mod + L
焦点往上窗口移
Mod + ;
焦点往右窗口移
Mod + Shift + J
窗口左移
Mod + Shift + K
窗口下移
Mod + Shift + L
窗口上移
Mod + Shift + :
窗口右移
Mod + SpaceBar
焦点在平铺式/浮动式转换
Mod + Shift + SpaceBar
窗口在平铺式/浮动式转换
Mod + Shift + Q
杀死当前窗口的进程
Mod + Shift + E
退出 i3
Mod + Shift + C
当场重新加载 i3config, 无需重启
Mod + Shift + R
重启 i3 (还重新加载了 i3config, 又没有退出过程)
i3的上下左右和 vim 还是有点区别的 “JKL:” 对应 左上下右
除了快捷键外,i3对多显示器的支持也很好,新建窗口的位置取决于新建窗口命令所在的监视器。
i3平铺式支持横向和纵向。支持多行或多列。支持窗口的重命名。
https://i3wm.org/docs/userguide.html
默认启动后什么都没有,完全依赖快捷键操作
默认配置文件 ~/.xmonad/xmonad.hs
xmobar 配置
https://beginners-guide-to-xmonad.readthedocs.io/configure_xmobar.html
默认Modkey
为Alt
键
下面是整理的 xmonad 默认快捷键:
Mod + Shift + Return
Launch terminal
Mod + P
Launch dmenu
Mod + Shift + P
Launch gmrun
Mod + Shift + C
Close the focused window
Mod + Space
Rotate through the available layout algorithms
Mod + Shift + Space
Reset the layouts on the current workspace to default
Mod + N
Resize viewed windows to the correct size
Mod + Tab
Move focus to the next window
Mod + Shift + Tab
Move focus to the previous window
Mod + J
Move focus to the next window
Mod + K
Move focus to the previous window
Mod + M
Move focus to the master window
Mod + Return
Swap the focused window and the master window
Mod + Shift + J
Swap the focused window with the next window
Mod + Shift + K
Swap the focused window with the previous window
Mod + H
Shrink the master area
Mod + L
Expand the master area
Mod + T
Push window back into tiling
Mod + ,
Increment the number of windows in the master area
Mod + .
Deincrement the number of windows in the master area
Mod + Shift + Q
Quit xmonad
Mod + Q
Restart xmonad
Mod + Shift + /
Run xmessage with a summary of the default keybindings (useful for beginners)
Mod + [1..9]
Switch to workspace N
Mod + Shift + [1..9]
Move client to workspace N
Mod + {W, E, R}
Switch to physical/Xinerama screens 1, 2, or 3
Mod + Shift + {W, E, R}
Move client to screen 1, 2, or 3
Mod + Button1
Set the window to floating mode and move by dragging
Mod + Button2
Raise the window to the top of the stack
Mod + Button3
Set the window to floating mode and resize by dragging
下面是键盘映射图:
https://wiki.haskell.org/Xmonad
默认Modkey
为Alt
键
config.def.h文件的默认设置:
MODKEY + P
dmenu
MODKEY + Shift + Q
To quite dwm cleanly
MODKEY + Shift + C
To kill a window
MODKEY + Shift + Enter
Launch terminal
MODKEY + Shift + 1,2,3,...
Move current window to area 1,2,3…
MODKEY + 1,2,3,...
Switch to area 1,2,3…
MODKEY + 0
预览1-9所有内容
MODKEY + tab
Switch view area
MODKEY + J
激活下一个窗口
MODKEY + K
激活上一个窗口
MODKEY + H
左移边界
MODKEY + L
右移边界
MODKEY + I
分割Master窗口(+1)
MODKEY + D
还原Master窗口(-1)
MODKEY + B
隐藏/显示dmenu菜单
MODKEY + T
Alt + F
Alt + M
切換桌面布局方式
MODKEY + space
前後布局切換
MODKEY + Enter
切換Master窗口
下面是 dwm 的示意图,参考自:
http://www.cnblogs.com/wonux/articles/5206085.html
+------+----------------------------------+--------+
| tags | title | status +
+------+---------------------+------------+--------+
| | |
| | |
| | |
| | |
| master | stack |
| | |
| | |
| | |
| | |
+----------------------------+---------------------+
dwm结构非常简单,是研究桌面管理器的最佳选择
git clone https://git.suckless.org/dwm
/usr/share/xsessions/*.desktop
记录了有几种桌面系统被安装
apt-file list dwm 查看 dwm 安装文件
使用自定义的桌面环境经常要自定义键盘映射,可以使用 xev 命令来捕获按键的 keysym 下面是使用 xmodmap 命令输出的 Thinkpad 键盘的默认映射关系:
keycode 8 =
keycode 9 = Escape NoSymbol Escape
keycode 10 = 1 exclam 1 exclam
keycode 11 = 2 at 2 at
keycode 12 = 3 numbersign 3 numbersign
keycode 13 = 4 dollar 4 dollar
keycode 14 = 5 percent 5 percent
keycode 15 = 6 asciicircum 6 asciicircum
keycode 16 = 7 ampersand 7 ampersand
keycode 17 = 8 asterisk 8 asterisk
keycode 18 = 9 parenleft 9 parenleft
keycode 19 = 0 parenright 0 parenright
keycode 20 = minus underscore minus underscore
keycode 21 = equal plus equal plus
keycode 22 = BackSpace BackSpace BackSpace BackSpace
keycode 23 = Tab ISO_Left_Tab Tab ISO_Left_Tab
keycode 24 = q Q q Q
keycode 25 = w W w W
keycode 26 = e E e E
keycode 27 = r R r R
keycode 28 = t T t T
keycode 29 = y Y y Y
keycode 30 = u U u U
keycode 31 = i I i I
keycode 32 = o O o O
keycode 33 = p P p P
keycode 34 = bracketleft braceleft bracketleft braceleft
keycode 35 = bracketright braceright bracketright braceright
keycode 36 = Return NoSymbol Return
keycode 37 = Control_L NoSymbol Control_L
keycode 38 = a A a A
keycode 39 = s S s S
keycode 40 = d D d D
keycode 41 = f F f F
keycode 42 = g G g G
keycode 43 = h H h H
keycode 44 = j J j J
keycode 45 = k K k K
keycode 46 = l L l L
keycode 47 = semicolon colon semicolon colon
keycode 48 = apostrophe quotedbl apostrophe quotedbl
keycode 49 = grave asciitilde grave asciitilde
keycode 50 = Shift_L NoSymbol Shift_L
keycode 51 = backslash bar backslash bar
keycode 52 = z Z z Z
keycode 53 = x X x X
keycode 54 = c C c C
keycode 55 = v V v V
keycode 56 = b B b B
keycode 57 = n N n N
keycode 58 = m M m M
keycode 59 = comma less comma less
keycode 60 = period greater period greater
keycode 61 = slash question slash question
keycode 62 = Shift_R NoSymbol Shift_R
keycode 63 = KP_Multiply KP_Multiply KP_Multiply KP_Multiply KP_Multiply KP_Multiply XF86ClearGrab
keycode 64 = Alt_L Meta_L Alt_L Meta_L
keycode 65 = space NoSymbol space
keycode 66 = Caps_Lock NoSymbol Caps_Lock
keycode 67 = F1 F1 F1 F1 F1 F1 XF86Switch_VT_1
keycode 68 = F2 F2 F2 F2 F2 F2 XF86Switch_VT_2
keycode 69 = F3 F3 F3 F3 F3 F3 XF86Switch_VT_3
keycode 70 = F4 F4 F4 F4 F4 F4 XF86Switch_VT_4
keycode 71 = F5 F5 F5 F5 F5 F5 XF86Switch_VT_5
keycode 72 = F6 F6 F6 F6 F6 F6 XF86Switch_VT_6
keycode 73 = F7 F7 F7 F7 F7 F7 XF86Switch_VT_7
keycode 74 = F8 F8 F8 F8 F8 F8 XF86Switch_VT_8
keycode 75 = F9 F9 F9 F9 F9 F9 XF86Switch_VT_9
keycode 76 = F10 F10 F10 F10 F10 F10 XF86Switch_VT_10
keycode 77 = Num_Lock NoSymbol Num_Lock
keycode 78 = Scroll_Lock NoSymbol Scroll_Lock
keycode 79 = KP_Home KP_7 KP_Home KP_7
keycode 80 = KP_Up KP_8 KP_Up KP_8
keycode 81 = KP_Prior KP_9 KP_Prior KP_9
keycode 82 = KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract XF86Prev_VMode
keycode 83 = KP_Left KP_4 KP_Left KP_4
keycode 84 = KP_Begin KP_5 KP_Begin KP_5
keycode 85 = KP_Right KP_6 KP_Right KP_6
keycode 86 = KP_Add KP_Add KP_Add KP_Add KP_Add KP_Add XF86Next_VMode
keycode 87 = KP_End KP_1 KP_End KP_1
keycode 88 = KP_Down KP_2 KP_Down KP_2
keycode 89 = KP_Next KP_3 KP_Next KP_3
keycode 90 = KP_Insert KP_0 KP_Insert KP_0
keycode 91 = KP_Delete KP_Decimal KP_Delete KP_Decimal
keycode 92 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift
keycode 93 =
keycode 94 = less greater less greater bar brokenbar bar
keycode 95 = F11 F11 F11 F11 F11 F11 XF86Switch_VT_11
keycode 96 = F12 F12 F12 F12 F12 F12 XF86Switch_VT_12
keycode 97 =
keycode 98 = Katakana NoSymbol Katakana
keycode 99 = Hiragana NoSymbol Hiragana
keycode 100 = Henkan_Mode NoSymbol Henkan_Mode
keycode 101 = Hiragana_Katakana NoSymbol Hiragana_Katakana
keycode 102 = Muhenkan NoSymbol Muhenkan
keycode 103 =
keycode 104 = KP_Enter NoSymbol KP_Enter
keycode 105 = Control_R NoSymbol Control_R
keycode 106 = KP_Divide KP_Divide KP_Divide KP_Divide KP_Divide KP_Divide XF86Ungrab
keycode 107 = Print Sys_Req Print Sys_Req
keycode 108 = Alt_R Meta_R Alt_R Meta_R
keycode 109 = Linefeed NoSymbol Linefeed
keycode 110 = Home NoSymbol Home
keycode 111 = Up NoSymbol Up
keycode 112 = Prior NoSymbol Prior
keycode 113 = Left NoSymbol Left
keycode 114 = Right NoSymbol Right
keycode 115 = End NoSymbol End
keycode 116 = Down NoSymbol Down
keycode 117 = Next NoSymbol Next
keycode 118 = Insert NoSymbol Insert
keycode 119 = Delete NoSymbol Delete
keycode 120 =
keycode 121 = XF86AudioMute NoSymbol XF86AudioMute
keycode 122 = XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume
keycode 123 = XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolume
keycode 124 = XF86PowerOff NoSymbol XF86PowerOff
keycode 125 = KP_Equal NoSymbol KP_Equal
keycode 126 = plusminus NoSymbol plusminus
keycode 127 = Pause Break Pause Break
keycode 128 = XF86LaunchA NoSymbol XF86LaunchA
keycode 129 = KP_Decimal KP_Decimal KP_Decimal KP_Decimal
keycode 130 = Hangul NoSymbol Hangul
keycode 131 = Hangul_Hanja NoSymbol Hangul_Hanja
keycode 132 =
keycode 133 = Super_L NoSymbol Super_L
keycode 134 = Super_R NoSymbol Super_R
keycode 135 = Menu NoSymbol Menu
keycode 136 = Cancel NoSymbol Cancel
keycode 137 = Redo NoSymbol Redo
keycode 138 = SunProps NoSymbol SunProps
keycode 139 = Undo NoSymbol Undo
keycode 140 = SunFront NoSymbol SunFront
keycode 141 = XF86Copy NoSymbol XF86Copy
keycode 142 = XF86Open NoSymbol XF86Open
keycode 143 = XF86Paste NoSymbol XF86Paste
keycode 144 = Find NoSymbol Find
keycode 145 = XF86Cut NoSymbol XF86Cut
keycode 146 = Help NoSymbol Help
keycode 147 = XF86MenuKB NoSymbol XF86MenuKB
keycode 148 = XF86Calculator NoSymbol XF86Calculator
keycode 149 =
keycode 150 = XF86Sleep NoSymbol XF86Sleep
keycode 151 = XF86WakeUp NoSymbol XF86WakeUp
keycode 152 = XF86Explorer NoSymbol XF86Explorer
keycode 153 = XF86Send NoSymbol XF86Send
keycode 154 =
keycode 155 = XF86Xfer NoSymbol XF86Xfer
keycode 156 = XF86Launch1 NoSymbol XF86Launch1
keycode 157 = XF86Launch2 NoSymbol XF86Launch2
keycode 158 = XF86WWW NoSymbol XF86WWW
keycode 159 = XF86DOS NoSymbol XF86DOS
keycode 160 = XF86ScreenSaver NoSymbol XF86ScreenSaver
keycode 161 = XF86RotateWindows NoSymbol XF86RotateWindows
keycode 162 = XF86TaskPane NoSymbol XF86TaskPane
keycode 163 = XF86Mail NoSymbol XF86Mail
keycode 164 = XF86Favorites NoSymbol XF86Favorites
keycode 165 = XF86MyComputer NoSymbol XF86MyComputer
keycode 166 = XF86Back NoSymbol XF86Back
keycode 167 = XF86Forward NoSymbol XF86Forward
keycode 168 =
keycode 169 = XF86Eject NoSymbol XF86Eject
keycode 170 = XF86Eject XF86Eject XF86Eject XF86Eject
keycode 171 = XF86AudioNext NoSymbol XF86AudioNext
keycode 172 = XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause
keycode 173 = XF86AudioPrev NoSymbol XF86AudioPrev
keycode 174 = XF86AudioStop XF86Eject XF86AudioStop XF86Eject
keycode 175 = XF86AudioRecord NoSymbol XF86AudioRecord
keycode 176 = XF86AudioRewind NoSymbol XF86AudioRewind
keycode 177 = XF86Phone NoSymbol XF86Phone
keycode 178 =
keycode 179 = XF86Tools NoSymbol XF86Tools
keycode 180 = XF86HomePage NoSymbol XF86HomePage
keycode 181 = XF86Reload NoSymbol XF86Reload
keycode 182 = XF86Close NoSymbol XF86Close
keycode 183 =
keycode 184 =
keycode 185 = XF86ScrollUp NoSymbol XF86ScrollUp
keycode 186 = XF86ScrollDown NoSymbol XF86ScrollDown
keycode 187 = parenleft NoSymbol parenleft
keycode 188 = parenright NoSymbol parenright
keycode 189 = XF86New NoSymbol XF86New
keycode 190 = Redo NoSymbol Redo
keycode 191 = XF86Tools NoSymbol XF86Tools
keycode 192 = XF86Launch5 NoSymbol XF86Launch5
keycode 193 = XF86Launch6 NoSymbol XF86Launch6
keycode 194 = XF86Launch7 NoSymbol XF86Launch7
keycode 195 = XF86Launch8 NoSymbol XF86Launch8
keycode 196 = XF86Launch9 NoSymbol XF86Launch9
keycode 197 =
keycode 198 = XF86AudioMicMute NoSymbol XF86AudioMicMute
keycode 199 = XF86TouchpadToggle NoSymbol XF86TouchpadToggle
keycode 200 = XF86TouchpadOn NoSymbol XF86TouchpadOn
keycode 201 = XF86TouchpadOff NoSymbol XF86TouchpadOff
keycode 202 =
keycode 203 = Mode_switch NoSymbol Mode_switch
keycode 204 = NoSymbol Alt_L NoSymbol Alt_L
keycode 205 = NoSymbol Meta_L NoSymbol Meta_L
keycode 206 = NoSymbol Super_L NoSymbol Super_L
keycode 207 = NoSymbol Hyper_L NoSymbol Hyper_L
keycode 208 = XF86AudioPlay NoSymbol XF86AudioPlay
keycode 209 = XF86AudioPause NoSymbol XF86AudioPause
keycode 210 = XF86Launch3 NoSymbol XF86Launch3
keycode 211 = XF86Launch4 NoSymbol XF86Launch4
keycode 212 = XF86LaunchB NoSymbol XF86LaunchB
keycode 213 = XF86Suspend NoSymbol XF86Suspend
keycode 214 = XF86Close NoSymbol XF86Close
keycode 215 = XF86AudioPlay NoSymbol XF86AudioPlay
keycode 216 = XF86AudioForward NoSymbol XF86AudioForward
keycode 217 =
keycode 218 = Print NoSymbol Print
keycode 219 =
keycode 220 = XF86WebCam NoSymbol XF86WebCam
keycode 221 =
keycode 222 =
keycode 223 = XF86Mail NoSymbol XF86Mail
keycode 224 = XF86Messenger NoSymbol XF86Messenger
keycode 225 = XF86Search NoSymbol XF86Search
keycode 226 = XF86Go NoSymbol XF86Go
keycode 227 = XF86Finance NoSymbol XF86Finance
keycode 228 = XF86Game NoSymbol XF86Game
keycode 229 = XF86Shop NoSymbol XF86Shop
keycode 230 =
keycode 231 = Cancel NoSymbol Cancel
keycode 232 = XF86MonBrightnessDown NoSymbol XF86MonBrightnessDown
keycode 233 = XF86MonBrightnessUp NoSymbol XF86MonBrightnessUp
keycode 234 = XF86AudioMedia NoSymbol XF86AudioMedia
keycode 235 = XF86Display NoSymbol XF86Display
keycode 236 = XF86KbdLightOnOff NoSymbol XF86KbdLightOnOff
keycode 237 = XF86KbdBrightnessDown NoSymbol XF86KbdBrightnessDown
keycode 238 = XF86KbdBrightnessUp NoSymbol XF86KbdBrightnessUp
keycode 239 = XF86Send NoSymbol XF86Send
keycode 240 = XF86Reply NoSymbol XF86Reply
keycode 241 = XF86MailForward NoSymbol XF86MailForward
keycode 242 = XF86Save NoSymbol XF86Save
keycode 243 = XF86Documents NoSymbol XF86Documents
keycode 244 = XF86Battery NoSymbol XF86Battery
keycode 245 = XF86Bluetooth NoSymbol XF86Bluetooth
keycode 246 = XF86WLAN NoSymbol XF86WLAN
keycode 247 =
keycode 248 =
keycode 249 =
keycode 250 =
keycode 251 =
keycode 252 =
keycode 253 =
keycode 254 =
keycode 255 =
实验环境 Ubuntu 18.04 , inittab 模式切换可以使用以下脚本,将脚本保存为 inittab.sh 后执行 sudo ./inittab.sh 3 && sudo reboot
可以进入为启动X server 的状态,执行 sudo ./inittab.sh 5 && sudo reboot
后可以恢复图形界面。
#!/bin/bash
# Change default runlevel on Debian systemd based system
# linux shell color support.
RED="\\033[31m"
GREEN="\\033[32m"
YELLOW="\\033[33m"
BLACK="\\033[0m"
if [ "X_$1" = "X_" ]; then
runlevel
elif [ $1 -ge 0 -a $1 -le 6 ]; then
sudo ln -sf /lib/systemd/system/runlevel$1.target /etc/systemd/system/default.target
else
echo -e "${RED} please input args 0-6 ${BLACK}"
fi
#end
在 X server 未启动的情况下启动一个 xclock 实验:
sudo xinit /usr/bin/xclock -- /usr/bin/X :0
xclock 相对于 X11 类似于 编程语言中的 Hello Wrold,经常拿它来验证 X11 服务的状态。
切换到shell界面使用 Ctrl + Alt + F1
恢复到xclock界面使用 Ctrl + Alt + F3
linux是一个多用户操作系统,它可以同时接受多个用户登录。linux还允许一个用户进行多次登录,这是因为linux和Unix一样,提供了虚拟控制台的访问方式,允许用户同时从不同的虚拟控制台进行多次登录。
虚拟控制台的选择可以通过Ctrl+Alt+F(1~6) 来实现
1.在 MacOS 中本地显示远程启动的X11程序界面
在 MacOS 中安装 XQuartz 然后通过 ssh 登录远程 Linux 系统,
首先 允许远程主机的连接 xhost +192.168.1.1
,然后 ssh 登录中增加参数 -X 或者 -Y 例如 ssh -Y 192.168.1.1
登录成功后 xclock 就可以在本地显示 xclock 界面。
2.远程登录 ssh 后,让 X11 程序显示在远程显示器上
当远程登录主机时,如果不加 -X 参数 运行 X11 程序时通常会出错,因为当前shell的 DISPLAY 变量没有被设置,这是增加 DISPLAY 变量可以让程序在远程主机的显示器上输出,例如下面的命令可以实现远程锁屏 env DISPLAY=:0 slock &
在 MacOS 或者 Windows 中使用 docker 时需要运行图形界面可以在相应的操作系统下运行一个 X11 的 server 然后在 docker run 的时候 将 DISPLAY 变量指向本地 IP 的 6000 端口即可。
注意:XQuartz 默认不允许网络客户端连接,需要手动开启并重启服务。开启方法为:XQuartz 偏好设置 -> 安全性 -> 允许从网络客户端连接
docker 1803 以后的版本 支持变量 host.docker.internal
参考自:https://docs.docker.com/docker-for-windows/networking/
docker run -it -e DISPLAY=host.docker.internal:0 aggresss/x11