GNU General Public License v3.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

技术分析:i3-and-kde-plasma 项目

项目背景与痛点

i3-and-kde-plasma 项目提供了一种简便的方法,在 KDE 桌面环境下安装 i3 窗口管理器。这解决了在现代 Linux 桌面环境中实现轻量级窗口管理与功能丰富的 DE 无缝集成的问题。i3 是一个非常灵活和可定制的 tiling 窗口管理器,而 KDE Plasma 提供了丰富的桌面和系统管理功能。将两者融合,用户就可以在保持高效生产力的同时,享受完整的桌面体验,而无需牺牲任何一个组件的功能。

对于需要高性能和高度自定义的开发者或高级用户来说,该项目提供了必要的工具和脚本,以实现最优的集成效果。

核心技术揭秘

项目架构

项目主要包含安装脚本和配置文件,这些脚本负责在 KDE 环境下安装 i3 窗口管理器,并进行相应的配置调整。以下是该项目的核心组件及其工作原理:

  • 安装脚本:自定义的 shell 脚本,用于处理包管理、软件安装和配置文件的设置。
  • 配置文件:包括 i3 的配置文件(i3.config)和 KDE 桌面的配置文件。此外,还可能包含一些自定义的 KDE PLASMA 面板和应用程序启动脚本。
数据流图
graph TD subgraph "用户" User("用户选择 i3") end User --> S[shell 脚本启动] S -->|"安装依赖包"| Deps[安装 KDE 和 i3] Deps -->|"配置 i3"| I3Config[设置 i3.conf] I3Config -->|"配置 KDE"| KDEConfig[修改 KDE 设置] I3Config -->|"开启 i3 初始化"| Init[加载 i3 初始化脚本] KDEConfig -->|"启动 Deskbar"| Deskbar[启动 KDE 面板] Init -->|"显示桌面"| Show[显示 i3 桌面]

核心实现原理

1. 安装依赖包:脚本首先确保所有必要的软件包都可以通过包管理器获得。这是通过分析当前系统状态并安装缺失的软件包来实现的。

2. 个性化配置:

  • i3 窗口管理器:生成包含角色设定和预设配置项的 i3 config 文件。
  • KDE Plasma:通过环境变量或配置文件定位并修改 KDE 设置,确保桌面环境与 i3 无缝对接。KDE 面板中添加额外的模块或应用程序快捷方式,使其完美匹配 i3 风格。

3. 初始化脚本:初始化脚本确保在用户登录时启动 i3 以及必要的组合设置。这些脚本通常位于用户的主目录下,例如 .config/i3/。

4. 配置传递:所有配置信息通过环境变量和文件传递,确保整个安装过程的无缝和一致性。

配置文件的作用

配置文件的合理设计是确保 i3 和 KDE Plasma 无缝协作的关键。项目提供了示例配置文件,这些文件是可扩展的,允许用户根据需要修改。

功能亮点与差异

与其他类似项目相比,i3-and-kde-plasma 在自动化、简化集成过程和提供高度可定制性方面更为出色。其中亮点包括:

  1. 自动化程度高:为用户提供了一步到位的脚本,可以处理从最初设置到最终配置的每个步骤。
  2. 高度可定制性:配置文件和脚本都允许高度自定义,使用户可以根据个人喜好和具体需要进行调整。
  3. 完整的桌面环境集成:确保了桌面环境的丰富功能与 i3 的轻量级窗口管理功能无缝结合。

其他项目大多数只提供 i3 的安装指导,而 i3-and-kde-plasma 则通过多个方面确保了 KDE Plasma 和 i3 之间的无缝集成。

应用场景与落地建议

在实际生产环境中使用 i3-and-kde-plasma 时,需注意以下事项:

  1. 兼容性:确保你的系统支持所有必要的包和组件。
  2. 备份配置:在进行任何定制或大改动之前,备份原有的 KDE 和 i3 配置文件。
  3. 逐步测试:在应用所有更改前,逐项进行测试并确保不会破坏当前的工作环境。

该方案适用的场景包括:

  • 需要高度个性化桌面环境的高级用户。
  • 对系统资源消耗敏感但又想要享受丰富的桌面体验的用户。

综合评价

优点:

  • 卓越的自动化和安装脚本设计。
  • 提供高度可定制的配置文件,增加了灵活性和稳定性。
  • 无缝集成 KDE Plasma 和 i3,增强效率同时保持高度定制的桌面氛围。

