Last active
September 15, 2024 14:18
-
-
Save tarruda/ec4601f420f0ef0ab7a99d6582f90f0a to your computer and use it in GitHub Desktop.
Shfokus wrapper cron script. See https://github.com/rioastamal/shfokus for more info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get the current hour and minute (24-hour format) | |
current_time=$(date +"%H%M") | |
# Get the current day of the week (1 = Monday, 7 = Sunday) | |
current_day=$(date +"%u") | |
# Check if already blocked | |
if grep -q "shfokus_begin" /etc/hosts; then | |
blocked=true | |
else | |
blocked=false | |
fi | |
# during weekdays, between 09:30 and 17:30, block distracting websites | |
if [ "$current_day" -ge 1 ] && [ "$current_day" -le 5 ] && [ "$current_time" -ge 0930 ] && [ "$current_time" -lt 1730 ]; then | |
if [ "$blocked" = "false" ]; then | |
shfokus.sh -a block | |
fi | |
else | |
if [ "$blocked" = "true" ]; then | |
shfokus.sh -a unblock | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment