forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprayer-times-diyanet.sh
executable file
·63 lines (52 loc) · 2.2 KB
/
prayer-times-diyanet.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# You may need to install coreutils via homebrew to make this script work (gdate function).
#
# Homebrew: https://brew.sh/
# Coreutils: https://formulae.brew.sh/formula/coreutils
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Prayer Times (Diyanet)
# @raycast.mode inline
# @raycast.packageName Culture
# Optional parameters:
# @raycast.icon 🕌
# Documentation
# @raycast.author Emircan Erkul
# @raycast.authorURL https://emircanerkul.com
# @raycast.description Prayer Times grabbed from the Diyanet's Official Website for people located in Türkiye.
data=$(curl -s https://namazvakitleri.diyanet.gov.tr/tr-TR/9654/kocaeli-icin-namaz-vakti)
imsak=$(echo "$data" | pcregrep -o1 '_imsakTime = "(.*)"')
gunes=$(echo "$data" | pcregrep -o1 '_gunesTime = "(.*)"')
ogle=$(echo "$data" | pcregrep -o1 '_ogleTime = "(.*)"')
ikindi=$(echo "$data" | pcregrep -o1 '_ikindiTime = "(.*)"')
aksam=$(echo "$data" | pcregrep -o1 '_aksamTime = "(.*)"')
yatsi=$(echo "$data" | pcregrep -o1 '_yatsiTime = "(.*)"')
NOW=$(gdate +%s)
if [ $(($(gdate -d "$imsak" +%s) - $NOW)) -gt 0 ]; then
REMANINING=$(($(gdate -d "$imsak" +%s) - $NOW))
elif [ $(($(gdate -d "$gunes" +%s) - $NOW)) -gt 0 ]; then
REMANINING=$(($(gdate -d "$gunes" +%s) - $NOW))
elif [ $(($(gdate -d "$ogle" +%s) - $NOW)) -gt 0 ]; then
REMANINING=$(($(gdate -d "$ogle" +%s) - $NOW))
elif [ $(($(gdate -d "$ikindi" +%s) - $NOW)) -gt 0 ]; then
REMANINING=$(($(gdate -d "$ikindi" +%s) - $NOW))
elif [ $(($(gdate -d "$aksam" +%s) - $NOW)) -gt 0 ]; then
REMANINING=$(($(gdate -d "$aksam" +%s) - $NOW))
else
REMANINING=$(($(gdate -d "$yatsi" +%s) - $NOW))
fi
if [ $REMANINING -gt 0 ]; then
if [ $(($REMANINING / 3600)) -gt 0 ]; then
REMANINING="$(($REMANINING / 3600))h $(($REMANINING / 60 % 60))m $(($REMANINING % 60))s"
elif [ $(($REMANINING / 60 % 60)) -gt 0 ]; then
REMANINING="$(($REMANINING / 60 % 60))m $(($REMANINING % 60))s"
else
REMANINING="$(($REMANINING % 60))s"
fi
REMANINING="☾ $REMANINING ☽"
else
REMANINING=""
fi
output="$REMANINING $imsak ⚙︎ $gunes ⚙︎ $ogle ⚙︎ $ikindi ⚙︎ $aksam ⚙︎ $yatsi"
echo $output | tr -d '\n' | LANG=tr_TR.UTF-8 pbcopy
echo $output