Slack-fm is a tiny self-hosted service that automatically updates your Slack status from your Last.fm profile. It updates your Slack status when all the following conditions are met:
- the user is not set to "away"
- a custom status hasn't been set
- something is now playing on Last.fm
- the time is between 9am and 5pm (configurable)
- it's not a weekend (configurable)
To clear the status it will search Last.fm for the now playing tracks duration and use that as the status expiration time. If there is no duration information it defaults to a 10 minute expiration (configurable).
It looks like this:
- Last.fm API key (get one here)
- Last.fm username (this is probably your own username!)
- Slack "legacy" token (get one here)
All configuration is available via environment variables. Values without defaults are required.
Variable | Default | Description |
---|---|---|
LAST_FM_KEY |
Access to Last.fm data | |
LAST_FM_USERNAME |
Which user to get track info for | |
SLACK_TOKEN |
Personal "legacy" token for updating your Slack status | |
SLACK_EMOJI |
:headphones: |
Specify which emoji to use in the status |
SLACK_SEPARATOR |
• |
Specify which character to use as a separator between the track name and artist |
TZ |
UTC |
Set the timezone |
ACTIVE_HOURS_START |
8 |
The hour of the day to start updating your Slack status |
ACTIVE_HOURS_END |
18 |
The hour of the day to stop updating your Slack status |
UPDATE_INTERVAL |
1 |
The time in minutes to wait until updating your Slack Status |
UPDATE_WEEKENDS |
undefined |
Provide any value to enable status updates during the weekend |
UPDATE_EXPIRATION |
10 |
The time in minutes to use as a default status expiration length |
SENTRY_DSN |
undefined |
Optionally provide a Sentry DSN to enable error reporting |
ENABLE_LOGGING |
undefined |
Enable verbose console output |
I designed this to be easily self hosted, just use the Docker image! It's automatically built and versioned on Docker Hub based on GitHub activity.
docker run \
-e SLACK_TOKEN=<YOUR_SLACK_TOKEN> \
-e LAST_FM_KEY=<YOUR_LAST_FM_KEY> \
-e LAST_FM_USERNAME=<LAST_FM_USERNAME> \
-e TZ=<YOUR_TIMEZONE> \
jckcthbrt/slack-fm:latest
version: '3.7'
services:
slack_fm:
image: jckcthbrt/slack-fm:latest
container_name: slack_fm
restart: unless-stopped
environment:
TZ: <YOUR_TIMEZONE>
SLACK_TOKEN: <YOUR_SLACK_TOKEN>
LAST_FM_KEY: <YOUR_LAST_FM_KEY>
LAST_FM_USERNAME: <LAST_FM_USERNAME>
docker-compose up
This should be relatively simple to set up and run, all that's required is Node v12 and some environment variables.
- Fork this repository and clone your version
- Install dependencies with
npm install
- Run the tests with
npm test
- Set up your environment variables as above (direnv is great for this)
- Start the app locally with
npm start
- Commit and push your changes then submit a PR back to this repository