summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoran S. Diao <0@hairydiode.xyz>2019-04-14 04:17:08 -0400
committerHaoran S. Diao <0@hairydiode.xyz>2019-04-14 04:17:08 -0400
commitaa0ede80962912f85a66f0588469a13451b4c00e (patch)
tree3c03b845691afb4e553c7f5d528e7759b7f8aae2
parent7473a6bd11f36ae2b25355ee7d303a5323dcf5f9 (diff)
added parakoimomenos
-rw-r--r--README7
-rwxr-xr-xparakoimomenos33
2 files changed, 40 insertions, 0 deletions
diff --git a/README b/README
index 2ae7a60..d99afc3 100644
--- a/README
+++ b/README
@@ -9,6 +9,13 @@ Example Usage:
To raise the "buddy"'s arm again use:
guardian raise /dev/ttyUSB0
+parakoimomenos is a script that launches a random guardian alert based on a list
+of tasks in ~/.guardian/tasks.
+
+Example Usage, to set aside some time on self care every day
+$ fcrontab -e
+00 12 * * * parakoimomenos /dev/ttyUSB0 color
+
Acknoledgements:
The RS-232 library(https://www.teuniz.net/RS-232/) Teunis Van Beelen was used
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
+