缺点:

  • 对于初学者而言,即便是有指南的情况下,仍可能需要额外的努力来应对不同的系统环境和个性化设置。
  • 必须熟悉 shell 脚本的编写和基本的 Linux 系统配置,这可能是一个门槛。

i3-and-kde-plasma 项目显示出卓越的设计和实现,对于那些追求高效的Linux桌面环境及方法的用户来说,它无疑是值得探索的技术领域。

关于

GitHub 原始描述(英文)

How to install the i3 window manager on KDE

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
1062
价值分
598
活跃状态
活跃

README

i3 and KDE Plasma

How to install the i3 window manager on KDE Plasma.

Preview image: screenshot of my current setup


Situation before the installation

  • Manjaro KDE Edition, all updates installed
  • KDE Plasma
  • KWin

Installation

Packages

We’re gonna install a couple packages that are required or nice-to-haves on i3, as well as i3 itself. This consists of:

  • i3, obviously
  • feh to set up the background
  • dmenu (not required, but nice to have)
  • morc_menu (not required)
  • wmctrl to get some info for the i3 config (if you’re not on an English installation of Plasma)

Here’s a oneliner on how I installed everything: $ sudo pacman -Syu && sudo pacman -S i3 feh j4-dmenu-desktop morc_menu wmctrl


Configuration

Check your Plasma version by running:

plasmashell --version

If you are using Plasma >=5.25, you can either (i) create a new systemd user service to run i3 instead of KWin upon login (see option 1) or (ii) you can also disable systemd startup and proceed with option 2, creating a new XSession. Option 1 is per-user, whereas option 2 is systemwide and requires root.

If you are using Plasma <5.25, you need to create a new XSession and login to that, which means only option 2 is available for you.

Option 1: systemd user service (Plasma >=5.25)

Note that for this method, you do not need to be the root user. However, that means the changes will not effect the other users.

Create a new service file called plasma-i3.service in $HOME/.config/systemd/user.

Write the following into $HOME/.config/systemd/user/plasma-i3.service:

[Unit]
Description=Launch Plasma with i3
Before=plasma-workspace.target

[Service]
ExecStart=/usr/bin/i3
Restart=on-failure

[Install]
WantedBy=plasma-workspace.target

Mask plasma-kwin_x11.service by running systemctl mask plasma-kwin_x11.service --user

Enable the plasma-i3 service by running systemctl enable plasma-i3 --user

To go back to KWin, just unmask the plasma-kwin_x11.service and disable your plasma-i3 service in the same way.


Option 2: New XSession

Create a new file called plasma-i3.desktop in the /usr/share/xsessions directory as superuser.

Write the following into /usr/share/xsessions/plasma-i3.desktop:

[Desktop Entry]
Type=XSession
Exec=env KDEWM=/usr/bin/i3 /usr/bin/startplasma-x11
DesktopNames=KDE
Name=Plasma with i3
Comment=Plasma with i3

The i3 installation could have installed other .desktop files, you can remove them if you’d like. I only have the default plasma.desktop and plasma-i3.desktop in my folder.

For the following use your existing i3 config or create a new config using $ i3-config-wizard (this also works when you’re still in KWin).

Your i3 config should be located at ~/.config/i3/config, although other locations are possible (depending on your personal configuration).

If you are on Plasma 5.25 or later, you need to configure Plasma, disabling the systemd startup.

$ kwriteconfig5 --file startkderc --group General --key systemdBoot false
$

Adding stuff to the i3 config

To improve compatibility with Plasma, add the following lines in your i3 config.

# Plasma compatibility improvements
for_window [window_role="pop-up"] floating enable
for_window [window_role="task_dialog"] floating enable

for_window [class="yakuake"] floating enable
for_window [class="systemsettings"] floating enable
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"] border none, move position 70 ppt 81 ppt
no_focus [class="plasmashell" window_type="notification"]

Killing the existing window that covers everything

With my installation, there was a Plasma Desktop window that covered everything and had to be closed with $mod+Shift+q every time I logged in. To circumvent that, follow this tutorial.

English Plasma settings instructions

If you’re on an English installation of Plasma, add this line to your i3 config:

For Plasma >=5.27

for_window [title="Desktop @ QRect.*"] kill, floating enable, border none

OR for Plasma <5.27

for_window [title="Desktop — Plasma"] kill, floating enable, border none


Non-English Plasma settings instructions

If you’re not on the English setting, do this instead. This example is using the German Plasma setting.

Find out the name of your Plasma desktop

