From 057c322ba685752f683e585f89e34147b193e1bb Mon Sep 17 00:00:00 2001 From: hllvc Date: Fri, 11 Jun 2021 12:54:16 +0200 Subject: [PATCH 01/15] updated README.md and install method --- README.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 000044d..d0f0645 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,9 @@ ### How to install? Follow these instructions ``` -sudo wget -O /usr/local/bin/prayertimes \ - https://raw.githubusercontent.com/hllvc/Vaktija.ba-Gnome-Notification/main/prayertimes +/bin/bash -c "$(curl -fsSL \ + https://raw.githubusercontent.com/hllvc/Vaktija.ba-Gnome-Notification/main/prayertimes)" ``` -You could set your custom location but here is set to `/usr/bin/prayertimes`. - -After downloading script you should set it's permission like this - -``` -sudo chmod a+x /usr/local/bin/prayertimes -``` - -and then run it in terminal with `prayertimes`. - It should download automatically all necessary files and set it up for work. -To run it just type in terminal `prayertimes`. +And then run it in terminal with `prayertimes`. From d191649469d1915fe655ab319e18dc5f34aba506 Mon Sep 17 00:00:00 2001 From: hllvc Date: Fri, 24 Dec 2021 14:54:02 +0100 Subject: [PATCH 02/15] minor changes to support macos --- prayertimes | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/prayertimes b/prayertimes index e3b2c7d..d45d603 100755 --- a/prayertimes +++ b/prayertimes @@ -1,6 +1,6 @@ #!/bin/sh -dirpath="/home/$USER/.config/prayertimes" +dirpath="/Users/$USER/.config/prayertimes" tdatapath="$dirpath/data/town-data.json" rdatapath="$dirpath/data/reminders.json" scriptspath="$dirpath/scripts" @@ -12,59 +12,59 @@ icon="$dirpath/data/icon.svg" configuretimetext() { name="$2" - hours=$(date -d "$1" "+%_H") - minutes=$(date -d "$1" "+%_M") - seconds=$(date -d "$1" "+%_S") + hours=$(date -j -f "%H" "$1" "+%_H") + minutes=$(date -j -f "%M" "$1" "+%_M") + seconds=$(date -j -f "%S" "$1" "+%_S") if [[ $hours -eq 0 ]]; then hours="" elif [[ $hours -eq 1 ]] || [[ $hours -eq 21 ]]; then - hours="$(date -d "$time" "+%_H sat")" + hours="$(date -j -f "%H" "$time" "+%_H sat")" elif [[ $hours -eq 2 ]] || [[ $hours -eq 3 ]] || [[ $hours -eq 4 ]] || [[ $hours -eq 22 ]] || [[ $hours == 23 ]]; then - hours="$(date -d "$time" "+%_H sata")" + hours="$(date -j -f "%H" "$time" "+%_H sata")" elif [[ $hours < 10 ]]; then - hours="$(date -d "$time" "+%_H sati")" + hours="$(date -j -f "%H" "$time" "+%_H sati")" else - hours="$(date -d "$time" "+ %_H sati")" + hours="$(date -j -f "%H" "$time" "+ %_H sati")" fi if [[ $minutes -eq 0 ]]; then minutes="" elif [[ $minutes -eq 1 ]] || [[ $minutes -eq 21 ]]; then - minutes="$(date -d "$time" "+ %_M minutu")" + minutes="$(date -j -f "%M" "$time" "+ %_M minutu")" elif [[ $minutes -eq 2 ]] || [[ $minutes -eq 3 ]] || [[ $minutes -eq 4 ]] || [[ $minutes -eq 22 ]] || [[ $minutes == 23 ]]; then - minutes="$(date -d "$time" "+ %_M minute")" + minutes="$(date -j -f "%M" "$time" "+ %_M minute")" elif [[ $minutes < 10 ]]; then - minutes="$(date -d "$time" "+%_M minuta")" + minutes="$(date -j -f "%M" "$time" "+%_M minuta")" else - minutes="$(date -d "$time" "+ %_M minuta")" + minutes="$(date -j -f "%M" "$time" "+ %_M minuta")" fi if [[ $hours = "" ]] && [[ $minutes = "" ]]; then if [[ $seconds -eq 0 ]]; then notifbody="$name je sad!" break elif [[ $seconds -eq 1 ]]; then - seconds="$(date -d "$time" "+%_S sekundu")" + seconds="$(date -j -f "%S" "$time" "+%_S sekundu")" elif [[ $seconds -eq 2 ]] || [[ $seconds -eq 3 ]] || [[ $seconds -eq 4 ]]; then - seconds="$(date -d "$time" "+%_S sekunde")" + seconds="$(date -j -f "%S" "$time" "+%_S sekunde")" elif [[ $seconds < 10 ]]; then - seconds="$(date -d "$time" "+%_S sekundi")" + seconds="$(date -j -f "%S" "$time" "+%_S sekundi")" else modified=false for (( sec = 21; sec < 60; sec+=10 )); do if [[ $seconds -eq $sec ]]; then - seconds="$(date -d "$time" "+ %_S sekundu")" + seconds="$(date -j -f "%S" "$time" "+ %_S sekundu")" modified=true break fi done for (( sec1 = 22, sec2 = 23, sec3 = 24 ; sec1 < 60; sec1+=10, sec2+=10, sec3+=10 )); do if [[ $seconds -eq $sec1 ]] || [[ $seconds -eq $sec2 ]] || [[ $seconds -eq $sec3 ]]; then - seconds="$(date -d "$time" "+ %_S sekunde")" + seconds="$(date -j -f "%S" "$time" "+ %_S sekunde")" modified=true break fi done if [[ $modified = false ]]; then - seconds="$(date -d "$time" "+ %_S sekundi")" + seconds="$(date -j -f "%S" "$time" "+ %_S sekundi")" fi fi notifbody="$name za$seconds" @@ -83,9 +83,10 @@ sendnotif() { notifbody="" configuretimetext $time "$name" # notifbody=$(configuretimetext $time $name) - notify-send.sh "Vaktija.ba" "$notifbody" \ - -i $icon \ - -o "Open in Firefox:firefox --new-window www.vaktija.ba" \ + terminal-notifier -title "Vaktija.ba" -message "$notifbody" -open "https://vaktija.ba" + # notify-send.sh "Vaktija.ba" "$notifbody" \ + # -i $icon \ + # -o "Open in Firefox:firefox --new-window www.vaktija.ba" \ # -o "Snooze 5 min:notify-send.sh 'Delayed 5 minutes'" \ # -o "Snooze 10 min:notify-send.sh 'Delayed 10 minutes'" \ } @@ -104,7 +105,7 @@ if [[ ! -d $dirpath ]]; then wget -O $scriptspath/get-town-data.js $repourl/scripts/get-town-data.js wget -O $scriptspath/calculate-reminders.js $repourl/scripts/calculate-reminders.js wget -O $scriptspath/.env $repourl/scripts/.env - cd $scriptspath; npm install node-fetch dotenv --save; + cd $scriptspath; npm install node-fetch@^2.0.0 dotenv --save; node $scriptspath/pick-town.js node $scriptspath/get-town-data.js echo -e "\nDownloading icon ...\n" @@ -147,9 +148,9 @@ done # currentdate=$(date "+%H:%_M:%_S") # for time in ${times[@]}; do -# hours=$(( $(date -d "$time" "+%H") - $(date -d "$currentdate" "+%H") )) -# minutes=$(( $(date -d "$time" "+%_M") - $(date -d "$currentdate" "+%_M") )) -# seconds=$(( 60 - $(date -d "$currentdate" "+%_S") )) +# hours=$(( $(date -j -f "%H" "$time" "+%H") - $(date -d "$currentdate" "+%H") )) +# minutes=$(( $(date -j -f "%H" "$time" "+%_M") - $(date -d "$currentdate" "+%_M") )) +# seconds=$(( 60 - $(date -j -f "%H" "$currentdate" "+%_S") )) # if [[ $seconds -eq 60 ]]; then seconds=00; fi # if [[ $hours -lt 0 ]]; then # hours=$( expr 24 + $hours ) @@ -161,7 +162,7 @@ done # minutes=$(expr $minutes - 1) # if [[ $hours -eq 24 ]]; then hours=00; fi # if [[ ! $hours -lt 0 ]] && [[ ! $minutes -lt 0 ]]; then -# diff=$(date -d "$hours:$minutes:$seconds" "+%T") +# diff=$(date -j -f "%H" "$hours:$minutes:$seconds" "+%T") # echo "$time - $diff" # fi # done From ca1bea301a6848bf080094f9256639c6dd2c8756 Mon Sep 17 00:00:00 2001 From: hllvc Date: Fri, 24 Dec 2021 15:17:05 +0100 Subject: [PATCH 03/15] auto recognizing OS --- prayertimes | 94 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 8 deletions(-) diff --git a/prayertimes b/prayertimes index d45d603..f8a8b40 100755 --- a/prayertimes +++ b/prayertimes @@ -1,6 +1,14 @@ #!/bin/sh -dirpath="/Users/$USER/.config/prayertimes" +OS="$(uname)" + +if [[ $OS == Darwin ]]; then + home_folder="/Users" +elif [[ $OS == Linux ]]; then + home_folder="/home" +fi + +dirpath="$home_folder/$USER/.config/prayertimes" tdatapath="$dirpath/data/town-data.json" rdatapath="$dirpath/data/reminders.json" scriptspath="$dirpath/scripts" @@ -10,7 +18,74 @@ repourl="https://raw.githubusercontent.com/hllvc/Vaktija.ba-Gnome-Notification/m iconurl="https://raw.githubusercontent.com/vaktija/vaktija.ba/master/src/img/icon-light.svg" icon="$dirpath/data/icon.svg" -configuretimetext() { +configuretimetext_Linux () { + name="$2" + hours=$(date -d "$1" "+%_H") + minutes=$(date -d "$1" "+%_M") + seconds=$(date -d "$1" "+%_S") + if [[ $hours -eq 0 ]]; then + hours="" + elif [[ $hours -eq 1 ]] || [[ $hours -eq 21 ]]; then + hours="$(date -d "$time" "+%_H sat")" + elif [[ $hours -eq 2 ]] || [[ $hours -eq 3 ]] || [[ $hours -eq 4 ]] || [[ $hours -eq 22 ]] || [[ $hours == 23 ]]; then + hours="$(date -d "$time" "+%_H sata")" + elif [[ $hours < 10 ]]; then + hours="$(date -d "$time" "+%_H sati")" + else + hours="$(date -d "$time" "+ %_H sati")" + fi + if [[ $minutes -eq 0 ]]; then + minutes="" + elif [[ $minutes -eq 1 ]] || [[ $minutes -eq 21 ]]; then + minutes="$(date -d "$time" "+ %_M minutu")" + elif [[ $minutes -eq 2 ]] || [[ $minutes -eq 3 ]] || [[ $minutes -eq 4 ]] || [[ $minutes -eq 22 ]] || [[ $minutes == 23 ]]; then + minutes="$(date -d "$time" "+ %_M minute")" + elif [[ $minutes < 10 ]]; then + minutes="$(date -d "$time" "+%_M minuta")" + else + minutes="$(date -d "$time" "+ %_M minuta")" + fi + if [[ $hours = "" ]] && [[ $minutes = "" ]]; then + if [[ $seconds -eq 0 ]]; then + notifbody="$name je sad!" + break + elif [[ $seconds -eq 1 ]]; then + seconds="$(date -d "$time" "+%_S sekundu")" + elif [[ $seconds -eq 2 ]] || [[ $seconds -eq 3 ]] || [[ $seconds -eq 4 ]]; then + seconds="$(date -d "$time" "+%_S sekunde")" + elif [[ $seconds < 10 ]]; then + seconds="$(date -d "$time" "+%_S sekundi")" + else + modified=false + for (( sec = 21; sec < 60; sec+=10 )); do + if [[ $seconds -eq $sec ]]; then + seconds="$(date -d "$time" "+ %_S sekundu")" + modified=true + break + fi + done + for (( sec1 = 22, sec2 = 23, sec3 = 24 ; sec1 < 60; sec1+=10, sec2+=10, sec3+=10 )); do + if [[ $seconds -eq $sec1 ]] || [[ $seconds -eq $sec2 ]] || [[ $seconds -eq $sec3 ]]; then + seconds="$(date -d "$time" "+ %_S sekunde")" + modified=true + break + fi + done + if [[ $modified = false ]]; then + seconds="$(date -d "$time" "+ %_S sekundi")" + fi + fi + notifbody="$name za$seconds" + elif [[ $hours = "" ]]; then + notifbody="$name za$minutes" + elif [[ $minutes = "" ]]; then + notifbody="$name za$hours" + else + notifbody="$name za$hours i$minutes" + fi +} + +configuretimetext_Darwin () { name="$2" hours=$(date -j -f "%H" "$1" "+%_H") minutes=$(date -j -f "%M" "$1" "+%_M") @@ -77,18 +152,21 @@ configuretimetext() { fi } -sendnotif() { +sendnotif () { name="$1" time=$2 notifbody="" - configuretimetext $time "$name" + configuretimetext_$OS $time "$name" # notifbody=$(configuretimetext $time $name) - terminal-notifier -title "Vaktija.ba" -message "$notifbody" -open "https://vaktija.ba" - # notify-send.sh "Vaktija.ba" "$notifbody" \ - # -i $icon \ - # -o "Open in Firefox:firefox --new-window www.vaktija.ba" \ + if [[ $OS == Darwin ]]; then + terminal-notifier -title "Vaktija.ba" -message "$notifbody" -open "https://vaktija.ba" + elif [[ $OS == Linux ]]; then + notify-send.sh "Vaktija.ba" "$notifbody" \ + -i $icon \ + -o "Open in Firefox:firefox --new-window www.vaktija.ba" \ # -o "Snooze 5 min:notify-send.sh 'Delayed 5 minutes'" \ # -o "Snooze 10 min:notify-send.sh 'Delayed 10 minutes'" \ + fi } if [[ ! -d $dirpath ]]; then From ea28d53202868a6bb80cb5f65d0a7eb3f1b6ec11 Mon Sep 17 00:00:00 2001 From: hllvc Date: Fri, 24 Dec 2021 18:40:50 +0100 Subject: [PATCH 04/15] complete rewrite * removed all node.js scripts * new bash script from ground up (prayertimes.sh) --- prayertimes | 246 --------------------------------- prayertimes.sh | 46 ++++++ scripts/.env | 1 - scripts/calculate-reminders.js | 32 ----- scripts/get-town-data.js | 45 ------ scripts/pick-town.js | 51 ------- 6 files changed, 46 insertions(+), 375 deletions(-) delete mode 100755 prayertimes create mode 100644 prayertimes.sh delete mode 100644 scripts/.env delete mode 100644 scripts/calculate-reminders.js delete mode 100644 scripts/get-town-data.js delete mode 100644 scripts/pick-town.js diff --git a/prayertimes b/prayertimes deleted file mode 100755 index f8a8b40..0000000 --- a/prayertimes +++ /dev/null @@ -1,246 +0,0 @@ -#!/bin/sh - -OS="$(uname)" - -if [[ $OS == Darwin ]]; then - home_folder="/Users" -elif [[ $OS == Linux ]]; then - home_folder="/home" -fi - -dirpath="$home_folder/$USER/.config/prayertimes" -tdatapath="$dirpath/data/town-data.json" -rdatapath="$dirpath/data/reminders.json" -scriptspath="$dirpath/scripts" - -repourl="https://raw.githubusercontent.com/hllvc/Vaktija.ba-Gnome-Notification/main" - -iconurl="https://raw.githubusercontent.com/vaktija/vaktija.ba/master/src/img/icon-light.svg" -icon="$dirpath/data/icon.svg" - -configuretimetext_Linux () { - name="$2" - hours=$(date -d "$1" "+%_H") - minutes=$(date -d "$1" "+%_M") - seconds=$(date -d "$1" "+%_S") - if [[ $hours -eq 0 ]]; then - hours="" - elif [[ $hours -eq 1 ]] || [[ $hours -eq 21 ]]; then - hours="$(date -d "$time" "+%_H sat")" - elif [[ $hours -eq 2 ]] || [[ $hours -eq 3 ]] || [[ $hours -eq 4 ]] || [[ $hours -eq 22 ]] || [[ $hours == 23 ]]; then - hours="$(date -d "$time" "+%_H sata")" - elif [[ $hours < 10 ]]; then - hours="$(date -d "$time" "+%_H sati")" - else - hours="$(date -d "$time" "+ %_H sati")" - fi - if [[ $minutes -eq 0 ]]; then - minutes="" - elif [[ $minutes -eq 1 ]] || [[ $minutes -eq 21 ]]; then - minutes="$(date -d "$time" "+ %_M minutu")" - elif [[ $minutes -eq 2 ]] || [[ $minutes -eq 3 ]] || [[ $minutes -eq 4 ]] || [[ $minutes -eq 22 ]] || [[ $minutes == 23 ]]; then - minutes="$(date -d "$time" "+ %_M minute")" - elif [[ $minutes < 10 ]]; then - minutes="$(date -d "$time" "+%_M minuta")" - else - minutes="$(date -d "$time" "+ %_M minuta")" - fi - if [[ $hours = "" ]] && [[ $minutes = "" ]]; then - if [[ $seconds -eq 0 ]]; then - notifbody="$name je sad!" - break - elif [[ $seconds -eq 1 ]]; then - seconds="$(date -d "$time" "+%_S sekundu")" - elif [[ $seconds -eq 2 ]] || [[ $seconds -eq 3 ]] || [[ $seconds -eq 4 ]]; then - seconds="$(date -d "$time" "+%_S sekunde")" - elif [[ $seconds < 10 ]]; then - seconds="$(date -d "$time" "+%_S sekundi")" - else - modified=false - for (( sec = 21; sec < 60; sec+=10 )); do - if [[ $seconds -eq $sec ]]; then - seconds="$(date -d "$time" "+ %_S sekundu")" - modified=true - break - fi - done - for (( sec1 = 22, sec2 = 23, sec3 = 24 ; sec1 < 60; sec1+=10, sec2+=10, sec3+=10 )); do - if [[ $seconds -eq $sec1 ]] || [[ $seconds -eq $sec2 ]] || [[ $seconds -eq $sec3 ]]; then - seconds="$(date -d "$time" "+ %_S sekunde")" - modified=true - break - fi - done - if [[ $modified = false ]]; then - seconds="$(date -d "$time" "+ %_S sekundi")" - fi - fi - notifbody="$name za$seconds" - elif [[ $hours = "" ]]; then - notifbody="$name za$minutes" - elif [[ $minutes = "" ]]; then - notifbody="$name za$hours" - else - notifbody="$name za$hours i$minutes" - fi -} - -configuretimetext_Darwin () { - name="$2" - hours=$(date -j -f "%H" "$1" "+%_H") - minutes=$(date -j -f "%M" "$1" "+%_M") - seconds=$(date -j -f "%S" "$1" "+%_S") - if [[ $hours -eq 0 ]]; then - hours="" - elif [[ $hours -eq 1 ]] || [[ $hours -eq 21 ]]; then - hours="$(date -j -f "%H" "$time" "+%_H sat")" - elif [[ $hours -eq 2 ]] || [[ $hours -eq 3 ]] || [[ $hours -eq 4 ]] || [[ $hours -eq 22 ]] || [[ $hours == 23 ]]; then - hours="$(date -j -f "%H" "$time" "+%_H sata")" - elif [[ $hours < 10 ]]; then - hours="$(date -j -f "%H" "$time" "+%_H sati")" - else - hours="$(date -j -f "%H" "$time" "+ %_H sati")" - fi - if [[ $minutes -eq 0 ]]; then - minutes="" - elif [[ $minutes -eq 1 ]] || [[ $minutes -eq 21 ]]; then - minutes="$(date -j -f "%M" "$time" "+ %_M minutu")" - elif [[ $minutes -eq 2 ]] || [[ $minutes -eq 3 ]] || [[ $minutes -eq 4 ]] || [[ $minutes -eq 22 ]] || [[ $minutes == 23 ]]; then - minutes="$(date -j -f "%M" "$time" "+ %_M minute")" - elif [[ $minutes < 10 ]]; then - minutes="$(date -j -f "%M" "$time" "+%_M minuta")" - else - minutes="$(date -j -f "%M" "$time" "+ %_M minuta")" - fi - if [[ $hours = "" ]] && [[ $minutes = "" ]]; then - if [[ $seconds -eq 0 ]]; then - notifbody="$name je sad!" - break - elif [[ $seconds -eq 1 ]]; then - seconds="$(date -j -f "%S" "$time" "+%_S sekundu")" - elif [[ $seconds -eq 2 ]] || [[ $seconds -eq 3 ]] || [[ $seconds -eq 4 ]]; then - seconds="$(date -j -f "%S" "$time" "+%_S sekunde")" - elif [[ $seconds < 10 ]]; then - seconds="$(date -j -f "%S" "$time" "+%_S sekundi")" - else - modified=false - for (( sec = 21; sec < 60; sec+=10 )); do - if [[ $seconds -eq $sec ]]; then - seconds="$(date -j -f "%S" "$time" "+ %_S sekundu")" - modified=true - break - fi - done - for (( sec1 = 22, sec2 = 23, sec3 = 24 ; sec1 < 60; sec1+=10, sec2+=10, sec3+=10 )); do - if [[ $seconds -eq $sec1 ]] || [[ $seconds -eq $sec2 ]] || [[ $seconds -eq $sec3 ]]; then - seconds="$(date -j -f "%S" "$time" "+ %_S sekunde")" - modified=true - break - fi - done - if [[ $modified = false ]]; then - seconds="$(date -j -f "%S" "$time" "+ %_S sekundi")" - fi - fi - notifbody="$name za$seconds" - elif [[ $hours = "" ]]; then - notifbody="$name za$minutes" - elif [[ $minutes = "" ]]; then - notifbody="$name za$hours" - else - notifbody="$name za$hours i$minutes" - fi -} - -sendnotif () { - name="$1" - time=$2 - notifbody="" - configuretimetext_$OS $time "$name" - # notifbody=$(configuretimetext $time $name) - if [[ $OS == Darwin ]]; then - terminal-notifier -title "Vaktija.ba" -message "$notifbody" -open "https://vaktija.ba" - elif [[ $OS == Linux ]]; then - notify-send.sh "Vaktija.ba" "$notifbody" \ - -i $icon \ - -o "Open in Firefox:firefox --new-window www.vaktija.ba" \ - # -o "Snooze 5 min:notify-send.sh 'Delayed 5 minutes'" \ - # -o "Snooze 10 min:notify-send.sh 'Delayed 10 minutes'" \ - fi -} - -if [[ ! -d $dirpath ]]; then - # echo "Downloading necessary packages ..." - # sudo yay -S at notify-send.sh jq - echo "Downloading script ..." - sudo wget -O /usr/local/bin/prayertimes \ - https://raw.githubusercontent.com/hllvc/Vaktija.ba-Gnome-Notification/main/prayertimes - echo "Setting permissions ..." - sudo chmod a+x /usr/local/bin/prayertimes - mkdir -v $dirpath - mkdir -v $scriptspath - wget -O $scriptspath/pick-town.js $repourl/scripts/pick-town.js - wget -O $scriptspath/get-town-data.js $repourl/scripts/get-town-data.js - wget -O $scriptspath/calculate-reminders.js $repourl/scripts/calculate-reminders.js - wget -O $scriptspath/.env $repourl/scripts/.env - cd $scriptspath; npm install node-fetch@^2.0.0 dotenv --save; - node $scriptspath/pick-town.js - node $scriptspath/get-town-data.js - echo -e "\nDownloading icon ...\n" - wget -O $icon $iconurl - echo -e "Icon downloaded ..." -fi -if [[ $1 = "clear" ]]; then - rm -rfv $dirpath - exit -elif [[ $1 = "fetch" ]]; then - cd $scriptspath; node $scriptspath/get-town-data.js -elif [[ $1 = 'update' ]]; then - echo "Updating script ..." - sudo wget -O /usr/local/bin/prayertimes \ - https://raw.githubusercontent.com/hllvc/Vaktija.ba-Gnome-Notification/main/prayertimes - echo "Setting permissions ..." - sudo chmod a+x /usr/local/bin/prayertimes -fi - -node $scriptspath/calculate-reminders.js -# town=$(jq -j '.lokacija' $tdatapath) -# date=$(jq -j '.datum[1]' $tdatapath) -rawdata="$dirpath/data/rawdata" -jq -r '.vakat.until[]' $rdatapath > $rawdata -while read line; do - times+=( $line ) -done < $rawdata -# rm $rawdata -jq -r '.vakat[]' $tdatapath > $rawdata -while read line; do - prayers+=( "$line" ) -done < $rawdata -rm $rawdata -for index in ${!times[@]}; do - if [[ ! ${times[$index]} = "null" ]]; then - sendnotif "${prayers[$index]}" ${times[$index]} - break - fi -done - -# currentdate=$(date "+%H:%_M:%_S") -# for time in ${times[@]}; do -# hours=$(( $(date -j -f "%H" "$time" "+%H") - $(date -d "$currentdate" "+%H") )) -# minutes=$(( $(date -j -f "%H" "$time" "+%_M") - $(date -d "$currentdate" "+%_M") )) -# seconds=$(( 60 - $(date -j -f "%H" "$currentdate" "+%_S") )) -# if [[ $seconds -eq 60 ]]; then seconds=00; fi -# if [[ $hours -lt 0 ]]; then -# hours=$( expr 24 + $hours ) -# fi -# if [[ $minutes -lt 0 ]]; then -# minutes=$( expr 60 + $minutes ) -# hours=$(expr $hours - 1) -# fi -# minutes=$(expr $minutes - 1) -# if [[ $hours -eq 24 ]]; then hours=00; fi -# if [[ ! $hours -lt 0 ]] && [[ ! $minutes -lt 0 ]]; then -# diff=$(date -j -f "%H" "$hours:$minutes:$seconds" "+%T") -# echo "$time - $diff" -# fi -# done diff --git a/prayertimes.sh b/prayertimes.sh new file mode 100644 index 0000000..3da2fea --- /dev/null +++ b/prayertimes.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +current_time="$(date +"%H:%M:%S")" +prayer_times=($(curl -fsSL "https://api.vaktija.ba/" | jq -r ".vakat[]")) + +check_if_passed () { + if ([[ $(date -j -f "%H:%M" "$1" +"%H") < $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] || \ + ( [[ $(date -j -f "%H:%M" "$1" +"%H") == $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] && [[ $(date -j -f "%H:%M" "$1" +"%M") < $(date -j -f "%H:%M:%S" "$current_time" +"%M") ]] )) && \ + [[ $1 == ${prayer_times[0]} ]]; then + return 2 + elif [[ $(date -j -f "%H:%M" "$1" +"%H") < $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] || \ + ( [[ $(date -j -f "%H:%M" "$1" +"%H") == $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] && [[ $(date -j -f "%H:%M" "$1" +"%M") < $(date -j -f "%H:%M:%S" "$current_time" +"%M") ]] ); then + return 1 + fi + return 0 +} + +curr_hours="$(date -j -f "%H:%M:%S" "$current_time" +"%H")" +curr_minutes="$(date -j -f "%H:%M:%S" "$current_time" +"%M")" +curr_seconds="$(date -j -f "%H:%M:%S" "$current_time" +"%S")" + +for time in $prayer_times; do + check_if_passed $time + exit_code=$? + if [[ $exit_code == 0 ]]; then + prayer_hours="$(date -j -f "%H:%M" "$time" +"%H")" + prayer_minutes="$(date -j -f "%H:%M" "$time" +"%M")" + hours=$(($prayer_hours-$curr_hours)) + minutes=$(($prayer_minutes-$curr_minutes)) + while [[ $minutes < 0 ]]; do + minutes=$((60$minutes)) + hours=$(($hours-1)) + done + if [[ $minutes == 1 ]]; then + seconds=$((60-$curr_seconds)) + fi + break + elif [[ $exit_code == 2 ]]; then + prayer_hours="$(date -j -f "%H:%M" "$time" +"%H")" + prayer_minutes="$(date -j -f "%H:%M" "$time" +"%M")" + hours=$((24-$curr_hours+$prayer_hours)) + minutes=$((60-$curr_minutes+$prayer_minutes)) + fi +done + +echo "Prajer at $time, in $([[ $hours > 0 ]] && echo "$hours hours and ")$([[ $minutes > 1 ]] && echo "$minutes minutes")$([[ $seconds > 0 ]] && echo "$seconds seconds")" diff --git a/scripts/.env b/scripts/.env deleted file mode 100644 index 35259ed..0000000 --- a/scripts/.env +++ /dev/null @@ -1 +0,0 @@ -URL=https://api.vaktija.ba/vaktija/v1/ diff --git a/scripts/calculate-reminders.js b/scripts/calculate-reminders.js deleted file mode 100644 index 22e1ff1..0000000 --- a/scripts/calculate-reminders.js +++ /dev/null @@ -1,32 +0,0 @@ -const fetch = require("node-fetch"); -const fs = require("fs"); -const path = require("path"); -const os = require("os"); -require("dotenv").config(); - -var times = []; -const dirpath = path.join(__dirname, "../"); -const reminderspath = path.join(dirpath, "/data/reminders.json"); - -const rawdata = fs.readFileSync(reminderspath); -const data = JSON.parse(rawdata); -times = data.vakat.at; -let date = new Date(); -const newdata = { - vakat: { - ...data.vakat, - until: times.map(texttime => { - const splittime = texttime.split(":"); - date.setHours(splittime[0]); - date.setMinutes(splittime[1]); - date.setSeconds("00"); - const time = date.getTime() - Date.now(); - let reminder = new Date(time); - reminder.setHours(reminder.getHours() - 1); - if (time < 0) return null; - return reminder.toTimeString().split(" ")[0]; - }), - }, -}; -jsondata = JSON.stringify(newdata); -fs.writeFileSync(reminderspath, jsondata); diff --git a/scripts/get-town-data.js b/scripts/get-town-data.js deleted file mode 100644 index 05c56ad..0000000 --- a/scripts/get-town-data.js +++ /dev/null @@ -1,45 +0,0 @@ -const fetch = require("node-fetch"); -const fs = require("fs"); -const path = require("path"); -const os = require("os"); -require("dotenv").config(); - -const fetchdata = async () => { - const data = await fetch(`${URL}${id}`).then(res => res.json()); - let rawdata = { - ...data, - vakat: ["Zora", "Izlazak sunca", "Podne", "Ikindija", "Akšam", "Jacija"], - }; - let jsondata = JSON.stringify(rawdata); - fs.writeFileSync(tdatapath, jsondata); - rawdata = { - vakat: { - at: [ - data.vakat[0], - data.vakat[1], - data.vakat[2], - data.vakat[3], - data.vakat[4], - data.vakat[5], - ], - }, - }; - jsondata = JSON.stringify(rawdata); - fs.writeFileSync(reminderspath, jsondata); -}; - -var id; -const URL = process.env.URL; -const dirpath = path.join(__dirname, "../"); -const tdatapath = path.join(dirpath, "/data/town-data.json"); -const reminderspath = path.join(dirpath, "/data/reminders.json"); - -try { - const rawdata = fs.readFileSync(tdatapath); - const data = JSON.parse(rawdata); - id = data.id; - console.log("\nFetching town preferences ..."); - fetchdata(); -} catch (err) { - console.log(err); -} diff --git a/scripts/pick-town.js b/scripts/pick-town.js deleted file mode 100644 index 0ce6c90..0000000 --- a/scripts/pick-town.js +++ /dev/null @@ -1,51 +0,0 @@ -const fetch = require("node-fetch"); -const fs = require("fs"); -const path = require("path"); -const os = require("os"); -require("dotenv").config(); - -const readline = require("readline").createInterface({ - input: process.stdin, - output: process.stdout, -}); - -const fetchdata = async () => { - data = await fetch(`${URL}lokacije`).then(res => res.json()); - picktown(); -}; - -const picktown = () => { - data.map((town, index) => console.log(`[ ${index} ] ${town}`)); - readline.question("\nChoose town?\n> ", id => { - town = data[id]; - console.log(`\nYou picked ${town}.`); - readline.close(); - try { - if (!fs.existsSync(datapath)) { - fs.mkdirSync(datapath); - console.log("\nCreating data folder ..."); - } - } catch (err) { - console.log(err); - } - let towndata = { - id: id, - }; - let jsondata = JSON.stringify(towndata); - try { - fs.writeFileSync(filepath, jsondata); - console.log("\nSaving data ..."); - } catch (err) { - console.log(err); - } - }); -}; - -const URL = process.env.URL; -const dirpath = path.join(__dirname, "../"); -const datapath = path.join(dirpath, "/data"); -const filepath = path.join(datapath, "/town-data.json"); -var data = {}; - -console.log("Fetching data ...\n"); -fetchdata(); From 09617584644be895ae23cd0c8cf56effd923c68b Mon Sep 17 00:00:00 2001 From: hllvc Date: Fri, 24 Dec 2021 22:42:38 +0100 Subject: [PATCH 05/15] option to choose town, os detection * list of all towns on initial setup * selected town is saved in home dir under .prayerconfig * os type is now automatically detected --- prayertimes.sh | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/prayertimes.sh b/prayertimes.sh index 3da2fea..2e71f6a 100644 --- a/prayertimes.sh +++ b/prayertimes.sh @@ -1,7 +1,47 @@ #!/bin/bash +os="$(uname)" + +if [[ $os == Darwin ]]; then + homedir="/Users" +elif [[ $os == Linux ]]; then + homedir="/home" +fi +echo -e "\nRecognized $os as your OS.\n" + +config="$homedir/$USER/.prayerconfig" +url="https://api.vaktija.ba/vaktija/v1" + +initital_config () { + echo -e "\nFetching list of towns...\n" + old_ifs=$IFS + IFS=$'\n' + locations=($(curl -fsSL "$url/lokacije" | jq -r ".[]")) + IFS=$old_ifs + + for i in ${!locations[@]}; do + echo "[$i] ${locations[$i]}" + done + + read -p $'\nChoose town\n> ' town + echo -e "\nCreating config file at $config" + echo 'town='"$town"'' >> $config +} + +check_config () { + [[ ! -e $config ]] && return 1 + old_ifs=$IFS + IFS="=" + town=($(grep 'town=[0-90-90-9]' $config)) + town=${town[1]} + IFS=$old_ifs +} + +check_config +[[ $? == 1 ]] && initital_config + current_time="$(date +"%H:%M:%S")" -prayer_times=($(curl -fsSL "https://api.vaktija.ba/" | jq -r ".vakat[]")) +prayer_times=($(curl -fsSL "$url/$town" | jq -r ".vakat[]")) check_if_passed () { if ([[ $(date -j -f "%H:%M" "$1" +"%H") < $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] || \ From 64072360edc77d024aadbbadffc275c921c9378e Mon Sep 17 00:00:00 2001 From: hllvc Date: Fri, 24 Dec 2021 22:54:43 +0100 Subject: [PATCH 06/15] added bosnian language --- prayertimes.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/prayertimes.sh b/prayertimes.sh index 2e71f6a..2a735f2 100644 --- a/prayertimes.sh +++ b/prayertimes.sh @@ -7,13 +7,18 @@ if [[ $os == Darwin ]]; then elif [[ $os == Linux ]]; then homedir="/home" fi -echo -e "\nRecognized $os as your OS.\n" config="$homedir/$USER/.prayerconfig" url="https://api.vaktija.ba/vaktija/v1" initital_config () { - echo -e "\nFetching list of towns...\n" + read -p $'\nLanguages (Jezici):\n\n[0] English\n[1] Bosanski\n\nChoose language (Odaberite jezik)\n> ' lang + [[ $lang == 0 ]] && echo -e "\nCreating config file at $config" + [[ $lang == 1 ]] && echo -e "\nKreiranje konfiguracija u $config" + echo 'lang='"$lang"'' > $config + + [[ $lang == 0 ]] && echo -e "\nFetching list of towns...\n" + [[ $lang == 1 ]] && echo -e "\nDobavljamo listu gradova...\n" old_ifs=$IFS IFS=$'\n' locations=($(curl -fsSL "$url/lokacije" | jq -r ".[]")) @@ -23,9 +28,10 @@ initital_config () { echo "[$i] ${locations[$i]}" done - read -p $'\nChoose town\n> ' town - echo -e "\nCreating config file at $config" + [[ $lang == 0 ]] && read -p $'\nChoose town\n> ' town + [[ $lang == 1 ]] && read -p $'\nOdaberite grad\n> ' town echo 'town='"$town"'' >> $config + } check_config () { @@ -34,6 +40,8 @@ check_config () { IFS="=" town=($(grep 'town=[0-90-90-9]' $config)) town=${town[1]} + lang=($(grep 'lang=[0-9]' $config)) + lang=${lang[1]} IFS=$old_ifs } @@ -83,4 +91,5 @@ for time in $prayer_times; do fi done -echo "Prajer at $time, in $([[ $hours > 0 ]] && echo "$hours hours and ")$([[ $minutes > 1 ]] && echo "$minutes minutes")$([[ $seconds > 0 ]] && echo "$seconds seconds")" +[[ $lang == 0 ]] && echo -e "\nPrajer at $time, in $([[ $hours > 0 ]] && echo "$hours hours and ")$([[ $minutes > 1 ]] && echo "$minutes minutes")$([[ $seconds > 0 ]] && echo "$seconds seconds")" +[[ $lang == 1 ]] && echo -e "\nVakat u $time, za $([[ $hours > 0 ]] && echo "$hours sati i ")$([[ $minutes > 1 ]] && echo "$minutes minuta")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" From f62e583389397b8ad72246fdb0cade3c5ce4e65d Mon Sep 17 00:00:00 2001 From: hllvc Date: Sat, 25 Dec 2021 00:56:07 +0100 Subject: [PATCH 07/15] additional arguments for script --- prayertimes.sh | 102 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 90 insertions(+), 12 deletions(-) mode change 100644 => 100755 prayertimes.sh diff --git a/prayertimes.sh b/prayertimes.sh old mode 100644 new mode 100755 index 2a735f2..fa1c90d --- a/prayertimes.sh +++ b/prayertimes.sh @@ -11,8 +11,35 @@ fi config="$homedir/$USER/.prayerconfig" url="https://api.vaktija.ba/vaktija/v1" +usage () { + echo -e "\nUsage: $(basename "$0") [OPTIONS] + + Where OPTIONS are: + + -h) Show this help + -c) Remove config + -u) Update town and data + -e) Edit config file + -s) Show config file + -l ARG) Change language (where ARG is [en] or [ba])" + exit 2 +} + +load_config () { + [[ ! -e $config ]] && return 1 + old_ifs=$IFS + IFS="=" + town=($(grep 'town=[0-90-90-9]' $config)) + town=${town[1]} + lang=($(grep 'lang=[0-1]' $config)) + lang=${lang[1]} + IFS=$old_ifs +} + initital_config () { - read -p $'\nLanguages (Jezici):\n\n[0] English\n[1] Bosanski\n\nChoose language (Odaberite jezik)\n> ' lang + while [[ $lang > 1 ]] || [[ $lang < 0 ]]; do + read -p $'\nLanguages (Jezici):\n\n[0] English\n[1] Bosanski\n\nChoose language (Odaberite jezik)\n> ' lang + done [[ $lang == 0 ]] && echo -e "\nCreating config file at $config" [[ $lang == 1 ]] && echo -e "\nKreiranje konfiguracija u $config" echo 'lang='"$lang"'' > $config @@ -28,26 +55,77 @@ initital_config () { echo "[$i] ${locations[$i]}" done - [[ $lang == 0 ]] && read -p $'\nChoose town\n> ' town - [[ $lang == 1 ]] && read -p $'\nOdaberite grad\n> ' town + while [[ $town > $((${#locations[@]}-1)) ]] || [[ $town < 0 ]]; do + [[ $lang == 0 ]] && read -p $'\nChoose town\n> ' town + [[ $lang == 1 ]] && read -p $'\nOdaberite grad\n> ' town + done echo 'town='"$town"'' >> $config + usage } -check_config () { - [[ ! -e $config ]] && return 1 +update_town () { + [[ $lang == 0 ]] && echo -e "\nFetching list of towns...\n" + [[ $lang == 1 ]] && echo -e "\nDobavljamo listu gradova...\n" old_ifs=$IFS - IFS="=" - town=($(grep 'town=[0-90-90-9]' $config)) - town=${town[1]} - lang=($(grep 'lang=[0-9]' $config)) - lang=${lang[1]} + IFS=$'\n' + locations=($(curl -fsSL "$url/lokacije" | jq -r ".[]")) IFS=$old_ifs + + for i in ${!locations[@]}; do + echo "[$i] ${locations[$i]}" + done + + town=unset + while [[ $town < 0 ]] || [[ $town > $((${#locations[@]}-1)) ]]; do + [[ $lang == 0 ]] && read -p $'\nChoose town\n> ' town + [[ $lang == 1 ]] && read -p $'\nOdaberite grad\n> ' town + done + sed -i'' -e 's/town=.*/town='$town'/' $config } -check_config +load_config [[ $? == 1 ]] && initital_config +init=0 +while getopts 'hcuesl:' arg; do + case "$arg" in + h) + usage + ;; + c) + rm $config + init=2 + ;; + u) + update_town + init=2 + ;; + e) + $EDITOR $config + exit 2 + ;; + s) + cat $config + exit 2 + ;; + l) + if [[ $OPTARG == "en" ]]; then + lang=0 + elif [[ $OPTARG == "ba" ]]; then + lang=1 + else + usage + fi + sed -i'' -e 's/lang=[0-1]/lang='"$lang"'/' $config + ;; + *) + usage + ;; + esac +done +[[ $init == 2 ]] && exit 2 + current_time="$(date +"%H:%M:%S")" prayer_times=($(curl -fsSL "$url/$town" | jq -r ".vakat[]")) @@ -91,5 +169,5 @@ for time in $prayer_times; do fi done -[[ $lang == 0 ]] && echo -e "\nPrajer at $time, in $([[ $hours > 0 ]] && echo "$hours hours and ")$([[ $minutes > 1 ]] && echo "$minutes minutes")$([[ $seconds > 0 ]] && echo "$seconds seconds")" +[[ $lang == 0 ]] && echo -e "\nPrayer at $time, in $([[ $hours > 0 ]] && echo "$hours hours and ")$([[ $minutes > 1 ]] && echo "$minutes minutes")$([[ $seconds > 0 ]] && echo "$seconds seconds")" [[ $lang == 1 ]] && echo -e "\nVakat u $time, za $([[ $hours > 0 ]] && echo "$hours sati i ")$([[ $minutes > 1 ]] && echo "$minutes minuta")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" From ed08fd593c9b3c8d6be514f4fda67db0293f7576 Mon Sep 17 00:00:00 2001 From: hllvc Date: Sat, 25 Dec 2021 01:11:55 +0100 Subject: [PATCH 08/15] fix for town selection --- prayertimes.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) mode change 100755 => 100644 prayertimes.sh diff --git a/prayertimes.sh b/prayertimes.sh old mode 100755 new mode 100644 index fa1c90d..108d4fc --- a/prayertimes.sh +++ b/prayertimes.sh @@ -55,7 +55,8 @@ initital_config () { echo "[$i] ${locations[$i]}" done - while [[ $town > $((${#locations[@]}-1)) ]] || [[ $town < 0 ]]; do + town=-1 + while [[ $town -lt 0 ]] || [[ $town -gt $((${#locations[@]}-1)) ]]; do [[ $lang == 0 ]] && read -p $'\nChoose town\n> ' town [[ $lang == 1 ]] && read -p $'\nOdaberite grad\n> ' town done @@ -76,10 +77,13 @@ update_town () { echo "[$i] ${locations[$i]}" done - town=unset - while [[ $town < 0 ]] || [[ $town > $((${#locations[@]}-1)) ]]; do + town=-1 + echo $town + while [[ $town -lt 0 ]] || [[ $town -gt $((${#locations[@]}-1)) ]]; do [[ $lang == 0 ]] && read -p $'\nChoose town\n> ' town [[ $lang == 1 ]] && read -p $'\nOdaberite grad\n> ' town + echo $town + echo $((${#locations[@]}-1)) done sed -i'' -e 's/town=.*/town='$town'/' $config } @@ -87,7 +91,6 @@ update_town () { load_config [[ $? == 1 ]] && initital_config -init=0 while getopts 'hcuesl:' arg; do case "$arg" in h) @@ -95,11 +98,11 @@ while getopts 'hcuesl:' arg; do ;; c) rm $config - init=2 + exit 2 ;; u) update_town - init=2 + exit 2 ;; e) $EDITOR $config @@ -124,7 +127,6 @@ while getopts 'hcuesl:' arg; do ;; esac done -[[ $init == 2 ]] && exit 2 current_time="$(date +"%H:%M:%S")" prayer_times=($(curl -fsSL "$url/$town" | jq -r ".vakat[]")) From c3ad0f2ee06329f1a36f375c9ef4562fcf789519 Mon Sep 17 00:00:00 2001 From: hllvc Date: Sat, 25 Dec 2021 01:33:29 +0100 Subject: [PATCH 09/15] fix upcoming prayer output --- prayertimes.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prayertimes.sh b/prayertimes.sh index 108d4fc..89b4347 100644 --- a/prayertimes.sh +++ b/prayertimes.sh @@ -159,7 +159,7 @@ for time in $prayer_times; do minutes=$((60$minutes)) hours=$(($hours-1)) done - if [[ $minutes == 1 ]]; then + if [[ $minutes == 1 ]] && [[ $hours == 0 ]]; then seconds=$((60-$curr_seconds)) fi break @@ -171,5 +171,5 @@ for time in $prayer_times; do fi done -[[ $lang == 0 ]] && echo -e "\nPrayer at $time, in $([[ $hours > 0 ]] && echo "$hours hours and ")$([[ $minutes > 1 ]] && echo "$minutes minutes")$([[ $seconds > 0 ]] && echo "$seconds seconds")" -[[ $lang == 1 ]] && echo -e "\nVakat u $time, za $([[ $hours > 0 ]] && echo "$hours sati i ")$([[ $minutes > 1 ]] && echo "$minutes minuta")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" +[[ $lang == 0 ]] && echo -e "\nPrayer at $time, in $([[ $hours > 0 ]] && echo "$hours hours ")$([[ $minutes > 1 ]] && echo "$minutes minutes")$([[ $seconds > 0 ]] && echo "$seconds seconds")" +[[ $lang == 1 ]] && echo -e "\nVakat u $time, za $([[ $hours > 0 ]] && echo "$hours sati ")$([[ $minutes > 1 ]] && echo "$minutes minuta")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" From 57338a12918fab63e25f1dfd7959333f6623b393 Mon Sep 17 00:00:00 2001 From: hllvc Date: Sun, 26 Dec 2021 10:33:13 +0100 Subject: [PATCH 10/15] Linux support, calculation fixes * switch between Linux and Darwin based on current os * added aditinal scripts for Linux * fixed time calculation --- prayertimes.sh | 104 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 28 deletions(-) diff --git a/prayertimes.sh b/prayertimes.sh index 89b4347..29e2552 100644 --- a/prayertimes.sh +++ b/prayertimes.sh @@ -131,7 +131,7 @@ done current_time="$(date +"%H:%M:%S")" prayer_times=($(curl -fsSL "$url/$town" | jq -r ".vakat[]")) -check_if_passed () { +check_if_passed_Darwin () { if ([[ $(date -j -f "%H:%M" "$1" +"%H") < $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] || \ ( [[ $(date -j -f "%H:%M" "$1" +"%H") == $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] && [[ $(date -j -f "%H:%M" "$1" +"%M") < $(date -j -f "%H:%M:%S" "$current_time" +"%M") ]] )) && \ [[ $1 == ${prayer_times[0]} ]]; then @@ -143,33 +143,81 @@ check_if_passed () { return 0 } -curr_hours="$(date -j -f "%H:%M:%S" "$current_time" +"%H")" -curr_minutes="$(date -j -f "%H:%M:%S" "$current_time" +"%M")" -curr_seconds="$(date -j -f "%H:%M:%S" "$current_time" +"%S")" - -for time in $prayer_times; do - check_if_passed $time - exit_code=$? - if [[ $exit_code == 0 ]]; then - prayer_hours="$(date -j -f "%H:%M" "$time" +"%H")" - prayer_minutes="$(date -j -f "%H:%M" "$time" +"%M")" - hours=$(($prayer_hours-$curr_hours)) - minutes=$(($prayer_minutes-$curr_minutes)) - while [[ $minutes < 0 ]]; do - minutes=$((60$minutes)) - hours=$(($hours-1)) - done - if [[ $minutes == 1 ]] && [[ $hours == 0 ]]; then - seconds=$((60-$curr_seconds)) - fi - break - elif [[ $exit_code == 2 ]]; then - prayer_hours="$(date -j -f "%H:%M" "$time" +"%H")" - prayer_minutes="$(date -j -f "%H:%M" "$time" +"%M")" - hours=$((24-$curr_hours+$prayer_hours)) - minutes=$((60-$curr_minutes+$prayer_minutes)) - fi -done +check_if_passed_Linux () { + if ([[ $(date -d "$1" +"%H") < $(date -d "$current_time" +"%H") ]] || \ + ( [[ $(date -d "$1" +"%H") == $(date -d "$current_time" +"%H") ]] && [[ $(date -d "$1" +"%M") < $(date -d "$current_time" +"%M") ]] )) && \ + [[ $1 == ${prayer_times[0]} ]] && [[ $(date -d "${prayer_times[5]}" +"%H") < $(date -d "$current_time" +"%H") ]]; then + return 2 + elif [[ $(date -d "$1" +"%H") < $(date -d "$current_time" +"%H") ]] || \ + ( [[ $(date -d "$1" +"%H") == $(date -d "$current_time" +"%H") ]] && [[ $(date -d "$1" +"%M") < $(date -d "$current_time" +"%M") ]] ); then + return 1 + fi + return 0 +} + +Darwin () { + for time in $prayer_times; do + check_if_passed_$os $time + exit_code=$? + + curr_hours="$(date -j -f "%H:%M:%S" "$current_time" +"%_H")" + curr_minutes="$(date -j -f "%H:%M:%S" "$current_time" +"%_M")" + curr_seconds="$(date -j -f "%H:%M:%S" "$current_time" +"%_S")" + + if [[ $exit_code == 0 ]]; then + prayer_hours="$(date -j -f "%H:%M" "$time" +"%_H")" + prayer_minutes="$(date -j -f "%H:%M" "$time" +"%_M")" + hours=$(($prayer_hours-$curr_hours)) + minutes=$(($prayer_minutes-$curr_minutes)) + while [[ $minutes < 0 ]]; do + minutes=$((60$minutes)) + hours=$(($hours-1)) + done + if [[ $minutes == 1 ]] && [[ $hours == 0 ]]; then + seconds=$((60-$curr_seconds)) + fi + break + elif [[ $exit_code == 2 ]]; then + prayer_hours="$(date -j -f "%H:%M" "$time" +"%_H")" + prayer_minutes="$(date -j -f "%H:%M" "$time" +"%_M")" + hours=$((24-$curr_hours+$prayer_hours)) + minutes=$((60-$curr_minutes+$prayer_minutes)) + fi + done +} + +Linux () { + for time in ${prayer_times[@]}; do + check_if_passed_$os $time + exit_code=$? + + curr_hours="$(date -d "$current_time" +"%_H")" + curr_minutes="$(date -d "$current_time" +"%_M")" + curr_seconds="$(date -d "$current_time" +"%_S")" + + if [[ $exit_code == 0 ]]; then + prayer_hours="$(date -d "$time" +"%_H")" + prayer_minutes="$(date -d "$time" +"%_M")" + hours=$(($prayer_hours-$curr_hours)) + minutes=$(($prayer_minutes-$curr_minutes)) + while [[ $minutes < 0 ]]; do + minutes=$((60$minutes)) + hours=$(($hours-1)) + done + if [[ $minutes == 1 ]] && [[ $hours == 0 ]]; then + seconds=$((60-$curr_seconds)) + fi + break + elif [[ $exit_code == 2 ]]; then + prayer_hours="$(date -d "$time" +"%_H")" + prayer_minutes="$(date -d "$time" +"%_M")" + hours=$((24-$curr_hours+$prayer_hours)) + minutes=$((60-$curr_minutes+$prayer_minutes)) + fi + done +} + +$os [[ $lang == 0 ]] && echo -e "\nPrayer at $time, in $([[ $hours > 0 ]] && echo "$hours hours ")$([[ $minutes > 1 ]] && echo "$minutes minutes")$([[ $seconds > 0 ]] && echo "$seconds seconds")" [[ $lang == 1 ]] && echo -e "\nVakat u $time, za $([[ $hours > 0 ]] && echo "$hours sati ")$([[ $minutes > 1 ]] && echo "$minutes minuta")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" From 3d7f6526acfb95e1f3d41ee81be8156796ae5ec5 Mon Sep 17 00:00:00 2001 From: hllvc Date: Sun, 26 Dec 2021 15:06:31 +0100 Subject: [PATCH 11/15] Linux side calculation fix, added seconds in output --- prayertimes.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/prayertimes.sh b/prayertimes.sh index 29e2552..63c7412 100644 --- a/prayertimes.sh +++ b/prayertimes.sh @@ -201,12 +201,11 @@ Linux () { hours=$(($prayer_hours-$curr_hours)) minutes=$(($prayer_minutes-$curr_minutes)) while [[ $minutes < 0 ]]; do - minutes=$((60$minutes)) + minutes=$((60+$minutes)) hours=$(($hours-1)) done - if [[ $minutes == 1 ]] && [[ $hours == 0 ]]; then - seconds=$((60-$curr_seconds)) - fi + minutes=$(($minutes-1)) + seconds=$((60-$curr_seconds)) break elif [[ $exit_code == 2 ]]; then prayer_hours="$(date -d "$time" +"%_H")" @@ -219,5 +218,5 @@ Linux () { $os -[[ $lang == 0 ]] && echo -e "\nPrayer at $time, in $([[ $hours > 0 ]] && echo "$hours hours ")$([[ $minutes > 1 ]] && echo "$minutes minutes")$([[ $seconds > 0 ]] && echo "$seconds seconds")" -[[ $lang == 1 ]] && echo -e "\nVakat u $time, za $([[ $hours > 0 ]] && echo "$hours sati ")$([[ $minutes > 1 ]] && echo "$minutes minuta")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" +[[ $lang == 0 ]] && echo -e "\nPrayer at $time, in $([[ $hours > 0 ]] && echo "$hours hours ")$([[ $minutes > 0 ]] && echo "$minutes minutes ")$([[ $seconds > 0 ]] && echo "$seconds seconds")" +[[ $lang == 1 ]] && echo -e "\nVakat u $time, za $([[ $hours > 0 ]] && echo "$hours sati ")$([[ $minutes > 0 ]] && echo "$minutes minuta ")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" From 68fc73c3e17401d8f45f1de734ca9609eba146ab Mon Sep 17 00:00:00 2001 From: hllvc Date: Wed, 29 Dec 2021 18:52:33 +0100 Subject: [PATCH 12/15] minor display/calculation fix --- prayertimes.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/prayertimes.sh b/prayertimes.sh index 63c7412..cde4e52 100644 --- a/prayertimes.sh +++ b/prayertimes.sh @@ -201,17 +201,18 @@ Linux () { hours=$(($prayer_hours-$curr_hours)) minutes=$(($prayer_minutes-$curr_minutes)) while [[ $minutes < 0 ]]; do - minutes=$((60+$minutes)) + minutes=$((59+$minutes)) hours=$(($hours-1)) done - minutes=$(($minutes-1)) seconds=$((60-$curr_seconds)) break elif [[ $exit_code == 2 ]]; then prayer_hours="$(date -d "$time" +"%_H")" prayer_minutes="$(date -d "$time" +"%_M")" hours=$((24-$curr_hours+$prayer_hours)) - minutes=$((60-$curr_minutes+$prayer_minutes)) + minutes=$((59-$curr_minutes+$prayer_minutes)) + seconds=$((60-$curr_seconds)) + break fi done } From 8eb9ee22fbafb303ccb33708fc0f982ea6e56c79 Mon Sep 17 00:00:00 2001 From: hllvc Date: Thu, 30 Dec 2021 12:23:14 +0100 Subject: [PATCH 13/15] additional fixes * macos fixes * minor calculation fix * output modification * ability to continue config setup later if exited --- prayertimes.sh | 142 +++++++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 64 deletions(-) diff --git a/prayertimes.sh b/prayertimes.sh index cde4e52..a2900a0 100644 --- a/prayertimes.sh +++ b/prayertimes.sh @@ -16,76 +16,85 @@ usage () { Where OPTIONS are: - -h) Show this help - -c) Remove config - -u) Update town and data - -e) Edit config file - -s) Show config file - -l ARG) Change language (where ARG is [en] or [ba])" + -h Show this help + -c Remove config + -u Update town and data + -e Edit config file + -s Show config file + -l ARG Change language (where ARG is [en] or [ba])" exit 2 } -load_config () { - [[ ! -e $config ]] && return 1 +get_town () { + [[ $lang == 0 ]] && echo -e "\nFetching list of towns..\n" + [[ $lang == 1 ]] && echo -e "\nDobavljamo listu gradova..\n" old_ifs=$IFS - IFS="=" - town=($(grep 'town=[0-90-90-9]' $config)) - town=${town[1]} - lang=($(grep 'lang=[0-1]' $config)) - lang=${lang[1]} + IFS=$'\n' + locations=($(curl -fsSL "$url/lokacije" | jq -r ".[]")) IFS=$old_ifs + + for i in ${!locations[@]}; do + echo "[$i] ${locations[$i]}" + done + + [[ $lang == 0 ]] && echo -e "\nDefault set to Sarajevo" + [[ $lang == 1 ]] && echo -e "\nZadani grad Sarajevo" + + while + [[ $lang == 0 ]] && read -p $'\nChoose town [ENTER for default]\n> ' town + [[ $lang == 1 ]] && read -p $'\nOdaberite grad [ENTER za zadani grad]\n> ' town + [[ $town -lt 0 ]] || [[ $town -gt $((${#locations[@]}-1)) ]] + do + [[ $lang == 0 ]] && echo -e "\nInvalid choice!" + [[ $lang == 1 ]] && echo -e "\nPogresan odabir!" + done + + [[ -z $town ]] && town=77 + [[ $lang == 0 ]] && echo -e "\nSaving town choice to $config" + [[ $lang == 1 ]] && echo -e "\nSpremanje grada u $config" + sed -i'' -e 's/town=.*/town='$town'/' $config } initital_config () { + echo $'lang=\ntown=' > $config + while [[ $lang > 1 ]] || [[ $lang < 0 ]]; do read -p $'\nLanguages (Jezici):\n\n[0] English\n[1] Bosanski\n\nChoose language (Odaberite jezik)\n> ' lang done - [[ $lang == 0 ]] && echo -e "\nCreating config file at $config" - [[ $lang == 1 ]] && echo -e "\nKreiranje konfiguracija u $config" - echo 'lang='"$lang"'' > $config - [[ $lang == 0 ]] && echo -e "\nFetching list of towns...\n" - [[ $lang == 1 ]] && echo -e "\nDobavljamo listu gradova...\n" - old_ifs=$IFS - IFS=$'\n' - locations=($(curl -fsSL "$url/lokacije" | jq -r ".[]")) - IFS=$old_ifs + [[ $lang == 0 ]] && echo -e "\nSaving language choice to $config" + [[ $lang == 1 ]] && echo -e "\nSpremanje jezika u $config" + sed -i'' -e 's/lang=.*/lang='"$lang"'/' $config - for i in ${!locations[@]}; do - echo "[$i] ${locations[$i]}" - done + get_town - town=-1 - while [[ $town -lt 0 ]] || [[ $town -gt $((${#locations[@]}-1)) ]]; do - [[ $lang == 0 ]] && read -p $'\nChoose town\n> ' town - [[ $lang == 1 ]] && read -p $'\nOdaberite grad\n> ' town - done - echo 'town='"$town"'' >> $config usage - } -update_town () { - [[ $lang == 0 ]] && echo -e "\nFetching list of towns...\n" - [[ $lang == 1 ]] && echo -e "\nDobavljamo listu gradova...\n" +load_config () { + [[ ! -e $config ]] && return 1 + old_ifs=$IFS - IFS=$'\n' - locations=($(curl -fsSL "$url/lokacije" | jq -r ".[]")) - IFS=$old_ifs + IFS="=" - for i in ${!locations[@]}; do - echo "[$i] ${locations[$i]}" - done + while + lang=($(grep 'lang=[0-1]' $config)) + [[ $? != 0 ]] + do initital_config; done + lang=${lang[1]} - town=-1 - echo $town - while [[ $town -lt 0 ]] || [[ $town -gt $((${#locations[@]}-1)) ]]; do - [[ $lang == 0 ]] && read -p $'\nChoose town\n> ' town - [[ $lang == 1 ]] && read -p $'\nOdaberite grad\n> ' town - echo $town - echo $((${#locations[@]}-1)) + while + town=($(grep 'town=[0-90-90-9]' $config)) + [[ $? != 0 ]] + do + [[ $lang == 0 ]] && echo $'\nContinuing setup..' + [[ $lang == 1 ]] && echo $'\nNastavka konfiguracije..' + get_town + usage done - sed -i'' -e 's/town=.*/town='$town'/' $config + town=${town[1]} + + IFS=$old_ifs } load_config @@ -98,11 +107,9 @@ while getopts 'hcuesl:' arg; do ;; c) rm $config - exit 2 ;; u) - update_town - exit 2 + get_town ;; e) $EDITOR $config @@ -134,7 +141,7 @@ prayer_times=($(curl -fsSL "$url/$town" | jq -r ".vakat[]")) check_if_passed_Darwin () { if ([[ $(date -j -f "%H:%M" "$1" +"%H") < $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] || \ ( [[ $(date -j -f "%H:%M" "$1" +"%H") == $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] && [[ $(date -j -f "%H:%M" "$1" +"%M") < $(date -j -f "%H:%M:%S" "$current_time" +"%M") ]] )) && \ - [[ $1 == ${prayer_times[0]} ]]; then + [[ $1 == ${prayer_times[0]} ]] && [[ $(date -j -f "%H:%M" "${prayer_times[5]}" +"%H") < $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]]; then return 2 elif [[ $(date -j -f "%H:%M" "$1" +"%H") < $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] || \ ( [[ $(date -j -f "%H:%M" "$1" +"%H") == $(date -j -f "%H:%M:%S" "$current_time" +"%H") ]] && [[ $(date -j -f "%H:%M" "$1" +"%M") < $(date -j -f "%H:%M:%S" "$current_time" +"%M") ]] ); then @@ -156,7 +163,7 @@ check_if_passed_Linux () { } Darwin () { - for time in $prayer_times; do + for time in ${prayer_times[@]}; do check_if_passed_$os $time exit_code=$? @@ -170,18 +177,21 @@ Darwin () { hours=$(($prayer_hours-$curr_hours)) minutes=$(($prayer_minutes-$curr_minutes)) while [[ $minutes < 0 ]]; do - minutes=$((60$minutes)) + minutes=$((60+$minutes)) hours=$(($hours-1)) done - if [[ $minutes == 1 ]] && [[ $hours == 0 ]]; then - seconds=$((60-$curr_seconds)) - fi + if (($minutes <= 1)); then + seconds=$((60-$curr_seconds)) + fi break elif [[ $exit_code == 2 ]]; then prayer_hours="$(date -j -f "%H:%M" "$time" +"%_H")" prayer_minutes="$(date -j -f "%H:%M" "$time" +"%_M")" hours=$((24-$curr_hours+$prayer_hours)) minutes=$((60-$curr_minutes+$prayer_minutes)) + if (( $minute <= 1 )); then + seconds=$((60-$curr_seconds)) + fi fi done } @@ -201,17 +211,21 @@ Linux () { hours=$(($prayer_hours-$curr_hours)) minutes=$(($prayer_minutes-$curr_minutes)) while [[ $minutes < 0 ]]; do - minutes=$((59+$minutes)) + minutes=$((60+$minutes)) hours=$(($hours-1)) done - seconds=$((60-$curr_seconds)) + if (( $minutes <= 1 )); then + seconds=$((60-$curr_seconds)) + fi break elif [[ $exit_code == 2 ]]; then prayer_hours="$(date -d "$time" +"%_H")" prayer_minutes="$(date -d "$time" +"%_M")" hours=$((24-$curr_hours+$prayer_hours)) - minutes=$((59-$curr_minutes+$prayer_minutes)) - seconds=$((60-$curr_seconds)) + minutes=$((60-$curr_minutes+$prayer_minutes)) + if (( $minutes <= 1 )); then + seconds=$((60-$curr_seconds)) + fi break fi done @@ -219,5 +233,5 @@ Linux () { $os -[[ $lang == 0 ]] && echo -e "\nPrayer at $time, in $([[ $hours > 0 ]] && echo "$hours hours ")$([[ $minutes > 0 ]] && echo "$minutes minutes ")$([[ $seconds > 0 ]] && echo "$seconds seconds")" -[[ $lang == 1 ]] && echo -e "\nVakat u $time, za $([[ $hours > 0 ]] && echo "$hours sati ")$([[ $minutes > 0 ]] && echo "$minutes minuta ")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" +[[ $lang == 0 ]] && echo -e "\nPrayer at $time$(([[ $hours > 0 ]] || [[ $minutes > 0 ]] || [[ $seconds > 0 ]]) && echo ", in ")$([[ $hours > 0 ]] && echo "$hours hours ")$([[ $minutes > 0 ]] && echo "$minutes minutes ")$([[ $seconds > 0 ]] && echo "$seconds seconds")" +[[ $lang == 1 ]] && echo -e "\nVakat u $time$(([[ $hours > 0 ]] || [[ $minutes > 0 ]] || [[ $seconds > 0 ]]) && echo ", za ")$([[ $hours > 0 ]] && echo "$hours sati ")$([[ $minutes > 0 ]] && echo "$minutes minuta ")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" From 7893185d78fee852de4e8d99956ec9c2c4ba5a62 Mon Sep 17 00:00:00 2001 From: hllvc Date: Sat, 1 Jan 2022 19:27:09 +0100 Subject: [PATCH 14/15] pre-release bug fixes * fix 1 minute and under a minute calculations * exit loop fix if all prayers have passed * text ouput changes --- prayertimes.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/prayertimes.sh b/prayertimes.sh index a2900a0..fb18a39 100644 --- a/prayertimes.sh +++ b/prayertimes.sh @@ -180,8 +180,9 @@ Darwin () { minutes=$((60+$minutes)) hours=$(($hours-1)) done - if (($minutes <= 1)); then + if (( $minutes == 1 )) && (( $curr_seconds != 0 )); then seconds=$((60-$curr_seconds)) + minutes=$(($minutes-1)) fi break elif [[ $exit_code == 2 ]]; then @@ -189,9 +190,10 @@ Darwin () { prayer_minutes="$(date -j -f "%H:%M" "$time" +"%_M")" hours=$((24-$curr_hours+$prayer_hours)) minutes=$((60-$curr_minutes+$prayer_minutes)) - if (( $minute <= 1 )); then - seconds=$((60-$curr_seconds)) + if (( $minutes > 59 )); then + minutes=$(($minutes-60)) fi + break fi done } @@ -214,8 +216,9 @@ Linux () { minutes=$((60+$minutes)) hours=$(($hours-1)) done - if (( $minutes <= 1 )); then + if (( $minutes == 1 )) && (( $curr_seconds != 0 )); then seconds=$((60-$curr_seconds)) + minutes=$(($minutes-1)) fi break elif [[ $exit_code == 2 ]]; then @@ -223,8 +226,8 @@ Linux () { prayer_minutes="$(date -d "$time" +"%_M")" hours=$((24-$curr_hours+$prayer_hours)) minutes=$((60-$curr_minutes+$prayer_minutes)) - if (( $minutes <= 1 )); then - seconds=$((60-$curr_seconds)) + if (( $minutes > 59 )); then + minutes=$(($minutes-60)) fi break fi @@ -233,5 +236,5 @@ Linux () { $os -[[ $lang == 0 ]] && echo -e "\nPrayer at $time$(([[ $hours > 0 ]] || [[ $minutes > 0 ]] || [[ $seconds > 0 ]]) && echo ", in ")$([[ $hours > 0 ]] && echo "$hours hours ")$([[ $minutes > 0 ]] && echo "$minutes minutes ")$([[ $seconds > 0 ]] && echo "$seconds seconds")" -[[ $lang == 1 ]] && echo -e "\nVakat u $time$(([[ $hours > 0 ]] || [[ $minutes > 0 ]] || [[ $seconds > 0 ]]) && echo ", za ")$([[ $hours > 0 ]] && echo "$hours sati ")$([[ $minutes > 0 ]] && echo "$minutes minuta ")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" +[[ $lang == 0 ]] && echo -e "\nNext prayer at $time$(([[ $hours > 0 ]] || [[ $minutes > 0 ]] || [[ $seconds > 0 ]]) && echo ", in ")$([[ $hours > 0 ]] && echo "$hours hours ")$([[ $minutes > 0 ]] && echo "$minutes minutes ")$([[ $seconds > 0 ]] && echo "$seconds seconds")" +[[ $lang == 1 ]] && echo -e "\nSljedeci vakat u $time$(([[ $hours > 0 ]] || [[ $minutes > 0 ]] || [[ $seconds > 0 ]]) && echo ", za ")$([[ $hours > 0 ]] && echo "$hours sati ")$([[ $minutes > 0 ]] && echo "$minutes minuta ")$([[ $seconds > 0 ]] && echo "$seconds sekundi")" From 1d014f2253eec9d87a69b766055fb5f360a59d55 Mon Sep 17 00:00:00 2001 From: hllvc Date: Sat, 1 Jan 2022 20:13:58 +0100 Subject: [PATCH 15/15] updated README.md and installation --- README.md | 14 +++++++++++--- prayertimes.sh | 12 +++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d0f0645..a63b292 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,19 @@ -# [Vaktija.ba](https://vaktija.ba) GNOME Notification +# [Vaktija.ba](https://vaktija.ba) Linux/MacOS Notification ### How to install? + +Additional packages may be needed like +``` +jq +wget +``` + Follow these instructions ``` -/bin/bash -c "$(curl -fsSL \ - https://raw.githubusercontent.com/hllvc/Vaktija.ba-Gnome-Notification/main/prayertimes)" +/bin/bash -c "$(curl -fSsl \ + https://raw.githubusercontent.com/hllvc/Vaktija.ba-Unix-Notifications/master/prayertimes.sh)" ``` + It should download automatically all necessary files and set it up for work. And then run it in terminal with `prayertimes`. diff --git a/prayertimes.sh b/prayertimes.sh index fb18a39..9369e4a 100644 --- a/prayertimes.sh +++ b/prayertimes.sh @@ -1,5 +1,13 @@ #!/bin/bash +if [[ ! -e /usr/local/bin/prayertimes ]]; then + echo "Downloading script.." + sudo wget -O /usr/local/bin/prayertimes https://raw.githubusercontent.com/hllvc/Vaktija.ba-Unix-Notifications/develop/prayertimes.sh + echo "Setting permission.." + sudo chmod a+x /usr/local/bin/prayertimes + exit 2 +fi + os="$(uname)" if [[ $os == Darwin ]]; then @@ -9,6 +17,7 @@ elif [[ $os == Linux ]]; then fi config="$homedir/$USER/.prayerconfig" + url="https://api.vaktija.ba/vaktija/v1" usage () { @@ -106,7 +115,8 @@ while getopts 'hcuesl:' arg; do usage ;; c) - rm $config + sudo rm /usr/local/bin/prayertimes $config + exit 2 ;; u) get_town