-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·47 lines (39 loc) · 1.5 KB
/
run.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
# -----------------------------------------------------------------------------
# Project name :
# File name : run.sh
# Created date : Wed 06 Sep 2017 02:45:11 PM ICT
# Author : Huy-Hung Ho
# Last modified : Fri 08 Sep 2017 09:20:02 PM ICT
# Guide :
# -----------------------------------------------------------------------------
#!/bin/bash
# Requirement
#for i in `atq | awk '{print $1}'`;do atrm $i;done
export DISPLAY=:0
# Variable
BASEDIR=$(dirname $(readlink -m "$0"))
PATH="$BASEDIR/execute:$PATH"
INSTALL="sudo apt-get install"
# Install app
command -v notify-send >/dev/null 2>&1 || $INSTALL notify-send
command -v at >/dev/null 2>&1 || $INSTALL at
command -v crontab >/dev/null 2>&1 || $INSTALL crontab
command -v youtube-dl >/dev/null 2>&1 || $INSTALL youtube-dl
# Permission
chmod u+x $BASEDIR/job/*.sh $BASEDIR/*.sh $BASEDIR/execute/*
# Resting my eyes
if [[ $(crontab -l | grep -c warningTime) -eq 0 ]]
then
(crontab -l ; echo "50 * * * * $BASEDIR/job/warningTime.sh") | crontab -
(crontab -l ; echo "51 * * * * $BASEDIR/job/lock.sh") | crontab -
(crontab -l ; echo "*/2 * * * * $BASEDIR/job/learnVoc.sh") | crontab -
fi
# Greeting
if [[ $(grep -c warningTime ~/.profile) -eq 0 ]]
then
echo "at -f "$BASEDIR/job/greeting.sh" now + 1 minute 2> /dev/null" >> ~/.profile
echo "at -f "$BASEDIR/execute/weather" now + 2 minute 2> /dev/null" >> ~/.profile
echo "PATH=\"$BASEDIR/execute:\$PATH\"" >> ~/.profile
fi
# Note
echo "You must restart your computer to apply these changes"