Add example event-watcher script
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>pull/183/head
parent
d8239109e5
commit
3ee620b8b6
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
WAYVNCCTL=${WAYVNCCTL:-wayvncctl}
|
||||||
|
|
||||||
|
connection_count_now() {
|
||||||
|
echo "Total clients: $count"
|
||||||
|
}
|
||||||
|
|
||||||
|
while IFS= read -r EVT; do
|
||||||
|
case "$(jq -r '.method' <<<"$EVT")" in
|
||||||
|
client-*onnected)
|
||||||
|
count=$(jq -r '.params.connection_count' <<<"$EVT")
|
||||||
|
connection_count_now "$count"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done < <("$WAYVNCCTL" --json event-receive)
|
|
@ -47,7 +47,7 @@ struct ctl_client {
|
||||||
|
|
||||||
char read_buffer[512];
|
char read_buffer[512];
|
||||||
size_t read_len;
|
size_t read_len;
|
||||||
|
|
||||||
bool wait_for_events;
|
bool wait_for_events;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
|
@ -122,6 +122,25 @@ $ wayvncctl --json version
|
||||||
{"wayvnc":"v0.5.0","neatvnc":"v0.5.1","aml":"v0.2.2"}
|
{"wayvnc":"v0.5.0","neatvnc":"v0.5.1","aml":"v0.2.2"}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
A script that takes an action for each client connect and disconnect event:
|
||||||
|
|
||||||
|
```
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
connection_count_now() {
|
||||||
|
echo "Total clients: $count"
|
||||||
|
}
|
||||||
|
|
||||||
|
while IFS= read -r EVT; do
|
||||||
|
case "$(jq -r '.method' <<<"$EVT")" in
|
||||||
|
client-*onnected)
|
||||||
|
count=$(jq -r '.params.connection_count' <<<"$EVT")
|
||||||
|
connection_count_now "$count"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done < <(wayvncctl --json event-receive)
|
||||||
|
```
|
||||||
|
|
||||||
# ENVIRONMENT
|
# ENVIRONMENT
|
||||||
|
|
||||||
The following environment variables have an effect on wayvncctl:
|
The following environment variables have an effect on wayvncctl:
|
||||||
|
|
Loading…
Reference in New Issue