feat:spr plugin
This is based on the creation of spotify-player widget for the spotify-player app based on #336
There is also a remote option but it has some issues with latency and needs the daemon to be installed but limits the refresh rate on the display widget.
๐ Walkthrough
Walkthrough
Adds a new "spr" Spotify plugin: docs TOC and section in docs/CONFIG.md, a plugin case in scripts/dracula.sh, and a new scripts/spr.sh that queries spotify_player for playback, formats/truncates and caches output, and optionally binds tmux keys for remote control.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Docs: plugin entrydocs/CONFIG.md |
Inserted spr into Plugins TOC and added a new spr documentation section (usage, dependency spotify-player, refresh-rate note removed from mac-player), and declared public config options: @dracula-spr-play-icon, @dracula-spr-pause-icon, @dracula-spr-remote, @dracula-spr-remote-play-pause, @dracula-spr-remote-back, @dracula-spr-remote-next. |
Main plugin loaderscripts/dracula.sh |
Added "spr" case to plugin selection; reads @dracula-spr-colors (default "green dark_gray") and sets execution to ./scripts/spr.sh. |
New plugin implementationscripts/spr.sh |
Added new Bash script that queries spotify_player for playback JSON, parses play/pause and track info, truncates long strings, caches output per refresh rate to reduce lag, verifies spotify_player presence, and binds/unbinds tmux keys for play/pause/prev/next remote control. |
Sequence Diagram(s)
sequenceDiagram
participant Tmux
participant dracula.sh
participant spr.sh
participant spotify_player
Tmux->>dracula.sh: request status (plugin="spr")
dracula.sh->>spr.sh: execute
spr.sh->>spotify_player: get key playback
spotify_player-->>spr.sh: JSON playback info
spr.sh->>spr.sh: parse, format, truncate, cache
spr.sh-->>Tmux: formatted track line
alt remote control enabled
Tmux->>spr.sh: keypress (play/pause/next/back)
spr.sh->>spotify_player: send control command
end
Estimated code review effort
๐ฏ 2 (Simple) | โฑ๏ธ ~8 minutes
Possibly related PRs
- dracula/tmux#343 โ Adds a media-player plugin with similar functions (trackStatus, sliceTrack) and remote-control keybinding logic; likely closely related.
Suggested reviewers
- ethancedwards8
[!TIP]
๐ Remote MCP (Model Context Protocol) integration is now available!
Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.
๐ Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro
๐ก Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these settings in your CodeRabbit configuration.
๐ฅ Commits
Reviewing files that changed from the base of the PR and between 0aa155d2031e83bd9ccc16a1d1f5449af7bef797 and 7cf2f55cc74abd875b032ccadea8e807e193abab.
๐ Files selected for processing (1)
scripts/spr.sh(1 hunks)
๐ง Files skipped from review as they are similar to previous changes (1)
- scripts/spr.sh
โจ Finishing Touches
- [ ] ๐ Generate Docstrings
๐งช Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
๐ชง Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
hi, im sorry for the long wait. currently im rarely using macos, so i dont really get to install and test fancy things on it. ill try not to keep you waiting for too long anymore
The spotify_player tui supports various linux distributions is not only for macos. If you have cargo installed you can install it seemlessly.
is it normal for the tmux session to switch to a blank screen till you press enter when trying to use the remote control feature? i guess that would be OK for an experimental feature, but maybe it's also just a mistake on my end?
besides it's displaying well! formatting options like there used to be with spotify-tui would be cool, but not a must (set -g @dracula-spotify-tui-format "%f %s %t - %a")
is it normal for the tmux session to switch to a blank screen till you press enter when trying to use the remote control feature?
I just noticed that and will try to solve this issue.
is it when you do the 'R' remote command? Oh cause I just noticed that when you use the 'R' keybind, it displays the osascript mac player command so I'll do a slight patch on the mac-player plugin for the remote feature which was previously like this.
# Remote Access
if [[ "$REMOTE_ACCESS" == true ]]; then
remoteControl "$PLAY_PAUSE_BUTTON" "$BACK_BUTTON" "$NEXT_BUTTON" "$REMOTE_APP"
fi
then add a guard to prevent the commands from leaking to other commands in tmux. my bad :p .
if [[ "$REMOTE_ACCESS" == "true" ]]; then
# Remote Control Buttons Customizations
PLAY_PAUSE_BUTTON=$(get_tmux_option "@dracula-mac-player-remote-play-pause" "P")
BACK_BUTTON=$(get_tmux_option "@dracula-mac-player-remote-back" "R")
NEXT_BUTTON=$(get_tmux_option "@dracula-mac-player-remote-next" "N")
remoteControl "$PLAY_PAUSE_BUTTON" "$BACK_BUTTON" "$NEXT_BUTTON" "$REMOTE_APP"
else
tmux set -g @dracula-mac-player-remote-play-pause ""
tmux set -g @dracula-mac-player-remote-back ""
tmux set -g @dracula-mac-player-remote-next ""
fi
besides it's displaying well! formatting options like there used to be with spotify-tui would be cool, but not a must (set -g >@dracula-spotify-tui-format "%f %s %t - %a")
for the formatting options, I was finding ways to store the fields separately to the formatting options like in spotify-tui cause spotify-player doesn't provide the formatting options. The data they expose is in json but I'll figure something out.
so I found out that I was solving another error based on the mac-player where spotify does not have a back track option in applescript.
For the terminal going blank issue, I researched and found out the tui commands creates an exit command that leads to tmux showing a blank page.
I've added this prefix > /dev/null 2>&1 so that it doesnt output anything but makes tmux freeze for a bit then it works on my end.
Feel free to test on it :)
and also polished up the remote control issues and still working on the formatting options.
i don't have spotify premium anymore, but this looks good to me, so i'll merge it. thank you for your efforts and patience! feel free to send in patches if you feel like i merged to early and you want to add something
yeah for sure I'll patch for any issues relating to the plugin and also I've found a solution to the formatting feature and will present it soon :)