-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslack_status.sh
executable file
·57 lines (46 loc) · 1.05 KB
/
slack_status.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /bin/bash
function clear_status() {
/usr/local/opt/curl/bin/curl 'https://slack.com/api/users.profile.set' -X POST -H "Authorization: Bearer $SLACK_PERSONAL_TOKEN" --json @- <<EOF
{
"profile": {
"status_text": "",
"status_emoji": "",
}
}
EOF
}
function set_slack_status() {
echo $STATUS
/usr/local/opt/curl/bin/curl 'https://slack.com/api/users.profile.set' -X POST -H "Authorization: Bearer $SLACK_PERSONAL_TOKEN" --json @- <<EOF
{
"profile": {
"status_text": "$STATUS",
"status_emoji": ":musical_note:",
}
}
EOF
}
. ~/.slack-status
if ! $SLACK_UPDATE_MUSIC_ON; then
exit 0
fi
STATUS=$(osascript -e '
tell application "Music"
if player state = playing then
local status
set status to " 💽 " & album of current track & " 🎤 " & artist of current track as string
local possibleStatus
set possibleStatus to name of current track & status
if length of possibleStatus > 99 then
status
else
possibleStatus
end if
end if
end tell
')
if [[ -z $STATUS ]]; then
clear_status
else
set_slack_status
fi