Created
June 17, 2020 09:20
-
-
Save ianmiell/b11ab953e22105ef1f81bb363693fce0 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# 0 * * * * /Users/imiell/git/work/bin/home/slack_start_stop.sh start | |
# 3-59 * * * * /Users/imiell/git/work/bin/home/slack_start_stop.sh stop | |
DO_START=0 | |
DO_STOP=0 | |
while [ "$1" != "" ]; do | |
case $1 in | |
start) DO_START=1;; | |
stop) DO_STOP=1;; | |
*) echo '?' && exit 1;; | |
esac | |
shift | |
done | |
if [[ "${DO_STOP}" == "1" ]] | |
then | |
FOREGOUNDED_APP=$(osascript -e 'tell application "System Events"' -e 'set frontApp to name of first application process whose frontmost is true' -e 'end tell') | |
if [[ ${FOREGOUNDED_APP} == 'Slack' ]] | |
then | |
exit | |
else | |
killall Slack | |
fi | |
exit 0 | |
fi | |
if [[ "${DO_START}" == "1" ]] | |
then | |
open /Applications/Slack.app | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment