#!/bin/bash
set -euo pipefail

# Light or dark, for a room whose teachers prefer one.
#
# There is one interface, not two. Both schemes are the same token file with
# the roles swapped, and Plasma applies them to the panel, the notifications,
# the window decorations and every dialog at once, so nothing has to be kept
# in step by hand.

usage() {
    echo "usage: classroom-theme [light|dark|toggle|show]" >&2
    exit 2
}

current() {
    kreadconfig6 --file kdeglobals --group General --key ColorScheme 2>/dev/null \
        || echo EkklesiaDark
}

apply() {
    plasma-apply-colorscheme "$1" >/dev/null
    echo "$1"
}

case "${1:-show}" in
light)  apply EkklesiaLight ;;
dark)   apply EkklesiaDark ;;
toggle)
    if [[ "$(current)" == EkklesiaLight ]]; then apply EkklesiaDark
    else apply EkklesiaLight; fi
    ;;
show)   current ;;
*)      usage ;;
esac
