-
Notifications
You must be signed in to change notification settings - Fork 346
feat:spr plugin #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:spr plugin #344
Changes from 8 commits
07d6d71
3f8655f
38f3121
a7fcc6f
c77118b
c155992
f65a4e1
170a73c
c90405d
308b3c3
c6c13e4
90ed44e
0dce28c
7625de4
69f1089
0aa155d
7cf2f55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
|
@@ -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. | ||
|
|
@@ -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 | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### 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 "❚❚ " | ||
|
|
||
| ``` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainDocument spr colors (and verify max-length option).
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: Length of output: 2337 Document spr colors and max-length option (verified) Confirmed option names; please add docs for colors and max-length.
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"): 🤖 Prompt for AI Agents |
||
|
|
||
| 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. | ||
|
|
||
| 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 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this change intentional?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
-gtoremote-gwhich i think would be considered illegal syntax. hence the question of whether this is intentional. sorry for having been so unclear