forked from andreasgrill/auto-selfcontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/support-selfcontrol-v3'
Adds support for SelfControl 3.0 andreasgrill#45
- Loading branch information
Showing
5 changed files
with
379 additions
and
95 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
*.code-workspace | ||
|
||
# Local History for Visual Studio Code | ||
.history/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"python.pythonPath": "/usr/bin/python", | ||
"python.formatting.provider": "autopep8" | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
# Auto-SelfControl basic command-line interface | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
# Check if auto-selfcontrol was installed through brew and set the config.json location accordingly | ||
if [[ $DIR == /usr/local/* ]]; then | ||
mkdir -p /usr/local/etc/auto-selfcontrol || true | ||
CONFIG_FILE="/usr/local/etc/auto-selfcontrol/config.json" | ||
else | ||
CONFIG_FILE="$DIR/config.json" | ||
fi | ||
|
||
b=$(tput bold) | ||
n=$(tput sgr0) | ||
HELP_TEXT="Auto-SelfControl | ||
Small utility to schedule start and stop times of SelfControl. | ||
Usage: ${b}$(basename "$0") <config|activate|help>${n} | ||
where: | ||
${b}config${n} Open the schedule configuration file in a text | ||
editor to set up weekly parameters | ||
${b}activate${n} Activate the automatic start/stop of SelfControl | ||
according to schedules defined in configuration | ||
${b}help${n} Show this help message | ||
More instructions at https://github.com/andreasgrill/auto-selfcontrol" | ||
|
||
if [[ $1 ]]; then | ||
case "$1" in | ||
# Edit configuration file | ||
config|edit|set|conf*) | ||
# If no "config.json" found | ||
if [[ ! -f $CONFIG_FILE ]]; then | ||
curl -L -s "https://raw.githubusercontent.com/andreasgrill/auto-selfcontrol/master/config.json" -o $CONFIG_FILE | ||
echo "Downloaded sample configuration in $CONFIG_FILE" | ||
fi | ||
echo "Opening $CONFIG_FILE" | ||
# Opening with default editor set as $EDITOR | ||
if [[ $EDITOR ]]; then | ||
$EDITOR $CONFIG_FILE | ||
# Or with default GUI text editor (txt files > Open with...) | ||
else | ||
open -t $CONFIG_FILE | ||
fi | ||
;; | ||
# Install plist config | ||
activate|install) | ||
sudo /usr/bin/python $DIR/auto-selfcontrol.py | ||
exit 0 | ||
;; | ||
-h|--help|help|*) | ||
echo "$HELP_TEXT" | ||
exit 0 | ||
;; | ||
esac | ||
else | ||
echo "$HELP_TEXT" | ||
exit 0 | ||
fi |
Oops, something went wrong.