Pomodoro + Super DND from Slack


I’m fund of pomodoro technique when I’ve to focus on some task, mainly coding or writing.

I’m a mac owner, and I found an handy app called Timer (that you can build for free from github) and has nice integrations with calendar and the possibility to run scripts (apple scripts)

Thus, since I don’t want to be disturbed I user the Script to:

  • Set the DND on slack
  • Set the status of slack to “working on a pomodoro”
  • (extra: stop spotify when the pomodoro is over)

This is good, the only problem is that Slack keeps showing red badges even if you are on DND. To avoid this you have to disable the badge icon app from notification menu. After a long time I found out how to do it (asking on AppleStackExchange)

The result of my script are


set appName to "Slack"
if running of application "System Preferences" then
   quit application "System Preferences"
   delay 1
end if
tell application "System Preferences"
   set the current pane to pane id "com.apple.preference.notifications"
   delay 1
   tell application "System Events"
     tell table 1 of scroll area 1 of window 1 of application process "System Preferences"
     repeat with i from 1 to (count rows)
       if value of static text 1 of group 1 of UI element 1 of row i is appName then
         select row i
         exit repeat
       end if
     end repeat
     end tell
     delay 0.2
       click checkbox "Badge app icon" of group 1 of window 1 of application process "System Preferences"
   end tell
  quit
end tell

do shell script "curl 'https://slack.com/api/dnd.setSnooze?token=THE_SLACK_TOKEN&num_minutes=$duration'"
do shell script "curl --data 'token=THE_SLACK_TOKEN&profile=%7B%22status_text%22%3A%22working%20on%20a%20pomodoro%20%22%2C%22status_emoji%22%3A%22%3Atomato%3A%22%7D' https://slack.com/api/users.profile.set"

and when ends I remove status, DND and stop spotify


if application "Spotify" is running then
tell application "Spotify"
pause

end tell
end if
do shell script "curl https://slack.com/api/dnd.endSnooze?token=THE_SLACK_TOKEN"
do shell script "curl --data 'token=THE_SLACK_TOKEN&profile=%7B%0A%20%20%20%20%22status_text%22%3A%20%22%22%2C%0A%20%20%20%20%22status_emoji%22%3A%20%22%22%0A%7D' https://slack.com/api/users.profile.set"

Annunci

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...