summaryrefslogtreecommitdiff
path: root/parakoimomenos
blob: b81f1e455de57e48b29b199e512dd7492545fc61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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