repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

caldav: setup form and keyring-backed saveSetup

79c02f542e7d1b466bedf82a50b6ebd97af97265

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Task 10: when the service has no usable config (status needs-setup), the
clock popout shows a setup form instead of the calendar — URL, username,
app-password fields and a Speichern button. saveSetup persists the
non-secret url+username, then stores the password in gnome-keyring via
'secret-tool store', feeding the secret over stdin (printf is a shell
builtin, so it never reaches argv/ps) with the password travelling QML->sh
only as a transient env var. On keyring failure the error surfaces in the
form via secretError; on success it discovers calendars and fetches.

Verified live: empty-field validation, password stored to keyring and
read back, no password in process argv, form layout, and no regression
(status ok, 155 events, selfTest 6/6, JS tests pass).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Changed files (2)

quickshell/nuguland/CalDav.qml

Modified
33 33 backend: "CalDav.qml",
34 34 status: status,
35 35 stale: stale,
36 + secretError: secretError,
36 37 host: host,
37 38 username: config ? config.username : "",
38 39 calendarCount: config && config.calendars ? config.calendars.length : 0,
213 214 root.stale = false;
216 - function saveSetup(url, username, password) {}
217 + // non-empty when the last keyring write failed; shown in the setup form
218 + property string secretError: ""
220 + // Persist url+username, store the password in gnome-keyring, then discover.
221 + // Password reaches secret-tool via stdin (printf is a shell builtin, so it
222 + // never appears in argv/ps); it travels QML->sh only as a transient env var.
223 + function saveSetup(url, username, password) {
224 + root.secretError = "";
225 + const u = String(url || "").trim().replace(/\/+$/, "");
226 + const user = String(username || "").trim();
227 + if (!u || !user || !password) { root.secretError = "URL, Benutzer und Passwort nötig"; return; }
228 + const m = /^https?:\/\/([^\/:]+)/.exec(u);
229 + const h = m ? m[1] : "";
230 + if (!h) { root.secretError = "URL ungültig (https://… erwartet)"; return; }
231 + root.config.url = u;
232 + root.config.username = user;
233 + root.config.calendars = [];
234 + root.persistConfig();
235 + root.status = "loading";
236 + storeProc.exec({
237 + command: ["sh", "-c", root.storeScript()],
238 + environment: { CALDAV_HOST: h, CALDAV_USER: user, CALDAV_NEWPW: String(password) }
239 + });
242 + function storeScript() {
243 + return 'printf %s "$CALDAV_NEWPW" | secret-tool store --label="nuguland caldav" service caldav host "$CALDAV_HOST" account "$CALDAV_USER"';
218 246 Process {
219 247 id: discoverProc
227 255 stderr: StdioCollector { waitForEnd: true; onStreamFinished: if (this.text.trim()) { root.stale = true; if (root.status === "loading") root.status = "offline"; } }
258 + Process {
259 + id: storeProc
260 + stderr: StdioCollector { waitForEnd: true; onStreamFinished: if (this.text.trim()) root.secretError = this.text.trim() }
261 + onExited: (code, status) => {
262 + if (code === 0) { root.secretError = ""; root.discoverAndFetch(); }
263 + else { root.status = "needs-setup"; if (!root.secretError) root.secretError = "Keyring-Fehler (" + code + ")"; }
230 267 Timer {
231 268 interval: 15 * 60 * 1000
232 269 running: true

quickshell/nuguland/PopoutHost.qml

Modified
266 266 property var days: calendar.weeks ? [].concat.apply([], calendar.weeks) : []
268 + readonly property bool setupMode: root.caldavService && root.caldavService.status === "needs-setup"
268 270 // iso "YYYY-MM-DD" -> array of single-day markers {color, allDay}.
269 271 // Multi-day events (coveredDates>1) are drawn as bands, not markers.
270 272 readonly property var caldavEvents: root.caldavService ? root.caldavService.events : []
334 336 // single-letter weekday header, Monday-first; weekend dimmed
338 + visible: !clockCol.setupMode
336 339 spacing: 2
338 341 Repeater {
361 364 Item {
365 + visible: !clockCol.setupMode
362 366 width: monthGrid.width
363 367 height: monthGrid.height
462 466 // today's agenda: events + tasks, ○ for open tasks, ✓ for done
463 467 Column {
468 + visible: !clockCol.setupMode
464 469 width: parent ? parent.width : 0
465 470 spacing: 4
515 + // setup form: shown when the service has no usable config yet.
516 + // Keystrokes need the popout to hold keyboard focus; the IPC
517 + // saveSetup path is the verified entry point.
518 + Column {
519 + id: setupForm
521 + visible: clockCol.setupMode
522 + width: parent ? parent.width : 0
523 + spacing: 8
525 + component Field: Rectangle {
526 + property alias field: ti
527 + property string placeholder: ""
528 + property bool secret: false
530 + width: setupForm.width
531 + height: 30
532 + radius: 10
533 + color: root.theme ? root.theme.withAlpha(root.theme.ui.minor, 0.14) : "transparent"
535 + TextInput {
536 + id: ti
538 + anchors.fill: parent
539 + anchors.leftMargin: 10
540 + anchors.rightMargin: 10
541 + verticalAlignment: TextInput.AlignVCenter
542 + color: root.theme ? root.theme.content.normal : "white"
543 + selectionColor: root.theme ? root.theme.ui.focus : "#ffffff"
544 + selectedTextColor: root.theme ? root.theme.content.backdrop : "black"
545 + font.family: "IBM Plex Sans"
546 + font.pixelSize: 13
547 + echoMode: parent.secret ? TextInput.Password : TextInput.Normal
548 + clip: true
551 + NuguText {
552 + anchors.left: parent.left
553 + anchors.leftMargin: 10
554 + anchors.verticalCenter: parent.verticalCenter
555 + visible: ti.text.length === 0
556 + theme: root.theme
557 + variant: "meta"
558 + text: parent.placeholder
563 + NuguText {
564 + theme: root.theme
565 + variant: "meta"
566 + text: "CalDAV einrichten"
569 + Field {
570 + id: urlField
572 + placeholder: "https://host/remote.php/dav"
575 + Field {
576 + id: userField
578 + placeholder: "Benutzername"
581 + Field {
582 + id: pwField
584 + placeholder: "App-Passwort"
585 + secret: true
588 + Rectangle {
589 + width: parent.width
590 + height: 30
591 + radius: 10
592 + color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.2) : "transparent"
594 + NuguText {
595 + anchors.centerIn: parent
596 + theme: root.theme
597 + variant: "meta"
598 + text: "Speichern"
601 + MouseArea {
602 + anchors.fill: parent
603 + cursorShape: Qt.PointingHandCursor
604 + onClicked: if (root.caldavService) root.caldavService.saveSetup(urlField.field.text, userField.field.text, pwField.field.text)
609 + NuguText {
610 + visible: root.caldavService && root.caldavService.secretError.length > 0
611 + theme: root.theme
612 + variant: "meta"
613 + color: root.theme ? root.theme.error : "red"
614 + text: root.caldavService ? root.caldavService.secretError : ""