forked from sayan01/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebcam
executable file
·42 lines (36 loc) · 1.23 KB
/
webcam
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
coff="/usr/share/icons/breath/status/22/camera-off.svg"
con="/usr/share/icons/breeze-dark/status/22/camera-on.svg"
if [ -e ~/.cache/webcam.lock ] # if client is already running
then
killall droidcam-cli # kill client
adb shell am force-stop com.dev47apps.droidcam # kill client from mobile
rm ~/.cache/webcam.lock -f # remove flag file
notify-send -i $coff -a "Webcam" "Camera client killed" &
exit 0
fi
# start adb port forwarding from phone to pc
if ! adb forward tcp:4747 tcp:4747; then
notify-send -i $coff -a "Webcam" "ADB port forwarding failed!" &
exit 1
fi
# if phone is locked notify and exit
if [ "$(adb shell dumpsys power | grep 'Screen off timeout' | awk '{print $4}')" = "10000" ]; then
notify-send -i $coff -a "Webcam" "Phone is locked" &
exit 1
fi
# start droidcam app in phone
if ! adb shell monkey -p com.dev47apps.droidcam 1 ; then
notify-send -i $coff -a "Webcam" "Droidcam app not installed!"
exit 1
fi
notify-send -t 3000 -i $con -a "Webcam" "Webcam ON"
touch ~/.cache/webcam.lock # create flag file
# to allow app to launch, delay for a few seconds
sleep 2.5
# start the droidcam client
droidcam-cli 0.0.0.0 4747 </dev/null &>/dev/null &
if [ "$1" != "-q" ] # if not run quietly open mpv
then
cmdsp &
fi