-
Notifications
You must be signed in to change notification settings - Fork 0
/
regy
executable file
·88 lines (76 loc) · 2.12 KB
/
regy
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/bash
#remove the following line replace config
#to use without athanasius
. $AWMdir/themes/current.conf # for use with athanasius
Datediff(){
first_date=$(date "+%s")
second_date=$(date -d "$(tail -1 $HOME/.local/regy/datelist)" "+%s")
datediff=$(( $second_date - $first_date ))
if [[ $datediff -lt 2678400 ]] ; then #equivalent to 31 days
Gendates
fi
}
Gendates(){
rm "$HOME/.local/regy/datelist" && touch "$HOME/.local/regy/datelist"
today=$(date "+%D")
numofdays="1"
while [[ $numofdays -lt 121 ]]; do
newdate=$(date -d "$today + $numofdays day" "+%b %d %Y")
echo $newdate
numofdays=$(($numofdays + 1))
done > "$HOME/.local/regy/datelist"
}
Info(){
cal -n 2 | sed "s/ $day /|$day|/"
cat "$HOME/.local/regy/todo"
}
DeleteEvent(){
eventdelstring=$(cat "$HOME/.local/regy/todo" | rofi -dmenu -p "Delete Event:" -i -theme $roficonf)
sed -i "/${eventdelstring:1:12}/d" "$HOME/.local/regy/todo"
}
Addevent(){
eventdate=$(cat "$HOME/.local/regy/datelist" | rofi -dmenu -p "" -i -theme $roficonf)
if [[ -z $eventdate ]] ; then
echo "none selected"
exit 1
elif [[ $eventdate = "delete" ]] ; then
DeleteEvent
return 0
fi
eventtime=$(rofi -dmenu -p "Event Time:" -theme $roficonf)
eventdesc=$(rofi -dmenu -p "Event Description:" -theme $roficonf)
echo -e "[$eventdate,$eventtime] $eventdesc" >> "$HOME/.local/regy/todo"
}
Sort(){
touch /tmp/sortregy
IFS=','
while read -r line ; do
sortsec=$(date -d "${line:1:11}" "+%s")
echo $sortsec${line:13}
done > /tmp/sortregy
sort -k1 /tmp/sortregy | while read -r line ; do
sortdate=$(date -d "@${line:0:10}" "+%b %d %Y")
echo "[$sortdate,${line:10}"
done > "$HOME/.local/regy/todo"
}
Clean(){
old=$(date -d "7 days ago" "+%s")
linenum="1"
deletelines=""
while read -r line
do
seconds=$(date -d "${line:1:11}" "+%s")
if [[ $seconds -lt $old ]] ; then
deletelines+="$linenum "
fi
linenum=$(( $linenum + 1 ))
done < "$HOME/.local/regy/todo"
for deletion in $deletelines ; do
sed -i "${deletion}d" "$HOME/.local/regy/todo"
done
}
Datediff
day=$(date "+%d")
herbe "$(Info)" && Addevent
Clean
Sort < "$HOME/.local/regy/todo"