-
Notifications
You must be signed in to change notification settings - Fork 1
/
RandBlague.sh
executable file
·54 lines (44 loc) · 1.54 KB
/
RandBlague.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
#!/usr/bin/env bash
# Author: Lilian BESSON
# Email: Lilian.BESSON[AT]ens-cachan[DOT]fr
# Web version: http://perso.crans.org/besson/bin/RandBlague.sh
# Web version (2): https://bitbucket.org/lbesson/bin/src/master/RandBlague.sh
# Date: 03-02-2021
#
# A small script to do send one random joke (in English), by email, every single day !
# Requires: .blagues.txt (https://perso.crans.org/besson/bin/.blagues.txt)
sleeptime="${1:-0s}"
echo -e "Printing a random joke, after a short sleep ($sleeptime)...."
echo -e "Date:`date`. User:`whoami`. Calling $0 with time $sleeptime..." >> /tmp/randBlague.log
sleep "$sleeptime"
Blagues="$HOME/.blagues.txt"
randBlague ()
{
if [ -f "$Blagues" ]; then
echo -e "$Blagues is there" >> /tmp/randBlague.log;
shuf "$Blagues" | head -n 1;
else
if [ -f "$HOME/motd" ]; then
echo -e "$HOME/motd is there" >> /tmp/randBlague.log;
cat "$HOME/motd";
else
echo -e "No citation, $HOME/motd is not there, and $Blagues is not there either." >> /tmp/randBlague.log;
echo -e "No citation, $HOME/motd is not there, and $Blagues is not there either.";
fi;
fi
}
if [ -f "$HOME/.link.ico" ]; then
icon="$HOME/.link.ico";
else
icon="info";
fi
Blague=$(randBlague)
content="<big><b>$Blague</b></big>"
echo -e "Notifying with title='Rand Blague'...."
echo -e "Notifying with content='$content'...."
zenity --title="Rand Blague" --timeout=30 \
--width=250 --height=200 \
--window-icon="$icon" --info \
--display=:0.0 --text="$content"
exit 0
# END