feat: detect and play DVDs where a drive is fitted

DVD support stays optional per room: DVD_ENABLED decides whether the
button is built at all, and rooms without it poll nothing. Upgrades
append a commented DVD_ENABLED=false so the option is discoverable
without changing what those rooms already do.

The dock polls the drive with CDROM_DRIVE_STATUS, which is a status
query rather than a read, so it does not spin the disc up. A disc that
becomes ready announces itself once and brings the DVD logo up to full
strength; an empty or unplugged drive holds it back, the same gray
versus colour language the LIVE icon already uses. Nothing autoplays —
playback always needs a deliberate press.

Playback is VLC rather than mpv because mpv dropped DVD menu support,
and menus are the part that matters for a commercial disc. It goes
through classroom-window like everything else, so the player minimizes
and restores from the dock exactly as the browser does.

Pressing the button with no drive, no disc, or a disc still spinning up
gives a plain-language notification instead of failing silently.

Reading the drive needs group cdrom, which the postinst grants and the
OTA reboot activates. Commercial CSS discs additionally need libdvdcss,
which Debian cannot ship; classroom-dvd-css-setup bootstraps it from
contrib. That is deliberately not run from the postinst, which executes
while dpkg already holds the apt lock.

The optical helpers live in a shared module both the dock and
classroom-dvd import, and the dock imports it defensively: if it ever
goes missing the shell loses disc detection rather than failing to
start.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
ekklesia
2026-09-04 17:07:25 -05:00
co-authored by Claude Opus 5
parent 6b133bdc3e
commit 0c1acfe5f5
7 changed files with 438 additions and 3 deletions
+53 -3
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import subprocess
import sys
from datetime import datetime
from pathlib import Path
@@ -11,11 +12,23 @@ gi.require_version("GtkLayerShell", "0.1")
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, GtkLayerShell
# Optional on purpose. The dock is the one thing the classroom cannot
# afford to lose, so a missing DVD helper simply disables disc detection
# instead of taking the whole shell down.
sys.path.insert(0, "/usr/local/lib/ekklesia-classroom")
try:
import classroom_optical as optical
except ImportError:
optical = None
CONFIG_FILE = Path("/etc/ekklesia-classroom/device.conf")
CSS_FILE = Path("/etc/ekklesia-classroom/dock/style.css")
ICON_DIR = Path("/etc/ekklesia-classroom/icons")
DVD_POLL_SECONDS = 2
def read_device_config():
config = {}
@@ -110,6 +123,9 @@ class ClassroomShell(Gtk.Window):
self.config = read_device_config()
self.dvd_image = None
self.disc_ready = None
GtkLayerShell.init_for_window(self)
GtkLayerShell.set_layer(
self,
@@ -207,9 +223,8 @@ class ClassroomShell(Gtk.Window):
dock.pack_start(
self.make_button(
self.dvd_icon(),
lambda *_: notify(
"DVD",
"DVD support is being prepared.",
lambda *_: launch(
["/usr/local/bin/classroom-dvd", "toggle"]
),
),
False,
@@ -217,6 +232,8 @@ class ClassroomShell(Gtk.Window):
0,
)
self.start_disc_watch()
dock.pack_start(
self.make_button(
self.sanctuary_icon(),
@@ -268,6 +285,7 @@ class ClassroomShell(Gtk.Window):
)
if image is not None:
self.dvd_image = image
return image
image = themed_icon(
@@ -307,6 +325,38 @@ class ClassroomShell(Gtk.Window):
return image
def start_disc_watch(self):
if optical is None:
return
self.check_disc()
GLib.timeout_add_seconds(
DVD_POLL_SECONDS,
self.check_disc,
)
def check_disc(self):
ready = optical.drive_status() == optical.CDS_DISC_OK
# The disc indicator: the DVD logo sits back when the drive is
# empty or unplugged and comes up to full strength once a disc is
# ready, the same gray/colour language the LIVE icon uses.
if self.dvd_image is not None:
self.dvd_image.set_opacity(1.0 if ready else 0.55)
# The first poll only records what is already in the drive, so a
# disc left in over the week does not announce itself at boot.
if self.disc_ready is not None and ready and not self.disc_ready:
notify(
"DVD Ready",
"A disc is ready to play.",
)
self.disc_ready = ready
return True
def update_time(self):
self.clock.set_text(
datetime.now().strftime("%-I:%M %p")