From aa0ede80962912f85a66f0588469a13451b4c00e Mon Sep 17 00:00:00 2001 From: "Haoran S. Diao" <0@hairydiode.xyz> Date: Sun, 14 Apr 2019 04:17:08 -0400 Subject: added parakoimomenos --- parakoimomenos | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 parakoimomenos (limited to 'parakoimomenos') diff --git a/parakoimomenos b/parakoimomenos new file mode 100755 index 0000000..b81f1e4 --- /dev/null +++ b/parakoimomenos @@ -0,0 +1,33 @@ +#!/bin/bash +#check for missing required arguments and prints help if the arguments are wrong +#in addition searches for --help argument +if [ "$1" == "" ] || [ $1 == "--help" ]; then + echo "parakoimomenos: use guardian to send out a random alert based on\ + the configuration in ~/.guardian/tasks" + echo "Usage: parakoimomenos [device] [color]" + exit +fi + +#getting array of tasks, each taking up their own line in the user specified +#config file at ~/.guardian/tasks +# -t removes the delimiter +readarray -t tasks < ~/.guardian/tasks +#gets a list of alert templates installed on the location +#the color flag allows for toggling between color and noncolor templates +if [ "$2" == "color" ]; then + readarray templates <<< $(ls /etc/guardian/templates | grep color) + #take account of the fact that the device is now $2 +else + readarray templates <<< $(ls /etc/guardian/templates | grep -v color) +fi +#select random values within the indices of tasks and templates +j=$(( $RANDOM / $(( 32767 / ${#templates[@]} )) )) +i=$(( $RANDOM / $(( 32767 / ${#tasks[@]} )) )) +#runs guardian +guardian ${templates[$j]} "${tasks[$i]}" $1 +#sleep for 10 seconds +sleep 10 +#raises the buddy-arm +guardian raise $1 +#run guardian with the randomly selected task and template + -- cgit v1.1