教程/在Plasma中使用其他的窗口管理器
介绍
在Plasma中,默认的窗口管理器(WM)是KWin,它有很多特性,但是它只支持浮动窗口。Plasma允许你使用其他的窗口管理器,比如 i3, bspwm 或者 任何其他的平铺窗口管理器

大多数窗口管理器很少需要对其配置文件进行更改。
使用另一个窗口管理器时需要注意的一些事项:
- 平铺窗口管理器在使用组件(如面板)时可能会有问题。对于某些配置,某些选项将有助于缓解问题
大多数窗口管理器没有自己的混成器(compositors),因此缺乏像动画和透明度这样的特性。如果想要这些特性,就需要安装一个混成器 - 参见Arch Wiki
- 混成器也可以帮助解决屏幕撕裂,但在大多数情况下,检查视频驱动程序往往是更高效的方案。
在Plasma中使用其他的窗口管理器
用户范围: 使用系统设置
这是最简单的方法,但只对当前用户生效。
- 创建一个shell脚本 (比如:kde-i3.sh),并添加如下内容
#!/bin/sh export KDEWM=/usr/bin/i3
将其中的 /usr/bin/i3 替换为你想要用的窗口管理器位置。
- 启动 系统设置
- 选择 Startup and Shutdown
- 选择 Autostart
- 点击列表下方的 Add script
- 输入之前创建的脚本的位置,或者点击文件夹图标,使用一个对话框来找到它。点击“OK”,脚本就会添加到列表中
- 在“Run On”列中,从下拉列表中选择“Before Session Startup”
- 所选窗口管理器将在下次登录时使用
系统范围:添加一个X会话(XSession)
如果你有管理员(root) 权限,可以为X.org创建一个新的会话文件。
这样做有几个好处: 创建的会话对系统中的所有用户都可用, 而且切换回KWin 就像注销和重新登录一样简单。
使用管理员权限,为窗口管理器添加一个会话:
- 复制已有的Plasma会话文件
cp plasma.desktop plasma-i3.desktop
- 使用文本编辑器打开文件并修改Exec行和Des(可选)
[Desktop Entry] Type=XSession Exec=env KDEWM=/usr/bin/i3 /usr/bin/startplasma-x11 DesktopNames=KDE Name=Plasma (i3) Comment=Plasma by KDE w/i3
- 需要重启显示管理器, 最简单的方法是重启电脑。
I3 配置
安装
在开始配置之前,您应该确保系统上安装了i3或i3-gap。如果没有,请使用包管理器或Discover 安装这两个包中的一个。
配置I3
当你第一次启动i3时,它的默认全局配置(在/etc/i3/config
)将启动i3配置向导(i3-config-wizard), 它会让你选择一个键作为Mod键,并在~/.i3/config
生成用户本地配置。
如果您希望跨用户维护相同的配置(用户仍然可以用自己的本地配置覆盖它),请从全局配置文件中删除向导调用,直接使用全局配置文件。
下面的i3窗口规则将帮助你处理通知和其他一些Plasma窗口:
for_window [title="Desktop — Plasma"] kill; floating enable; border none
for_window [class="plasmashell"] floating enable;
for_window [class="Plasma"] floating enable; border none
for_window [title="plasma-desktop"] floating enable; border none
for_window [title="win7"] floating enable; border none
for_window [class="krunner"] floating enable; border none
for_window [class="Kmix"] floating enable; border none
for_window [class="Klipper"] floating enable; border none
for_window [class="Plasmoidviewer"] floating enable; border none
for_window [class="(?i)*nextcloud*"] floating disable
for_window [class="plasmashell" window_type="notification"] floating enable, border none, move right 700px, move down 450px
no_focus [class="plasmashell" window_type="notification"]
如果你使用非英语安装的Plasma,你需要找出桌面的确切窗口标题是什么。一种方法是使用wmctrl -l
。
比如这行
for_window [title="Desktop — Plasma"] kill; floating enable; border none
将窗口的名称添加到i3配置。这个例子是德语安装的Plasma。
通知的定位可能很棘手,因为并非所有通知的大小都取决于其内容。你也可以使用坐标定位,知道你的屏幕分辨率。例如,对于一个1920x1080的屏幕设置右上角的通知,可以使用这样的配置:
for_window [class="plasmashell" window_type="notification"] floating enable, border none, move position 1450px 20px
配置 Plasma
你可能会遇到与“Activities”功能相关的问题-快捷键(其中一些也被i3使用,如“Meta + Q”),似乎让i3没有响应。移除与Activity相关的全局快捷方式似乎可以解决这个问题。
如果要通过Plasma提供的类似i3bar那样的Pager显示,设置 Pager Settings > General > Text display 变为"Desktop name"
Bspwm configuration
For the most part, bspwm requires little additional configuration.
- A single Plasma panel, in most cases, is detected properly and bspwm will not place windows in its space. If the panel ends up presenting a problem, or when using multiple panels, the following may be added to .bspwmrcwhere size is the size of the panel in pixels. Also valid are bottom_padding, left_padding, and right_padding. As many of these directives may be used as necessary for multiple panels.
bspc config top_padding size
Hints and Tips
DBus
Since Meta key handling is in part performed by KWin, you will have to handle these shortcuts manually when you switch to a different window manager.
You can open some Plasma components with DBus commands. You can use this to map corresponding keybindings to DBus commands. To find a specific DBus command, you can look at dbus-monitor
or qdbusviewer
while you invoke the component in a standard Plasma set-up.
More info on meta key handling:
Some examples:
- Open Application Launcher
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.activateLauncherMenu
- Open Krunner
qdbus org.kde.kglobalaccel /component/krunner org.kde.kglobalaccel.Component.invokeShortcut 'run command'
- Open logout confirmation screen
qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1
For i3, you can map a keybinding with the bindsym command. Use --no-startup-id
to prevent the command from generating "i3" entries in the task manager.
Example:
bindsym $mod+Shift+e exec --no-startup-id <command>
If you want to map the modifier key itself, use the bindcode command - you have to specify the keycode generated by the key, which you can get via the xev
utility.
Example for the Meta key:
bindcode 133 --release exec --no-startup-id <command>
For Bspwn, you need to use the bspc
program. See Arch Linux wiki for more information.
More Information
- Window managers (Wikipedia)
- Window managers (Arch Linux wiki)
- Desktop environment (Wikipedia)
- Desktop environment (Arch Linux wiki)