Skip to content

Instantly share code, notes, and snippets.

@Rami-Majdoub
Last active September 13, 2022 12:48
Show Gist options
  • Save Rami-Majdoub/7b5d171989470f4db623e10be47062c1 to your computer and use it in GitHub Desktop.
Save Rami-Majdoub/7b5d171989470f4db623e10be47062c1 to your computer and use it in GitHub Desktop.
Time reminder

Warning the script will run the next time you start the device

# download script
curl https://gist.githubusercontent.com/Rami-Majdoub/7b5d171989470f4db623e10be47062c1/raw/92ee98501fe130ba86b32096ee59c72d6f0066df/time_reminder.sh > ~/time_reminder.sh

# make script runnable
chmod +x ~/time_reminder.sh

# autostart
printf "[Desktop Entry]
Type=Application
Exec=bash ~/time_reminder.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=Time reminder
Name=Time reminder
Comment[en_US]=
Comment=" >> ~/.config/autostart/time_reminder.desktop
#!/bin/bash
# why 10#$val : https://stackoverflow.com/questions/24777597/value-too-great-for-base-error-token-is-08
# mod : https://medium.com/@kauereinbold/mod-operator-on-bash-34e4d7d3b086
declare -r SECOND=1
declare -r MINUTE=60
declare -r HOUR=3600
declare -r CHECK_INTERVAL=$(( 5 * $MINUTE ))
hours="date +%H"
minutes="date +%M"
seconds="date +%S"
while true
do
# REPEAT_INTERVAL
# remaining_time=$(( 10 * $SECOND ))
# remaining_time=$(( 1 * $MINUTE - 10#$($seconds) * $SECOND ))
# remaining_time=$(( 1 * $HOUR - 10#$($minutes) * $MINUTE - 10#$($seconds) ))
# Method 2
# remaining_time=$(( (1 - $(expr $($minutes)) % 1 + 0) * $MINUTE - 10#$($seconds) ))
remaining_time=$(( 1 * $HOUR - 10#$($minutes) * $MINUTE - 10#$($seconds) ))
# echo "$remaining_time"
# replace with while true
while [ "$remaining_time" -gt "$CHECK_INTERVAL" ]
do
# echo "sleeping for $CHECK_INTERVAL sec"
sleep $CHECK_INTERVAL
remaining_time=$(( 1 * $HOUR - 10#$($minutes) * $MINUTE - 10#$($seconds) ))
# echo "$remaining_time"
done
# echo "sleeping for $remaining_time sec"
sleep $remaining_time
notify-send "Time check" "it is $($hours)" -t 60000 -u critical
done
@Rami-Majdoub
Copy link
Author

it works until you suspend the device

@Rami-Majdoub
Copy link
Author

it works until you suspend the device

fixed

@Rami-Majdoub
Copy link
Author

Screenshot from 2022-07-29 15-00-02

Warning
the script will run the next time you start the device

# download script
curl https://gist.githubusercontent.com/Rami-Majdoub/7b5d171989470f4db623e10be47062c1/raw/92ee98501fe130ba86b32096ee59c72d6f0066df/time_reminder.sh > ~/time_reminder.sh

# make script runnable
chmod +x ~/time_reminder.sh

# autostart
printf "[Desktop Entry]
Type=Application
Exec=bash ~/time_reminder.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=Time reminder
Name=Time reminder
Comment[en_US]=
Comment=" >> ~/.config/autostart/time_reminder.desktop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment