-
Notifications
You must be signed in to change notification settings - Fork 9
/
manage-inbox-functions
146 lines (124 loc) · 4.6 KB
/
manage-inbox-functions
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
MYPATH=$HOME/patmenu2
MAIN=$MYPATH/./manage-inbox
LOGO=$MYPATH/pmlogo.png
VERSION=$(cat $MYPATH/changelog | grep release | head -1 | sed 's/release=//')
source $MYPATH/config
IN=$HOME/.local/share/pat/mailbox/$MYCALLSIGN/in
ARCHIVE=$HOME/.local/share/pat/mailbox/$MYCALLSIGN/archive
SENT=$HOME/.local/share/pat/mailbox/$MYCALLSIGN/sent
ARCHIVE-ALL(){
mv $IN/* $ARCHIVE/
yad --form --width=420 --height=100 --text-align=center --center --title="Pat Menu" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu</b> by KM4ACK\rv$VERSION\rEmails Archived" \
--button=gtk-ok
$MAIN &
}
DELETE-ARCHIVE (){
yad --form --width=420 --text-align=center --center --title="Pat Menu" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu</b> by KM4ACK\rv$VERSION\r<b>ARE YOU SURE YOU WANT TO DELETE\rALL ITEMS FROM YOUR ARCHIVE FOLDER?\rTHIS CAN'T BE UNDONE</b>" \
--button="Yes I'm Sure":2 \
--button="No":1
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit 0
elif [ $BUT = 252 ]; then
exit
elif [ $BUT = 2 ]; then
rm $ARCHIVE/*
yad --form --width=420 --height=100 --text-align=center --center --title="Pat Menu" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu</b> by KM4ACK\rv$VERSION\rArchives Deleted" \
--button=gtk-ok
$MAIN &
fi
}
DELETE-SENT(){
yad --form --width=420 --text-align=center --center --title="Pat Menu" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu</b> by KM4ACK\rv$VERSION\r<b>ARE YOU SURE YOU WANT TO DELETE\rALL ITEMS FROM YOUR SENT FOLDER?\rTHIS CAN'T BE UNDONE</b>" \
--button="Yes I'm Sure":2 \
--button="No":1
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit 0
elif [ $BUT = 252 ]; then
exit
elif [ $BUT = 2 ]; then
rm $SENT/*
yad --form --width=420 --height=100 --text-align=center --center --title="Pat Menu" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu</b> by KM4ACK\rv$VERSION\rSent Emails Deleted" \
--button=gtk-ok
$MAIN &
fi
}
EMAILBKUP(){
CONFIG=$XDG_CONFIG_HOME/pat/config.json
WHO=$(whoami)
CALL=$(cat $XDG_CONFIG_HOME/pat/config.json | grep -m 1 mycall | sed 's/\"mycall\": \"//' | sed 's/\",//' | sed -e 's/^\s*//' | tr '[:lower:]' '[:upper:]')
BKUPTIME=$(date +%Y%d%m-%H%M)
BACKUP=$(yad --form --width=420 --text-align=center --center --title="Email Backup" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Email Backup</b> by KM4ACK" \
--field="Backup Directory":DIR \
--button="Backup Emails":2 \
--button="Cancel":1)
BUT=$?
if [ $BUT = 252 ]; then
exit
elif [ $BUT = 1 ]; then
$MAIN
exit
fi
DIR=$(echo $BACKUP | awk -F "|" '{print $1}')
cp -r $HOME/.local/share/pat/mailbox/$CALL $DIR/email.bkup.$BKUPTIME
if [ -d $DIR/email.bkup.$BKUPTIME ]; then
yad --center --text="Backup Complete" \
--button=gtk-ok
$MAIN &
exit
fi
}
EMAILRESTORE(){
MYPATH=$HOME/dev/patmenu2
CONFIG=$XDG_CONFIG_HOME/pat/config.json
WHO=$(whoami)
CALL=$(cat $XDG_CONFIG_HOME/pat/config.json | grep -m 1 mycall | sed 's/\"mycall\": \"//' | sed 's/\",//' | sed -e 's/^\s*//' | tr '[:lower:]' '[:upper:]')
RESTORE=$(yad --form --width=420 --text-align=center --center --title="Email Restore" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Email Restore</b> by KM4ACK" \
--field="Restore Directory":DIR \
--button="Restore Emails":2 \
--button="Cancel":1)
BUT=$?
if [ $BUT = 252 ]; then
exit
elif [ $BUT = 1 ]; then
$MAIN &
exit
fi
DIR=$(echo $RESTORE | awk -F "|" '{print $1}')
DIRCHECK=$(ls $DIR)
COUNT=${#DIRCHECK}
if [ "$COUNT" = 19 ]; then
cp $DIR/archive/* $HOME/.local/share/pat/mailbox/$CALL/archive/
cp $DIR/in/* $HOME/.local/share/pat/mailbox/$CALL/in/
cp $DIR/out/* $HOME/.local/share/pat/mailbox/$CALL/out/
cp $DIR/sent/* $HOME/.local/share/pat/mailbox/$CALL/sent/
yad --form --width=420 --text-align=center --center --title="Email Restore" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Email Restore</b> by KM4ACK\r\r<b>RESTORE COMPLETE</b>" \
--button=gtk-ok
else
yad --form --width=420 --text-align=center --center --title="Email Restore" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Email Restore</b> by KM4ACK\r\r<b>Not a valid restore directory</b>" \
--button=gtk-ok
fi
$MAIN &
exit
}