Skip to content

Instantly share code, notes, and snippets.

@colby
Last active August 29, 2015 14:11
Show Gist options
  • Save colby/7eab42879b6071a8dd07 to your computer and use it in GitHub Desktop.
Save colby/7eab42879b6071a8dd07 to your computer and use it in GitHub Desktop.
Lunch time script and time tracker function
#!/bin/bash
# You need to enter your own Slack API token
API_TOKEN="<TOKEN>"
API_URL="https://slack.com/api/presence.set"
source "$HOME/.dotfiles/.conf.d/10-work_related"
now "Taking lunch break"
# Set Slack away if running
if pgrep Slack; then
curl --data "token=${API_TOKEN}&presence=away" ${API_URL}
fi
# Set adium away if running
if pgrep adium;then
osascript <<EOD
tell application "Adium"
go away with message "Taking my lunch break."
end tell
EOD
fi
# Start screensaver
osascript <<EOD
tell application "System Events"
start current screen saver
end tell
EOD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment