You are helping the user switch between different display configurations/profiles (e.g., docked, laptop only, presentation).
Switches between display configurations for docked, laptop-only, or extended monitor setups.
/plugin marketplace add danielrosehill/linux-desktop-plugin/plugin install lan-manager@danielrosehillYou are helping the user switch between different display configurations/profiles (e.g., docked, laptop only, presentation).
Check current display setup:
# Display server type
echo $XDG_SESSION_TYPE
# Connected displays
kscreen-doctor -o # KDE/Wayland
# OR
xrandr --query # X11
Ask user which profile they want:
KDE Plasma - Use saved profiles:
# List saved display configurations
ls ~/.local/share/kscreen/
# KDE automatically switches profiles based on connected displays
# Force reload configuration
kscreen-doctor --reload
Create/Use autorandr (X11):
# Install if not present
sudo apt install autorandr
# Save current configuration as profile
autorandr --save profile-name
# Switch to saved profile
autorandr --load profile-name
# Auto-detect and load appropriate profile
autorandr --change
Manual X11 configuration examples:
Laptop only:
xrandr --output eDP-1 --auto --primary \
--output HDMI-1 --off \
--output DP-1 --off
Docked (external monitors only):
xrandr --output eDP-1 --off \
--output HDMI-1 --auto --primary \
--output DP-1 --auto --right-of HDMI-1
Extended (laptop + external):
xrandr --output eDP-1 --auto \
--output HDMI-1 --auto --primary --above eDP-1
Mirrored:
xrandr --output eDP-1 --auto \
--output HDMI-1 --auto --same-as eDP-1
Wayland/KDE configuration:
# Laptop only
kscreen-doctor output.eDP-1.enable \
output.HDMI-1.disable \
output.DP-1.disable
# Docked
kscreen-doctor output.eDP-1.disable \
output.HDMI-1.enable output.HDMI-1.primary \
output.DP-1.enable output.DP-1.position.1920,0
# Extended
kscreen-doctor output.eDP-1.enable \
output.HDMI-1.enable output.HDMI-1.primary \
output.HDMI-1.position.0,-1080
Create quick-switch scripts:
# Create scripts directory
mkdir -p ~/.local/bin/display-profiles
# Example: Laptop only script
cat > ~/.local/bin/display-profiles/laptop-only.sh << 'EOF'
#!/bin/bash
xrandr --output eDP-1 --auto --primary \
--output HDMI-1 --off \
--output DP-1 --off
notify-send "Display Profile" "Switched to: Laptop Only"
EOF
chmod +x ~/.local/bin/display-profiles/laptop-only.sh
Create keyboard shortcuts (KDE):
# Add custom shortcut
kwriteconfig6 --file kglobalshortcutsrc \
--group "Display Profile - Laptop" \
--key "_k_friendly_name" "Laptop Display Only"
Automatic profile switching with udev:
# Create udev rule for auto-switching when docking
sudo tee /etc/udev/rules.d/95-monitor-hotplug.rules << 'EOF'
ACTION=="change", SUBSYSTEM=="drm", RUN+="/usr/local/bin/display-switch.sh"
EOF
# Create switch script
sudo tee /usr/local/bin/display-switch.sh << 'EOF'
#!/bin/bash
export DISPLAY=:0
export XAUTHORITY=/home/user/.Xauthority
/usr/bin/autorandr --change
EOF
sudo chmod +x /usr/local/bin/display-switch.sh
sudo udevadm control --reload-rules
Profile not loading:
xrandr or kscreen-doctor -oAutomatic switching not working:
journalctl -f while connecting/disconnecting displaysBlack screen after switching:
xrandr --autosudo systemctl restart sddm (or gdm, lightdm)