Directly after logging into your i3 environment, switch to a new workspace with $mod+2. Then enter the following in your terminal:

$ wmctrl -l

The output should contain the name of the Plasma window. Copy the name into your clipboard.

...
0x04400006  0 alex-mi Arbeitsfläche — Plasma
...
Set it in the i3 config

Using the name from the clipboard as te title, add the following lines to your i3 config:

for_window [title="Desktop — Plasma"] kill, floating enable, border none
for_window [title="Arbeitsfläche — Plasma"] kill, floating enable, border none

Disabling a shortcut that breaks stuff

Launch the Plasma System Settings and go to Category Workspace > Shortcuts > Category System Services > Plasma and disable the shortcut “Activities…” that uses the combination Meta+Q.

Using the plasma shutdown screen

To use the plasma shutdown/logout/reboot screen, delete this line (or comment out)

bindsym $mod+Shift+e exec "i3-nagbar " ...

and add the following one(s) instead:

For KDE 4
# using plasma's logout screen instead of i3's
bindsym $mod+Shift+e exec --no-startup-id qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1

For KDE 5
# using plasma's logout screen instead of i3's
bindsym $mod+Shift+e exec --no-startup-id qdbus-qt5 org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1

Note: With some distros, even if you have KDE 5 and Qt 5, the above line may not work and would require calling qdbus instead of qdbus-qt5, as shown under KDE 4.


Audio buttons integration

To control the volume via DBus with nice popups and sounds, you can add the following lines to the i3config:

bindsym XF86AudioRaiseVolume exec --no-startup-id qdbus org.kde.kglobalaccel /component/kmix invokeShortcut "increase_volume"
bindsym XF86AudioLowerVolume exec --no-startup-id qdbus org.kde.kglobalaccel /component/kmix invokeShortcut "decrease_volume"
bindsym XF86AudioMute exec --no-startup-id qdbus org.kde.kglobalaccel /component/kmix invokeShortcut "mute"
bindsym XF86AudioMicMute exec --no-startup-id qdbus org.kde.kglobalaccel /component/kmix invokeShortcut "mic_mute"

What next?

Here are a couple of advanced things that may be nice to do for a “prettier” desktop.

Setting the Background (optional)

NOTE: This section is outdated. The “Andromeda” packages are no longer in the Manjaro repositories. However, I am leaving it in because the principle stays the same, regardless where you save your images.

By default, i3 doesn’t set a background and it requires a third party program to do that. I am using the default background provided by the Plasma theme “Andromeda” and a program called feh to set the background.

I installed these following packages for the background and theme:

$ sudo pacman -S andromeda-wallpaper plasma5-themes-andromeda sddm-andromeda-theme andromeda-icon-theme

and enabled the theming in the Plasma settings.

To set up the same wallpaper in i3, add the following line to the i3 config:

exec --no-startup-id feh --bg-scale /usr/share/plasma/look-and-feel/org.manjaro.andromeda.desktop/contents/components/artwork/background.png

Editing the bar (optional)

The i3 bar has a nice feature that allows it to be hidden, unless you press $mod. I enabled this, because I have the Plasma status bar.

This is my bar config. It sets the command that should be called to get the current system status, makes it a bit larger and a bit less black. To use the i3 bar instead of the plasma one, you should be able to just remove it with your mouse (navigate through the right click menus of the bar).

bar {
    status_command i3status
    mode hide
    height 30
    colors {
      background #242424
    }
}

Enable transparency (optional)

If you’d like to enable transparency, you need to install a compositor. I use picom, and it works really well with minimal (no) configuration. First, install picom: $ sudo pacman -S picom

Then, add this line to your i3 config: exec_always --no-startup-id picom -bc

Preview image:

screenshot of my setup with transparency enabled

Dual Kawase blur (optional)

This was a bit more tricky to do. Instead of the normal picom from Manjaro’s repository, I used picom-git from the AUR.

To configure picom, I copied /etc/xdg/picom.conf.example to ~/.config/picom.conf. Picom should already pick up this config. There are a couple of things you need to change.

To set everything up for the blur effect, set the following settings:

backend = "glx";
blur_method = "dual_kawase";
blur_deviation = true;

To start picom in a way that supports kawase blur, replace the line in your i3 config that starts picom with this one:

exec --no-startup-id picom --experimental-backends -b

Preview image:

with blur and looking good


You’ve reached the end! That’s it! I hope this little tutorial helped you, and if you see anything you’d like to improve, absolutely feel free to do so! My issues are open, as are pull requests.

评论

暂无评论