VovanR / onair

Webcamera and Microphone onair status
MIT License
0 stars 0 forks source link

PC docs #4

Open VovanR opened 5 days ago

VovanR commented 5 days ago

Webcamera is active (1 or 0 when inactive):

lsmod | grep uvcvideo --max-count=1 | awk '{print $3}'

Check every 5 seconds.
With systemd https://wiki.archlinux.org/title/Systemd/User

mkdir -p ~/.config/systemd/user/

touch ~/.config/systemd/user/onair.service

[Unit]
Description=Onair Daemon

[Service]
ExecStart=%h/.local/bin/onair.sh

[Install]
WantedBy=default.target

touch .config/systemd/user/onair.timer

[Unit]
Description=Onair Schedule

[Timer]
AccuracySec=1s
OnBootSec=5
OnUnitActiveSec=5

[Install]
WantedBy=timers.target

after edit reload

systemctl --user daemon-reload 

Check

systemctl --user
journalctl --user-unit onair.service
systemctl --user status onair.service
mkdir ~/.local/bin/
touch ~/.local/bin/onair.sh
#!/bin/bash

fn () {
    status=$(lsmod | grep uvcvideo --max-count=1 | awk '{print $3}')
    if [ ${status} == "1" ]; then
        curl -d '{"status":true}' -X POST http://192.168.1.1:3000/api/status -H "Content-Type: application/json" 
    fi
}

fn

exit 0

systemctl --user enable onair.service systemctl --user start onair.service systemctl --user enable onair.timer systemctl --user start onair.timer

VovanR commented 3 days ago

Podman

podman kube play onair.yaml