Skip to content

Commit

Permalink
update snippets
Browse files Browse the repository at this point in the history
Former-commit-id: 55547c6a7adde87df510049c7a864a17b6351983
  • Loading branch information
2e0byo committed Oct 8, 2020
1 parent 5c1eed8 commit ae9c2f9
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions content/post/computing/webcam-on-and-off.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ae9c2f9

Please sign in to comment.