Advertisement
miamondo

rtc.sh

Dec 14th, 2021 (edited)
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.58 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #Copyright © 2021 Benoît Boudaud https://miamondo.org/contact
  4. #This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
  5. # License as published by the Free Software Foundation, either version 3 of the License, or any later version.
  6.  
  7. #This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
  8. # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  9. # You should have received a copy of the GNU General Public License along with this program.
  10. # If not, see <http://www.gnu.org/licenses/>
  11.  
  12. # ----------------------------------------------------------------------------------------------------------------------
  13.  
  14. warning=$(date -d "23:55" +%s) # Correspond à l'heure d'apparition du message : 23:55 tous les jours
  15. time_before_warning=$[$warning - $(date +%s)] # Calcul du temps restant avant le message d'avertissement.
  16.  
  17. if [ $time_before_warning -lt 0 ] # Si le temps restant est négatif, cela signifie que l'avertissement est passé.
  18. then # Alors, on rajoute un jour (86400 secondes) et on recalcule.
  19.     time_before_warning=$[($warning+86400) - $(date +%s)]
  20. fi
  21.  
  22. sleep $time_before_warning # Le script se met en pause jusqu'au message d'avertissement.
  23.  
  24. # Puis, à l'heure convenue, il ouvre la fenêtre popup.
  25.  
  26. /home/$USER/Documents/Informatique/Linux/Bash/Codes/rtc/rtc.py
  27.  
  28. # ----------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement