Created
January 10, 2017 10:59
-
-
Save harryi3t/f5f98f13a67ff8b9710fd6dba297b5a5 to your computer and use it in GitHub Desktop.
set the slack status as away on screen lock and back to active on screen unlock
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 | |
TOKEN='put your token here. Get a new from https://api.slack.com/docs/oauth-test-tokens' | |
dbus-monitor --session type='signal',interface='com.canonical.Unity.Session' | while true | |
do | |
read x | |
if echo "$x" | grep -q Locked; then | |
echo "set yourself away at $(date)" | |
curl -X GET -H "Cache-Control: no-cache" "https://slack.com/api/users.setPresence?token=$TOKEN&presence=away" | |
elif echo "$x" | grep -q Unlocked; then | |
echo "set yourself active at $(date)" | |
curl -X GET -H "Cache-Control: no-cache" "https://slack.com/api/users.setPresence?token=$TOKEN&presence=auto" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can't - dbus is Linux specific. You would need to work out how you can detect presence in Mac.