Tutorials/Using Other Window Managers with Plasma/zh-cn: Difference between revisions

From KDE UserBase Wiki
(Created page with "{{Note|在不同的发行版中,XSession文件位置有所不同,但大多数时候在 {{Path|/usr/share/xsessions}} }}")
 
(Updating to match new version of source page)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<languages />
<languages />


<span id="Introduction"></span>
==介绍==
==介绍==


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


<span id="Set-up"></span>
<div class="mw-translate-fuzzy">
==在Plasma中使用其他的窗口管理器==
==在Plasma中使用其他的窗口管理器==
</div>


===用户范围: 使用系统设置===
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 [https://wiki.archlinux.org/title/KDE#Use_a_different_window_manager ArchWiki].


这是最简单的方法,但只对当前用户生效。
<span id="Configuration"></span>
 
<div class="mw-translate-fuzzy">
[[Image:kde-i3-integration.png]]
== I3 配置==
 
</div>
*创建一个shell脚本 (比如:kde-i3.sh),并添加如下内容{{Input|1=<nowiki>
#!/bin/sh
export KDEWM=/usr/bin/i3
</nowiki>}}
将其中的 /usr/bin/i3 替换为你想要用的窗口管理器位置。


* 启动 '''系统设置'''
To make a non-standard WM work well with Plasma, some additional configuration may be required.


* 选择 '''Startup and Shutdown'''
===i3===  
 
* 选择 '''Autostart'''
 
* 点击列表下方的 '''Add script'''
 
* 输入之前创建的脚本的位置,或者点击文件夹图标,使用一个对话框来找到它。点击“OK”,脚本就会添加到列表中
 
* 在“Run On”列中,从下拉列表中选择“Before Session Startup”
 
* 所选窗口管理器将在下次登录时使用
 
{{注意|在最近的Plasma版本中,'''Run On''' 和 '''Before Session Startup''' 选项可能不可用。你可以将脚本复制或者链接到<code>$HOME/.config/plasma-workspace/env</code>目录下,以达到相同目的。
}}
 
=== 系统范围:添加一个X会话(XSession)===
 
如果你有管理员(root) 权限,可以为X.org创建一个新的会话文件。
 
这样做有几个好处: 创建的会话对系统中的所有用户都可用, 而且切换回'''KWin''' 就像注销和重新登录一样简单。
 
{{Note|在不同的发行版中,XSession文件位置有所不同,但大多数时候在 {{Path|/usr/share/xsessions}} }}
 
使用管理员权限,为窗口管理器添加一个会话:
 
* 复制已有的Plasma会话文件{{Input|1=<nowiki>cp plasma.desktop plasma-i3.desktop</nowiki>}}
 
* 使用文本编辑器打开文件并修改Exec行和Des(可选) {{Input|1=<nowiki>[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
</nowiki>}}
{{Warning|asma 5.17之前的版本中, 使用'''startkde''' 代替上面Exec命令中的'''startplasma-x11'''。}}
 
* 需要重启显示管理器, 最简单的方法是重启电脑。
 
{{Warning|确保在修改Exec指令时使用了正确的窗口管理器应用程序路径和名称。如果KDE无法启动窗口管理器,会话将失败,用户将回到登录屏幕。}}
 
{{Warning|在最近的一些版本中,SDDM检查<code>Exec</code>命令中是否有空格。如果发现空格,则在会话菜单中不会显示该条目。要解决这个问题,创建一个名为<code>plasma-i3.sh</code>的脚本,其中包含以下内容:{{Input|1=<nowiki>
#!/bin/sh
export KDEWM=/usr/bin/i3
/usr/bin/startplasma-x11
</nowiki>}}
设置脚本的执行权限并在'''plasma-i3.desktop'''中引用它:
{{Input|1=<nowiki>
Exec=/usr/local/bin/plasma-i3.sh
</nowiki>}}}}
 
== I3 配置==


<span id="Installation"></span>
<div class="mw-translate-fuzzy">
===安装===
===安装===
</div>


在开始配置之前,您应该确保系统上安装了i3或i3-gap。如果没有,请使用包管理器或[[Special:myLanguage/Discover|Discover]] 安装这两个包中的一个。
在开始配置之前,您应该确保系统上安装了i3或i3-gap。如果没有,请使用包管理器或[[Special:myLanguage/Discover|Discover]] 安装这两个包中的一个。


<span id="Configure_i3"></span>
<div class="mw-translate-fuzzy">
== 配置I3==
== 配置I3==
</div>


当你第一次启动i3时,它的默认全局配置(在<code>/etc/i3/config</code>)将启动i3配置向导(i3-config-wizard), 它会让你选择一个键作为Mod键,并在<code>~/.i3/config</code>生成用户本地配置。
当你第一次启动i3时,它的默认全局配置(在<code>/etc/i3/config</code>)将启动i3配置向导(i3-config-wizard), 它会让你选择一个键作为Mod键,并在<code>~/.i3/config</code>生成用户本地配置。
Line 97: Line 52:




<div class="mw-translate-fuzzy">
下面的i3窗口规则将帮助你处理通知和其他一些Plasma窗口:
下面的i3窗口规则将帮助你处理通知和其他一些Plasma窗口:
{{Input|1=<nowiki>for_window [title="Desktop — Plasma"] kill; floating enable; border none
{{Input|1=<nowiki>for_window [title="Desktop — Plasma"] kill; floating enable; border none
Line 111: Line 67:
no_focus [class="plasmashell" window_type="notification"]  
no_focus [class="plasmashell" window_type="notification"]  
</nowiki>}}
</nowiki>}}
</div>


如果你使用非英语安装的Plasma,你需要找出桌面的确切窗口标题是什么。一种方法是使用<code>wmctrl -l</code>。
如果你使用非英语安装的Plasma,你需要找出桌面的确切窗口标题是什么。一种方法是使用<code>wmctrl -l</code>。
Line 125: Line 82:
</nowiki>}}
</nowiki>}}


