Installing Compton on Ubuntu
Before configuring dual screens, ensure Compton is installed. Run the following commands to update your package list and install Compton:
sudo apt update
sudo apt install compton
Creating/Editing the Compton Configuration File
Compton’s default configuration file is located at ~/.config/compton.conf. If it doesn’t exist, create the directory and file manually:
mkdir -p ~/.config
touch ~/.config/compton.conf
Open the file with a text editor (e.g., nano ~/.config/compton.conf) to add or modify settings.
Configuring Dual Screens in Compton
The most critical part of dual-screen setup is defining monitor layouts. Use the screen section to specify each display’s position relative to the others. First, identify your monitor names with:
xrandr --query
This command lists all connected displays (e.g., HDMI-1, eDP-1). Replace these names in the example below to match your setup:
screen0 {
output HDMI-1 # Replace with your secondary monitor name (e.g., HDMI-1, DP-1)
position LeftOf eDP-1 # Place secondary monitor to the left of the primary (replace eDP-1 with your primary monitor name)
}
screen1 {
output eDP-1 # Primary monitor
position RightOf HDMI-1 # Place primary monitor to the right of the secondary
}
Key parameters:
output: Specifies the monitor name from xrandr --query.position: Defines the relative placement of monitors (e.g., LeftOf, RightOf, Above, Below).Additional Optional Settings
Optimize performance and visuals with these common configurations:
# Enable OpenGL acceleration for smoother rendering
backend "glx"
glx-no-stencil true # Disables stencil buffer for better performance
glx-copy-from-front false # Improves performance in multi-monitor setups
# Configure shadows (exclude panels/windows to avoid visual glitches)
shadow-exclude = [
"class_g = 'gnome-panel'", # Exclude GNOME panel
"class_g = 'gnome-terminal'", # Exclude terminal windows
"class_g = 'firefox'" # Exclude Firefox windows
]
shadow-radius = 5 # Softens shadow edges
shadow-opacity = 0.5 # Adjusts shadow transparency
# Set frame rate limit to reduce CPU/GPU usage
fps-limit = 60
Save changes after editing.
Starting Compton with the New Configuration
Test your configuration by running Compton with the custom config file:
compton -c ~/.config/compton.conf
If the dual-screen setup works as expected, proceed to set up automatic startup.
Setting Up Compton to Start on Boot
To ensure Compton launches automatically after login, create a systemd service:
sudo nano /etc/systemd/system/compton.service
Add the following content (replace YourUsername with your actual username):
[Unit]
Description=Compton Compositor
After=display-manager.service # Starts after the display manager (e.g., GDM, LightDM)
[Service]
ExecStart=/usr/bin/compton -c ~/.config/compton.conf
Restart=always # Restarts Compton if it crashes
User=YourUsername
[Install]
WantedBy=multi-user.target
Save the file, then enable and start the service:
sudo systemctl enable compton.service
sudo systemctl start compton.service
Verify Compton is running with:
systemctl --user status compton
You should see an “active (running)” status.
Troubleshooting Common Issues
xrandr --query and update the output parameters in the config file.shadow-exclude = ["all"]) or reduce the fps-limit.systemd service is enabled (sudo systemctl enable compton.service) and there are no syntax errors in the config file.For further customization, refer to the official Compton documentation.