From 24fcc4dba8613cb2394e4bf7add571fc4ea242a0 Mon Sep 17 00:00:00 2001 From: boyska Date: Fri, 4 Mar 2022 02:35:29 +0100 Subject: [PATCH] example files/scripts for apply-state --- ring_mon/example-state.json | 3 +++ ring_mon/get-status | 3 +++ ring_mon/set-light | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 ring_mon/example-state.json create mode 100755 ring_mon/get-status create mode 100755 ring_mon/set-light diff --git a/ring_mon/example-state.json b/ring_mon/example-state.json new file mode 100644 index 0000000..f58889c --- /dev/null +++ b/ring_mon/example-state.json @@ -0,0 +1,3 @@ +{ +"devices": {"1": "up", "2": "onair"} +} diff --git a/ring_mon/get-status b/ring_mon/get-status new file mode 100755 index 0000000..acca7ba --- /dev/null +++ b/ring_mon/get-status @@ -0,0 +1,3 @@ +#!/bin/sh +set -eu +jq -rM < example-state.json ".devices[\"$1\"]" diff --git a/ring_mon/set-light b/ring_mon/set-light new file mode 100755 index 0000000..943f51d --- /dev/null +++ b/ring_mon/set-light @@ -0,0 +1,18 @@ +#!/bin/sh + +set -eu + +if [ "$DEVICE_NUMBER" = 0 ]; then + [ "$1" = on ] && exec numlockx on + [ "$1" = off ] && exec numlockx off +elif [ "$DEVICE_NUMBER" = 1 ]; then + [ "$1" = on ] && exec xset led named "Scroll Lock" + [ "$1" = off ] && exec xset -led named "Scroll Lock" +else + echo "Device number not supported" >&2 + exit 2 +fi + +echo "Invalid usage" >&2 +exit 2 +