Installing Compton
Compton can be installed using your distribution’s package manager. For Debian/Ubuntu-based systems, run:
sudo apt update && sudo apt install compton
For Arch-based systems (e.g., Manjaro), use:
sudo pacman -S compton
This installs the latest version of Compton compatible with your system.
Configuring Compton for Wayland
Compton’s configuration file is typically located at ~/.config/compton.conf (create it if it doesn’t exist). To enable Wayland support, add or modify the following key:
backend = "wayland";
Additional optimizations (optional but recommended) include enabling shadows (with exclusions for performance) and transparency:
shadow = true;
shadow-exclude = ["WINDOW_CLASS=.*Firefox", "WINDOW_CLASS=.*Chrome"]; # Exclude resource-heavy apps
glx-no-stencil = true; # Improves performance
alpha-threshold = 0.05; # Sets transparency threshold
Save the file after editing.
Switching to a Wayland Session
Most Linux distributions allow you to choose between X11 and Wayland at login. On the login screen, click the gear icon (or equivalent) next to your username and select a Wayland session (e.g., “GNOME on Wayland” or “KDE Plasma on Wayland”). This ensures Compton runs under the Wayland display server.
Starting Compton Automatically
To start Compton when your system boots, create a Systemd service file:
sudo nano /etc/systemd/system/compton.service
Add the following content (replace your_username with your actual username):
[Unit]
Description=Compton Window Compositor
After=display-manager.service
[Service]
ExecStart=/usr/bin/compton --config ~/.config/compton.conf
Restart=always
User=your_username
[Install]
WantedBy=multi-user.target
Save the file, then enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable compton
sudo systemctl start compton
You can verify Compton is running with:
systemctl status compton
Alternatively, add Compton to your desktop environment’s autostart (e.g., GNOME: ~/.config/autostart/compton.desktop).
Troubleshooting Compatibility Issues
Some Wayland applications (notably input method frameworks like Fcitx5) may not work seamlessly with Compton. To resolve this:
- Exclude Input Method Windows: Add their window class to
shadow-excludeincompton.conf(e.g.,WINDOW_CLASS=.*Fcitx). - Use XWayland Fallback: If an app fails to render, launch it with
GTK_USE_PORTAL=1(e.g.,GTK_USE_PORTAL=1 firefox) to force it into XWayland mode, which Compton handles better.
以上就是关于“Compton与Wayland如何搭配”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm