Last active
September 1, 2022 15:00
-
-
Save mrballcb/1a3c6c293e26d7c44d082270de625599 to your computer and use it in GitHub Desktop.
Helper script for lungo on MacOS
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
Usage: | |
# Both of these will activate lungo for 10 hours | |
lungo 10 hours | |
lungo hours=10 | |
# Both of these will toggle lungo off if it's on, or on indefinitely if it was off | |
lungo toggle | |
lungo | |
# This doesn't look like it should work to deactivate, but it does. Dunno why | |
lungo deactivate | |
# Scripting explanations from website: | |
https://sindresorhus.com/lungo#scripting |
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
#!/usr/bin/env bash | |
set -euo pipefail | |
CLIARGS=${1-toggle} | |
if [[ $CLIARGS =~ (hours|minutes)= ]]; then | |
# Passed "hours=NN" (native) format | |
ARGS="activate?$CLIARGS" | |
elif [[ $CLIARGS =~ [[:digit:]]+ ]] && [[ $2 =~ hours|minutes ]]; then | |
# Passed "NN hours" format | |
ARGS="activate?$2=$1" | |
else | |
# Hope user passed in correct arg for lungo. | |
# Lungo ignores any arg it doesn't understand, so is not fatal. | |
ARGS=$CLIARGS | |
fi | |
open --background "lungo:$ARGS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment