ubuntu compton设置选项
Compton Configuration Options for Ubuntu
Compton is a lightweight window compositor for X11 that enhances desktop visuals with effects like transparency, shadows, and fading. Below is a structured guide to its key configuration options, setup steps, and optimization tips for Ubuntu.
1. Installation
Before configuring, install Compton using Ubuntu’s package manager:
sudo apt update &
&
sudo apt install compton
2. Configuration File Location
Compton’s primary user-specific config file is located at ~/.config/compton.conf
. If it doesn’t exist, create it with a text editor (e.g., nano ~/.config/compton.conf
). System-wide configs can be found at /etc/xdg/compton.conf
(for all users) or ~/.compton.conf
(legacy path).
3. Common Configuration Options
Below are essential options to customize Compton’s behavior, grouped by category:
A. Basic Settings
backend
: Defines the rendering backend. Choose between:xrender
(default, better compatibility but slower)glx
(faster performance, recommended for modern GPUs).
Example:backend = "glx"
.
vsync
: Enables vertical synchronization to reduce screen tearing. Set totrue
(recommended) orfalse
. For better performance, usevsync = "opengl-swc"
(OpenGL swapchain wait).shadow
: Toggles window shadows. Set totrue
to enable (with customizable radius/offset) orfalse
to disable (improves performance). Example:shadow = true
.opacity
: Controls window transparency. Useinactive-opacity
(for inactive windows, e.g.,0.8
) andactive-opacity
(for active windows, e.g.,1.0
). Set to1.0
to disable transparency entirely.ignore_root
: Ignores transparency for the root window (prevents issues in some desktop environments like GNOME). Set totrue
if you experience graphical glitches.
B. Visual Effects
shadow-radius
: Adjusts shadow blurriness (default:12
). Lower values make shadows sharper; higher values create a softer effect.shadow-offset-x/y
: Sets shadow offset from the window edge (default:-15
for both). Negative values place shadows inside the window; positive values place them outside.shadow-opacity
: Controls shadow transparency (default:0.75
). Lower values make shadows fainter; higher values make them more pronounced.fade-in/out
: Enables window fade effects when opening/closing. Set totrue
for smooth transitions (recommended) orfalse
to disable.fade-delta
: Adjusts fade speed (default:5
). Lower values make fades faster; higher values make them slower.
C. Performance Optimization
glx-no-stencil
: Disables stencil buffer usage (reduces GPU memory load). Set totrue
for better performance on older GPUs.glx-no-rebind-pixmap
: Prevents unnecessary pixmap rebinding (improves frame rate). Set totrue
.xrender-sync-fence
: Enables X11 sync fences (reduces tearing withxrender
backend). Set totrue
if usingbackend = "xrender"
.unredir-if-possible
: Disables composition for fullscreen windows (e.g., games) to improve performance. Set totrue
and add exceptions (e.g., media players) tounredir-if-possible-exclude
.max-cpu-usage
: Caps CPU usage (default:80%
). Set to a lower value (e.g.,60
) if Compton is consuming too many resources.
D. Advanced: Window-Specific Rules
shadow-exclude
: Excludes specific windows from shadows (e.g., notifications, docks). Use a list of conditions:shadow-exclude = [ "name = 'Notification'", "class_g = 'Conky'", "class_g = 'Cairo-clock'" ];
opacity-rule
: Sets transparency for specific applications. Use class names (find them withxprop | grep WM_CLASS
):opacity-rule = [ "90:class_g = 'Alacritty'", # Terminal at 90% opacity "80:class_g = 'URxvt'" # Another terminal at 80% ];
4. Applying Changes
After editing the config file, restart Compton to apply changes:
pkill compton &
&
compton -b
For Systemd users (to auto-start Compton on boot), create a service file:
sudo nano /etc/systemd/system/compton.service
Add this content (replace with your config path if needed):
[Unit]
Description=Compton Window Composer
After=xorg.service
[Service]
ExecStart=/usr/bin/compton --config /home/yourusername/.config/compton.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable compton
sudo systemctl start compton
5. Troubleshooting Tips
- Screen Tearing: Ensure
vsync
is enabled (vsync = "opengl-swc"
) and try different backends (glx
vs.xrender
). - High CPU Usage: Disable unnecessary effects (e.g.,
shadow = false
,fade-in/out = false
) and optimize GPU usage withglx-no-stencil = true
. - Application Glitches: Add problematic apps to
shadow-exclude
oropacity-rule
(e.g., Conky, notification daemons).
This guide covers the most essential Compton options for Ubuntu users. For advanced customization, refer to the official documentation or run compton --help
to explore additional parameters.
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: ubuntu compton设置选项
本文地址: https://pptw.com/jishu/719657.html