Last active
May 11, 2020 13:37
-
-
Save geoffreydhuyvetters/e9d80ccc9289458deeb70b7fe6061b8e to your computer and use it in GitHub Desktop.
Focus scripts
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 | |
# https://api.slack.com/legacy/custom-integrations/legacy-tokens | |
slack_legacy_token=<insert-your-token-here> | |
function set_slack_status { | |
curl -s -S -X POST \ | |
-d "token=$1" \ | |
--data-urlencode "profile={\"status_text\": \"Focus time!\", \"status_emoji\": \"🍅\"}" \ | |
https://slack.com/api/users.profile.set | |
} | |
function set_slack_dnd { | |
curl -s -S -X POST \ | |
-d "token=$1" \ | |
--data-urlencode "num_minutes=25" \ | |
https://slack.com/api/dnd.setSnooze | |
} | |
function set_slack_presence { | |
curl -s -S -X POST \ | |
-d "token=$1" \ | |
--data-urlencode "presence=away" \ | |
https://slack.com/api/users.setPresence | |
} | |
# turned it into a function to run for multiple Slack workspaces | |
function slack { | |
set_slack_status $1 | |
set_slack_dnd $1 | |
set_slack_presence $1 | |
} | |
# Focus changes the already open 'forbidden' tabs to a tab with the name 'Focus', let's clean those up | |
function close_focus_tabs { | |
osascript <<-EOF | |
set closeTab to "Focus" as string | |
tell application "Chrome" | |
close (every tab of window 1 whose name is equal to closeTab) | |
end tell | |
EOF | |
} | |
function open_spotify { | |
cd /Applications | |
open Spotify.app | |
} | |
open_spotify | |
close_focus_tabs | |
slack $slack_legacy_token |
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 | |
# https://api.slack.com/legacy/custom-integrations/legacy-tokens | |
slack_legacy_token=<insert-your-token-here> | |
function set_slack_status { | |
curl -s -S -X POST \ | |
-d "token=$1" \ | |
--data-urlencode "profile={\"status_text\": \"\", \"status_emoji\": \"\"}" \ | |
https://slack.com/api/users.profile.set | |
} | |
function set_slack_dnd { | |
curl -s -S -X POST \ | |
-d "token=$1" \ | |
https://slack.com/api/dnd.endDnd | |
} | |
function set_slack_presence { | |
curl -s -S -X POST \ | |
-d "token=$1" \ | |
--data-urlencode "presence=auto" \ | |
https://slack.com/api/users.setPresence | |
} | |
# turned it into a function to run for multiple Slack workspaces | |
function slack { | |
set_slack_status $1 | |
set_slack_dnd $1 | |
set_slack_presence $1 | |
} | |
function pause_spotify { | |
osascript <<-EOF | |
tell application "Spotify" to pause | |
EOF | |
} | |
function open_slack { | |
cd /Applications | |
open Slack.app | |
} | |
function open_spark { | |
cd /Applications | |
open Spark.app | |
} | |
pause_spotify | |
open_slack | |
open_spark | |
slack $slack_legacy_token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment