2022-09-08 22:38:09 +05:00
|
|
|
#!/bin/bash
|
2022-09-13 19:43:39 +05:00
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
|
2024-03-06 15:43:54 +05:00
|
|
|
|
|
|
|
WALLDIR=$(pwd)/prayer-bg
|
|
|
|
INPUT=$WALLDIR/$(ls -l $WALLDIR | tail -n +2 | sort -R | head -1 | awk '{print $9}')
|
|
|
|
# INPUT=prayer.png
|
|
|
|
|
2022-09-08 22:38:09 +05:00
|
|
|
OUTPUT=prayer_added.png
|
2022-09-09 12:23:16 +05:00
|
|
|
PRAYERTIMES_CSV="male.csv"
|
2023-02-08 11:05:27 +05:00
|
|
|
#DAY_OF_YEAR=$(($(date -d "@$(date +%s)" +%j) - 1)) # no clue why this wasnt whats below from the begning
|
|
|
|
#DAY_OF_YEAR=$(date +%j) # this adds a zero at the begining and causes issues
|
|
|
|
DAY_OF_YEAR=$((10#$(date +%j))) # remove the zero https://stackoverflow.com/a/11130324
|
2022-09-09 13:49:17 +05:00
|
|
|
source .env
|
2022-09-09 11:28:03 +05:00
|
|
|
|
2022-09-09 12:23:16 +05:00
|
|
|
rm $OUTPUT > /dev/null
|
2022-09-09 11:28:03 +05:00
|
|
|
|
2022-09-09 12:23:16 +05:00
|
|
|
human() {
|
|
|
|
HOUR="$(( $1 / 60 ))"
|
|
|
|
if (( $(( $1 / 60 )) < 10 )) ; then
|
|
|
|
HOUR="0$(( $1 / 60 ))"
|
|
|
|
fi
|
|
|
|
MINUTE="$(( $1 % 60 ))"
|
|
|
|
if (( $(( $1 % 60 )) < 10 )) ; then
|
|
|
|
MINUTE="0$(( $1 % 60 ))"
|
|
|
|
fi
|
|
|
|
echo "$HOUR:$MINUTE"
|
2022-09-09 11:28:03 +05:00
|
|
|
}
|
|
|
|
|
2022-09-08 22:38:09 +05:00
|
|
|
imagemagick(){
|
|
|
|
TIME=$1
|
|
|
|
PRAYER=$2
|
|
|
|
|
|
|
|
case $PRAYER in
|
|
|
|
fathis)
|
2022-09-09 03:45:04 +05:00
|
|
|
POSITION='+685+430'
|
2022-09-13 19:28:19 +05:00
|
|
|
COLOR=white
|
2022-09-08 22:38:09 +05:00
|
|
|
;;
|
|
|
|
iruaraa)
|
2022-09-13 19:28:19 +05:00
|
|
|
POSITION='+450+430'
|
|
|
|
COLOR=white
|
2022-09-08 22:38:09 +05:00
|
|
|
;;
|
|
|
|
mendhuru)
|
2022-09-13 19:28:19 +05:00
|
|
|
POSITION='+215+430'
|
|
|
|
COLOR=white
|
2022-09-08 22:38:09 +05:00
|
|
|
;;
|
|
|
|
asr)
|
2022-09-09 03:45:04 +05:00
|
|
|
POSITION='+685+768'
|
2022-09-13 19:28:19 +05:00
|
|
|
COLOR=white
|
2022-09-08 22:38:09 +05:00
|
|
|
;;
|
|
|
|
magrib)
|
2022-09-13 19:28:19 +05:00
|
|
|
POSITION='+450+768'
|
|
|
|
COLOR=white
|
2022-09-08 22:38:09 +05:00
|
|
|
;;
|
|
|
|
isha)
|
2022-09-13 19:28:19 +05:00
|
|
|
POSITION='+215+768'
|
|
|
|
COLOR=white
|
2022-09-13 18:58:40 +05:00
|
|
|
;;
|
|
|
|
date)
|
2022-09-13 19:28:19 +05:00
|
|
|
POSITION='+375+190'
|
|
|
|
TIME=$(date +'%d-%m-%Y')
|
|
|
|
COLOR='#AC5757'
|
2022-09-08 22:38:09 +05:00
|
|
|
esac
|
|
|
|
|
|
|
|
if [ -f $OUTPUT ]
|
|
|
|
then
|
|
|
|
INPUT=$OUTPUT
|
|
|
|
fi
|
2022-09-13 19:28:19 +05:00
|
|
|
echo Prayer=$PRAYER DayOfYear=$DAY_OF_YEAR Time=$TIME File=$INPUT Colour=$COLOR
|
2022-09-08 22:38:09 +05:00
|
|
|
|
|
|
|
convert $INPUT \
|
2022-09-09 03:45:04 +05:00
|
|
|
-font $PWD/CourierPrime.ttf \
|
|
|
|
-pointsize 48 \
|
2022-09-13 19:28:19 +05:00
|
|
|
-fill $COLOR \
|
2022-09-08 22:38:09 +05:00
|
|
|
-annotate $POSITION $TIME \
|
|
|
|
$OUTPUT
|
|
|
|
}
|
|
|
|
|
2022-09-09 12:23:16 +05:00
|
|
|
Fajr=$(grep "^$DAY_OF_YEAR," $PRAYERTIMES_CSV | cut -d, -f2)
|
|
|
|
Sunrise=$(grep "^$DAY_OF_YEAR," $PRAYERTIMES_CSV | cut -d, -f3)
|
|
|
|
Dhuhr=$(grep "^$DAY_OF_YEAR," $PRAYERTIMES_CSV | cut -d, -f4)
|
|
|
|
Asr=$(grep "^$DAY_OF_YEAR," $PRAYERTIMES_CSV | cut -d, -f5)
|
|
|
|
Maghrib=$(grep "^$DAY_OF_YEAR," $PRAYERTIMES_CSV | cut -d, -f6)
|
|
|
|
Isha=$(grep "^$DAY_OF_YEAR," $PRAYERTIMES_CSV | cut -d, -f7)
|
|
|
|
|
2022-09-13 18:58:40 +05:00
|
|
|
|
2022-09-09 12:23:16 +05:00
|
|
|
imagemagick $(human $Fajr) fathis
|
|
|
|
imagemagick $(human $Sunrise) iruaraa
|
|
|
|
imagemagick $(human $Dhuhr) mendhuru
|
|
|
|
imagemagick $(human $Asr) asr
|
|
|
|
imagemagick $(human $Maghrib) magrib
|
|
|
|
imagemagick $(human $Isha) isha
|
2022-09-13 18:58:40 +05:00
|
|
|
imagemagick "" date
|
2022-09-09 03:45:04 +05:00
|
|
|
|
2022-09-09 13:47:53 +05:00
|
|
|
curl -s -F photo=@$OUTPUT $TG_BOTAPI$TG_BOT_TOKEN/sendphoto?chat_id=$TG_CHATID
|