If you want to unlock KWallet automatically on login, configure PAM and then add the following line to your i3 configuration file:
{{Input|1=<nowiki>exec --no-startup-id /usr/lib/pam_kwallet_init
</nowiki>}}
<span id="Configure_Plasma"></span>
<div class="mw-translate-fuzzy">
===配置 Plasma===
===配置 Plasma===
</div>


你可能会遇到与“Activities”功能相关的问题-快捷键(其中一些也被i3使用,如“Meta + Q”),似乎让i3没有响应。移除与Activity相关的全局快捷方式似乎可以解决这个问题。
你可能会遇到与“Activities”功能相关的问题-快捷键(其中一些也被i3使用,如“Meta + Q”),似乎让i3没有响应。移除与Activity相关的全局快捷方式似乎可以解决这个问题。
Line 131: Line 95:
如果要通过Plasma提供的类似i3bar那样的Pager显示,设置 '''Pager Settings''' > '''General''' > '''Text display''' 变为"Desktop name"
如果要通过Plasma提供的类似i3bar那样的Pager显示,设置 '''Pager Settings''' > '''General''' > '''Text display''' 变为"Desktop name"


 
===Bspwm===
==Bspwm configuration==


For the most part, bspwm requires little additional 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 '''.bspwmrc'''{{Input|1=<nowiki>bspc config top_padding size</nowiki>}}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.
* 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'''{{Input|1=<nowiki>bspc config top_padding size</nowiki>}}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.
===awesomewm===
Following rules help Plasma to work as intended.
Add these entries into <code>awful.rules.rules</code> table
{{Input|1=<nowiki>
{ -- General plasma rules
    rule_any = {
        class = {
            "plasmashell",
            "ksmserver-logout-greeter",
        },
    },
    properties = {
        floating = true,
        border_width = 0,
        titlebars = false, -- custom property to control titlebars
    },
},
{ -- KDE apps
    rule_any = {
        class = {
            "spectacle",
            "krunner"
        }
    },
    properties = {
        floating = true,
    }
},
</nowiki>}}
Plasma widgets hide when they become unfocused. We do not want Desktop and Panel to be focusable, but want other <code>plasmashell</code> windows to remain focusable. A way to achieve this is with "manage" signal handler. An example handler:
{{Input|1=<nowiki>
client.connect_signal("manage", function(c)
--... your config
if c.type == "dock" -- Plasma Panel
    or c.type == "desktop" then -- Plasma Desktop
    c.focusable = false
    c:tags(c.screen.tags) -- show on all tags from this screen.
end
-- Show titlebars only if enabled.
if c.titlebars then
    awful.titlebar.show(c)
else
    awful.titlebar.hide(c)
end
-- Place floating windows. Plasma widgets provide this info
if c.floating then
    if c.size_hints.user_position then
        c.x = c.size_hints.user_position.x
        c.y = c.size_hints.user_position.y
    end
    if c.size_hints.user_size then
        c.width = c.size_hints.user_size.width
        c.height = c.size_hints.user_size.height
    end
end
..
end)
</nowiki>}}
You may match Plasma Desktop using the following rule:
{{Input|1=<nowiki>
rule_any = {
    name = {
      "Desktop.*Plasma",
    },
},
</nowiki>}}


==Hints and Tips==
==Hints and Tips==

Latest revision as of 01:30, 22 October 2023

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.

awesomewm

Following rules help Plasma to work as intended. Add these entries into awful.rules.rules table

{ -- General plasma rules
    rule_any = {
        class = {
            "plasmashell",
            "ksmserver-logout-greeter",
        },
    },
    properties = {
        floating = true,
        border_width = 0,
        titlebars = false, -- custom property to control titlebars
    },

},
{ -- KDE apps
    rule_any = {
        class = {
            "spectacle",
            "krunner"
        }
    },
    properties = {
        floating = true,
    }
},

Plasma widgets hide when they become unfocused. We do not want Desktop and Panel to be focusable, but want other plasmashell windows to remain focusable. A way to achieve this is with "manage" signal handler. An example handler:

client.connect_signal("manage", function(c)
--... your config

if c.type == "dock" -- Plasma Panel
    or c.type == "desktop" then -- Plasma Desktop
    c.focusable = false
    c:tags(c.screen.tags) -- show on all tags from this screen.
end

-- Show titlebars only if enabled.
if c.titlebars then 
    awful.titlebar.show(c)
else
    awful.titlebar.hide(c)
end

-- Place floating windows. Plasma widgets provide this info
 if c.floating then
    if c.size_hints.user_position then
        c.x = c.size_hints.user_position.x
        c.y = c.size_hints.user_position.y
    end
    if c.size_hints.user_size then
        c.width = c.size_hints.user_size.width
        c.height = c.size_hints.user_size.height
    end
end
..
end)

You may match Plasma Desktop using the following rule:

 rule_any = {
     name = {
       "Desktop.*Plasma",
     },
 },

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