From ae9c2f9756c4b9e146043f0965de1156e98ab5f4 Mon Sep 17 00:00:00 2001 From: John Maximilian <2e0byo@gmail.com> Date: Thu, 8 Oct 2020 18:57:55 +0100 Subject: [PATCH] update snippets Former-commit-id: 55547c6a7adde87df510049c7a864a17b6351983 --- content/post/computing/webcam-on-and-off.md | 23 ++++++++++++--------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/content/post/computing/webcam-on-and-off.md b/content/post/computing/webcam-on-and-off.md index 3c7a3b3..562ac05 100644 --- a/content/post/computing/webcam-on-and-off.md +++ b/content/post/computing/webcam-on-and-off.md @@ -59,23 +59,26 @@ amount of time I have spent typing at the computer that day, from my ```python def webcam_status(): - webcam = get_webcam() - if webcam: - status = get_webcam_status(webcam) - if status: - return "R", red + webcams = get_webcam() + statuses = [] + for webcam in webcams: + if webcam: + status = get_webcam_status(webcam) + if status: + statuses.append(("R", red)) + else: + statuses.append(("", green)) else: - return "", green - else: - return "O", orange + statuses.append(("O", orange)) + return statuses ``` where the colours are html codes defined elsewhere. This is then injected into the json: ```python -webcam, colour = webcam_status() -j.insert(0, {"full_text": webcam, "name": "webcam", "color": colour}) +for webcam, colour in webcam_status(): + j.insert(0, {"full_text": webcam, "name": "webcam", "color": colour}) ``` and if the webcam is recording, a red ‘R’ appears in the status line.