Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- [playerctl](#playerctl---up)
- [ram-usage](#ram-usage---up)
- [spotify-tui](#spotify-tui---up)
- [spr](#spr---up)
- [ssh-session](#ssh-session---up)
- [synchronize-panes](#synchronize-panes---up)
- [sys-temp](#sys-temp---up)
Expand Down Expand Up @@ -516,6 +517,7 @@ set -g @dracula-kubernetes-eks-extract-account true
This script retrieves and displays continuous glucose monitoring (CGM) data from the LibreView API.
It caches the data to minimize API requests and displays the latest glucose level along with a trend indicator in a Tmux status bar.


### mac-player - [up](#table-of-contents)

This widget and script displays music information provided by the native macOS players.
Expand Down Expand Up @@ -713,8 +715,49 @@ To limit the maximum length (0 means unlimited length):
set -g @dracula-spotify-tui-max-len 30
```


`set remote-g @dracula-refresh-rate 5` affects this widget
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I noticed that the when I place like a refresh rate lke 2, the presentation was faster. Maybe it's an issue with my current installation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the refresh rate option is essentially a sleep statement, lower numbers should yield less delay between the refreshes, so what you say makes sense. however, im am a little confused as to why you changed the flag from -g to remote-g which i think would be considered illegal syntax. hence the question of whether this is intentional. sorry for having been so unclear


### spr - [up](#table-of-contents)

This widget displays music information provided by [spotify-player](https://github.com/aome510/spotify-player). spotify-player must be installed to use this widget.

NOTE: `set -g @dracula-refresh-rate 5` affects this widget

To change player icons:

```bash
set -g @dracula-spr-play-icon "♪ "
set -g @dracula-spr-pause-icon "❚❚ "

```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Document spr colors (and verify max-length option).

  • Consider adding the standard colors override example for spr to keep docs consistent with other plugins.
  • The implementation reportedly supports truncation/max length. If there is a tmux option for this (e.g., @dracula-spr-max-len), please document it here.

Proposed doc additions (colors are safe; max-len requires verifying the exact option name):

 ### spr - [up](#table-of-contents)

 This widget displays music information provided by [spotify-player](https://github.com/aome510/spotify-player). spotify-player must be installed to use this widget.

 NOTE: `set -g @dracula-refresh-rate 5` affects this widget

 To change player icons:
@@
 set -g @dracula-spr-pause-icon "❚❚ "

+# Optionally set background/foreground colors:
+# default available colors: white, gray, dark_gray, light_purple, dark_purple, cyan, green, orange, red, pink, yellow
+# set -g @dracula-spr-colors "[background] [foreground]"
+set -g @dracula-spr-colors "green dark_gray"
+
+# To limit the maximum length (0 means unlimited length):
+# NOTE: verify the exact option name in scripts/spr.sh before documenting.
+# set -g @dracula-spr-max-len 30


To confirm the exact option name for max length, run:

---

🏁 Script executed:

```shell
#!/bin/bash
# Find all documented tmux options related to spr
rg -n '@dracula-spr' -A 2

# Also look for "max" or "len" around spr to spot the length option
rg -n '(max|len)' scripts/spr.sh -A 3 -B 3 || true

Length of output: 2337


Document spr colors and max-length option (verified)

Confirmed option names; please add docs for colors and max-length.

  • scripts/spr.sh — MAX_LENGTH="$(get_tmux_option "@dracula-spr-length" 25)" (line ~80) — default 25
  • scripts/dracula.sh — get_tmux_option "@dracula-spr-colors" "green dark_gray" (line ~282) — default "green dark_gray"
  • Edit docs/CONFIG.md around the spr widget (near lines 730–733) to include these options

Suggested doc diff to apply:

 ### spr - [up](#table-of-contents)

 This widget displays music information provided by [spotify-player](https://github.com/aome510/spotify-player). spotify-player must be installed to use this widget.

 NOTE: `set -g @dracula-refresh-rate 5` affects this widget

 To change player icons:
@@
 set -g @dracula-spr-pause-icon "❚❚ "

+# Optionally set background/foreground colors (default: "green dark_gray"):
+set -g @dracula-spr-colors "green dark_gray"
+
+# To limit the maximum text length shown (0 = unlimited). Default is 25:
+set -g @dracula-spr-length 30


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
### spr - [up](#table-of-contents)

This widget displays music information provided by [spotify-player](https://github.com/aome510/spotify-player). spotify-player must be installed to use this widget.

NOTE: `set -g @dracula-refresh-rate 5` affects this widget

To change player icons:

🤖 Prompt for AI Agents
In docs/CONFIG.md around lines 721–733 (the spr widget section), add
documentation for the spr color and max-length options: document
@dracula-spr-colors with its default value "green dark_gray" and note it sets
background/foreground colors for the widget, and document @dracula-spr-length
with default 25 (explain 0 = unlimited) and that it limits the displayed text
length; include example set -g lines matching the repo naming
(@dracula-spr-colors and @dracula-spr-length) and a short note about the
defaults.


This section includes an experimental remote control feature, but it may limit the widget’s display on macOS.

In order to utilize the remote feature you need to install the [spotify-player-daemon](https://github.com/aome510/spotify-player#daemon)
To activate the remote:

```bash
set -g @dracula-spr-remote true
```

The default keybinds are:

- `<prefix> + P` - Play/Pause
- `<prefix> + R` - Back to position 0/previous track
- `<prefix> + N` - Next track

To change the keybinds:

```bash
set -g @dracula-spr-remote-play-pause "P"
set -g @dracula-spr-remote-back "R"
set -g @dracula-spr-remote-next "N"
```

`set -g @dracula-refresh-rate 5` affects this widget


### ssh-session - [up](#table-of-contents)

This widget displays the current username@host combination, both of the local machine as well as when connected via ssh.
Expand Down
4 changes: 4 additions & 0 deletions scripts/dracula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ main() {
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-mpc-colors" "green dark_gray")
script="#($current_dir/mpc.sh)"

elif [ $plugin = "spr" ]; then
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-spr-colors" "green dark_gray")
script="#($current_dir/spr.sh)"

elif [ $plugin = "spotify-tui" ]; then
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-spotify-tui-colors" "green dark_gray")
script="#($current_dir/spotify-tui.sh)"
Expand Down
116 changes: 116 additions & 0 deletions scripts/spr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env bash

export LC_ALL=en_US.UTF-8

current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$current_dir/utils.sh"


function trackStatus() {
local pause_icon="$1" play_icon="$2"
local track_info playback status track_result

playback=$(spotify_player get key playback)


status=$(echo "$playback" | jq -r '.["is_playing"]')
track_info=$(echo "$playback" | jq -r '.item | "\(.artists | map(.name) | join(", ")) - \(.name)"')
track_result=""

if [[ $status == true ]]; then
track_result+=$play_icon
track_result+=$track_info
else
track_result+=$pause_icon
track_result+=$track_info
fi

case "$status" in
"null") echo "spotify not running" ;;
*) echo "$track_result" ;;
esac

}

function sliceTrack()
{
local str="$1"
local std="$2"
local len=${#str}

local result=""

if [[ $len > $std ]]; then
result="${str:0:$std}"
result+="..."
else
result=$str
fi

echo "$result"
}


function remoteControl() {
local toggle_button="$1"
local back_button="$2"
local next_button="$3"

local toggle="spotify_player playback play-pause"
local back="spotify_player playback previous"
local next="spotify_player playback next"


tmux unbind-key "$toggle_button"
tmux unbind-key "$back_button"
tmux unbind-key "$next_button"

tmux bind-key "$toggle_button" run-shell "$toggle"
tmux bind-key "$back_button" run-shell "$back"
tmux bind-key "$next_button" run-shell "$next"

}

main() {
# save buffer to prevent lag
local cache_file="/tmp/tmux_spr_cache"

RATE=$(get_tmux_option "@dracula-refresh-rate" 5)

MAX_LENGTH=$(get_tmux_option "@dracula-spr-length" 25)

# Remote Control checker
REMOTE_ACCESS=$(get_tmux_option "@dracula-spr-remote" false)

PLAY_ICON=$(get_tmux_option "@dracula-spr-play-icon" "♪ ")
PAUSE_ICON=$(get_tmux_option "@dracula-spr-pause-icon" "❚❚ ")

# Remote Control Buttons Customizations
PLAY_PAUSE_BUTTON=$(get_tmux_option "@dracula-spr-remote-play-pause" "P")
BACK_BUTTON=$(get_tmux_option "@dracula-spr-remote-back" "R")
NEXT_BUTTON=$(get_tmux_option "@dracula-spr-remote-next" "N")

if ! command -v spotify_player &> /dev/null
then
exit 1
fi

# Remote Access
if [[ "$REMOTE_ACCESS" == true ]]; then
remoteControl "$PLAY_PAUSE_BUTTON" "$BACK_BUTTON" "$NEXT_BUTTON"
else
tmux unbind-key "$PLAY_PAUSE_BUTTON"
tmux unbind-key "$BACK_BUTTON"
tmux unbind-key "$NEXT_BUTTON"
fi

if [ ! -f "$cache_file" ] || [ $(($(date +%s) - $(stat -f%c "$cache_file"))) -ge "$RATE" ]; then
trackStatus "$PAUSE_ICON" "$PLAY_ICON" > "$cache_file"
sliceTrack "$(cat $cache_file)" "$MAX_LENGTH" > "$cache_file"
fi

cat "$cache_file"
}

main