Skip to content

Instantly share code, notes, and snippets.

@JamesMcMahon
Last active June 30, 2025 22:53
Show Gist options
  • Save JamesMcMahon/23e365b02f4a6b9d4f02ccecbf4ebc73 to your computer and use it in GitHub Desktop.
Save JamesMcMahon/23e365b02f4a6b9d4f02ccecbf4ebc73 to your computer and use it in GitHub Desktop.
Script to toggle HDR in KDE Plasma
#!/usr/bin/env bash
# Toggle HDR on a given display using kscreen-doctor
# Usage: ./toggle-hdr.sh <output-name>
# Example: ./toggle-hdr.sh DP-2
set -euo pipefail
OUTPUT="${1:-DP-2}"
# Get HDR status for the specified output
HDR_STATUS=$(kscreen-doctor -o | \
grep -i "$OUTPUT" -A 20 | \
grep -i "HDR" | \
grep -ioP "[deins]{2,3}abled")
if [[ "$HDR_STATUS" == "enabled" ]]; then
echo "HDR is enabled on $OUTPUT. Disabling..."
kscreen-doctor "output.$OUTPUT.hdr.disable"
# Script assumes you want wide color gamut off for SDR content
# if that is not the case, remove this line
kscreen-doctor "output.$OUTPUT.wcg.disable"
elif [[ "$HDR_STATUS" == "disabled" ]]; then
echo "HDR is disabled on $OUTPUT. Enabling..."
kscreen-doctor "output.$OUTPUT.hdr.enable"
kscreen-doctor "output.$OUTPUT.wcg.enable"
else
echo "Could not determine HDR status for $OUTPUT. Got: '$HDR_STATUS'"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment