summaryrefslogtreecommitdiff
path: root/parakoimomenos
diff options
context:
space:
mode:
Diffstat (limited to 'parakoimomenos')
-rwxr-xr-xparakoimomenos33
1 files changed, 33 insertions, 0 deletions
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
+