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 --- README | 7 +++++++ parakoimomenos | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 parakoimomenos 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 + -- cgit v1.1