教程/在Plasma中使用其他的窗口管理器

From KDE Wiki Sandbox
This page is a translated version of the page Tutorials/Using Other Window Managers with Plasma and the translation is 37% complete.
Outdated translations are marked like this.
Other languages:

介绍

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

Plasma 使用i3作为窗口管理器
Warning
切换窗口管理器功能仅在使用X.org时才可用,目前还不能用于Wayland会话。随着Wayland的成熟和Wayland扩展的标准化,这个功能才可能在Wayland中实现。[1]


大多数窗口管理器很少需要对其配置文件进行更改。

使用另一个窗口管理器时需要注意的一些事项:

  • 平铺窗口管理器在使用组件(如面板)时可能会有问题。对于某些配置,某些选项将有助于缓解问题

大多数窗口管理器没有自己的混成器(compositors),因此缺乏像动画和透明度这样的特性。如果想要这些特性,就需要安装一个混成器 - 参见Arch Wiki

    • 混成器也可以帮助解决屏幕撕裂,但在大多数情况下,检查视频驱动程序往往是更高效的方案。

在Plasma中使用其他的窗口管理器

To use a different window manager with Plasma, replace the systemd service for KWin with a new user unit for your preferred WM. A tutorial can be found in the ArchWiki.

I3 配置

To make a non-standard WM work well with Plasma, some additional configuration may be required.

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

If you want to unlock KWallet automatically on login, configure PAM and then add the following line to your i3 configuration file:

exec --no-startup-id /usr/lib/pam_kwallet_init

配置 Plasma

你可能会遇到与“Activities”功能相关的问题-快捷键(其中一些也被i3使用,如“Meta + Q”),似乎让i3没有响应。移除与Activity相关的全局快捷方式似乎可以解决这个问题。

如果要通过Plasma提供的类似i3bar那样的Pager显示,设置 Pager Settings > General > Text display 变为"Desktop name"

Bspwm

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 .bspwmrc
    bspc config top_padding size
    where 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.

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

References