A Simple Shell Script for Eye Care Reminder
For those who spend long hours in front of screens, taking regular breaks is crucial. Here's a useful shell script that serves as an eye-care reminder by displaying a custom alert and sound notification every 30 minutes.
Creating the Script
To set up this reminder, you'll need to create a shell script. Open your terminal and type:
touch ~/scriptname.sh
Once the script file is created, open it in your preferred text editor and paste the following script:
#!/bin/bash
export DISPLAY=:0.0
export XDG_RUNTIME_DIR="/run/user/1001"
/usr/bin/mplayer -really-quiet /home/xxx/Music/111.mp3 -volume 100
/usr/bin/pqiv -c -i /home/xxx/Pictures/123123.png
sleep 100
killall pqiv
This script uses mplayer
to play a sound and pqiv
to show an overlay image. Ensure you replace /home/xxx/Music/111.mp3
and /home/xxx/Pictures/123123.png
with the correct paths to your audio and image files.
Automating with Crontab
To automate this script to run at your preferred interval, such as every 30 minutes, use crontab
. In your terminal, execute:
crontab -e
This will open a text editor where you can schedule tasks. Add the following line to schedule your script to run every half hour:
*/30 * * * * /path/to/yourscript/scriptname.sh
Make sure to replace /path/to/yourscript/scriptname.sh
with the full path to your script.
Additional Notes
- The
pqiv
tool is needed to properly display the transparent overlay. Ensure it's installed on your system. - This reminder script helps maintain your eye health by encouraging screen breaks.
For more details and community contributions, check the discussion on Reddit.