-
Notifications
You must be signed in to change notification settings - Fork 14
/
dailyschedule.sh
executable file
·58 lines (47 loc) · 2.17 KB
/
dailyschedule.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Daily schedule printer! v0.9.1
# [email protected] / https://freelance.halfacree.co.uk
# Depends: Various defaults plus task, figlet, fortune, cowsay,
# gcalcli with oauth configured, and a 'net connection.
# Now with word of the day; requires "wordoftheday.sh" from the
# same place you got this.
# NO LONGER PRINTS BY DEFAULT; OUTPUTS TO STDOUT INSTEAD!
# To actually print, use the --print flag.
# Current formatting optimised for a Dymo 450 using S0929100 name cards.
# Set CUPS to 40cpi/18lpi and a page size of 4.6x7.1cm.
# Tasty variables
LOCATION="bradford" # Insert your location here
CALENDARS="--calendar=Home --calendar=Work --calendar=Deadlines" # Calendars to be used by GCalCLI
SCHEDULEFILE="/tmp/dailyschedule.txt" # Temporary file for the output
WEATHERFILE="/tmp/weather.txt" # Temporary file for the weather
COWFILE="/tmp/cowfile.txt" # Temporary file for the cowsay output
PRINTERNAME="LabelWriter-450" # Name of lp-compatible printer
# The header
date +"%a %F" | figlet -f small.flf > "$SCHEDULEFILE"
# Let's start with the weather and cow...
curl -s wttr.in/$LOCATION?0QT | cut -c 1-37 > "$WEATHERFILE"
/usr/games/fortune -a -s | /usr/games/cowsay -W 30 > "$COWFILE"
if grep --quiet "Sorry\|html" "$WEATHERFILE"; then
printf "\nWeather service down. :(" > "$WEATHERFILE"
fi
paste "$COWFILE" "$WEATHERFILE" | column -s $'\t' -t >> "$SCHEDULEFILE"
printf "\n" >> "$SCHEDULEFILE"
# Now tasks...
echo -n "TASKS" >> "$SCHEDULEFILE"
task ls >> "$SCHEDULEFILE" || printf "\nNo tasks due!\n" >> "$SCHEDULEFILE"
printf "\n" >> "$SCHEDULEFILE"
# Calendar... - BROKEN IN LATEST GCALCLI OWING TO DEPRECATION OF WIDTHS LESS THAN 10 (the buggers)
#echo "THIS WEEK'S SCHEDULE" >> "$SCHEDULEFILE"
#gcalcli --nocolor --lineart ascii --calendar="Holidays in United Kingdom" $CALENDARS calw >> "$SCHEDULEFILE"
# Word of the Day
echo "WORD OF THE DAY" >> "$SCHEDULEFILE"
$(dirname "$0")/wordoftheday.sh >> "$SCHEDULEFILE"
# Now wrap and print...
if [ "$1" == "--print" ]; then
fold -w 72 -s "$SCHEDULEFILE" | lp -d $PRINTERNAME
else
fold -w 72 -s "$SCHEDULEFILE" | cat "$SCHEDULEFILE"
fi
# Housekeeping
rm "$SCHEDULEFILE" "$WEATHERFILE" "$COWFILE"
exit 0