Made this script to quickly toggle displays on and off on KDE as it seems there's no easy way to do it out of the box for desktops.
#!/usr/bin/env bash
# Made to easily toggle displays on KDE
# To make a system tray icon:
# - Create a desktop file for this script with KDE menu editor
# - Add the "Quicklaunch" widget to your panel and add the desktop file there
set -euo pipefail
[[ "${1-}" == "--help" ]] && echo "Usage: ${0##*/}" && exit
declare -A outputs
while read -r name enabled; do
outputs+=([$name]="$enabled")
done < <(kscreen-doctor --json | jq -r '.outputs[] | [.name, .enabled] | join(" ")')
unset "outputs[DP-1]" # Unset the main monitor connector, we don't want to toggle that one
for key in "${!outputs[@]}"; do
options+=("$key" "$key")
done
choice=$(kdialog --title 'Display Toggle' --menu 'Outputs' "${options[@]}")
if [[ "${outputs[$choice]}" == true ]]; then
kscreen-doctor output."$choice".disable
else
kscreen-doctor output."$choice".enable
fi