-
Notifications
You must be signed in to change notification settings - Fork 9
/
manage-form-functions
57 lines (54 loc) · 1.45 KB
/
manage-form-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
MYPATH=$HOME/patmenu2
MAIN=$MYPATH/./manage-forms
LOGO=$MYPATH/pmlogo.png
DOWNLOAD(){
#yad --center --timeout=3 --timeout-indicator=top --no-buttons --text="Downloading Forms - Please wait" \
#--image $LOGO --window-icon=$LOGO --image-on-top &
lxterminal -e /usr/bin/pat updateforms
yad --center --timeout=3 --timeout-indicator=top --no-buttons --text="Forms Download Complete" \
--image $LOGO --window-icon=$LOGO --image-on-top
exit &
$MAIN
}
AUTO-DOWNLOAD(){
CHOICE="Weekly,At-Boot"
FREQ=$(yad --center --wrap --width=350 --title="Auto Download" --text-align=center \
--text="Download Weekly or at boot?" \
--image $LOGO --window-icon=$LOGO --image-on-top \
--button="Update:2" \
--button="Cancel:1" \
--form --separator="," --item-separator="," \
--field="Choose":CB $CHOICE \
)
BUT=$?
FREQ=$(echo $FREQ | awk -F "|" '{print $1}' | sed 's/,//')
if [ $FREQ = 'At-Boot' ]; then
FREQ=@reboot
fi
echo "FREQ = $FREQ"
if [ $BUT = 1 ]; then
exit &
$MAIN
elif [ $BUT = 252 ]; then
exit
elif [ $BUT = 2 ]; then
echo "updating cron"
FILE=/run/user/$UID/cron.txt
crontab -l > $FILE
sed -i '/updateforms$/d' $FILE
if [ $FREQ = '@reboot' ]; then
TEXT="@reboot sleep 10 && /usr/bin/pat updateforms"
FREQ="At-Boot"
else
TEXT="0 4 * * 6 /usr/bin/pat updateforms"
FREQ="Weekly"
fi
echo "$TEXT" >> $FILE
crontab $FILE
rm $FILE
exit &
yad --center --timeout=3 --timeout-indicator=top --no-buttons --text="Auto download set to $FREQ" \
--image $LOGO --window-icon=$LOGO --image-on-top
$MAIN
fi
}