From 07d6d7189e07b7a4508ff260e9361903abb731e4 Mon Sep 17 00:00:00 2001 From: bernie-haxx Date: Thu, 29 May 2025 17:11:59 +0300 Subject: [PATCH 01/15] feat:spr plugin --- docs/CONFIG.md | 141 ++++++++++++++++++++++++++++++++++++++++++++- scripts/dracula.sh | 4 ++ scripts/spr.sh | 112 +++++++++++++++++++++++++++++++++++ 3 files changed, 255 insertions(+), 2 deletions(-) create mode 100755 scripts/spr.sh diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 2cf16b22..6d3d0eca 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -1,6 +1,7 @@ # [tmux](https://github.com/tmux/tmux/wiki) ## Table of Contents + - [Configuration](#Configuration---up) - [Status bar options](#status-bar-options---up) - [Powerline](#powerline---up) @@ -29,6 +30,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) @@ -87,6 +89,7 @@ set -g @dracula-show-empty-plugins false ``` ### Powerline - [up](#table-of-contents) + Enable powerline symbols ```bash @@ -94,6 +97,7 @@ set -g @dracula-show-powerline true ``` Enable edge icons + ```bash set -g @dracula-show-edge-icons true ``` @@ -118,6 +122,7 @@ set -g @dracula-inverse-divider  ``` ### Left Icon - [up](#table-of-contents) + - The left icon can be set to anything static you'd like. - However if you use tmux on multiple machines, it may be helpful to display the hostname. - If you use multiple sessions simultaneously it can be good to name them and have the name in the left icon. @@ -143,6 +148,7 @@ more formats can be found here, though those without a shorthand like #H need to besides formats, any other string can be used. additionally the left icons padding can be set like so: + ```bash # default is 1, it can accept any number and 0 disables padding. set -g @dracula-left-icon-padding 1 @@ -157,7 +163,9 @@ This allows for the use of custom themes like catppuccin or gruvbox. For everything regarding colors, please refer to [the color theming directory](/docs/color_theming/README.md). ## Plugins + ### attached-clients - [up](#table-of-contents) + This widget provides the number of clients attached to the current tmux session. Set the minimum number of clients to show (otherwise, show nothing) @@ -174,9 +182,11 @@ set -g @dracula-clients-plural clients ``` ### battery - [up](#table-of-contents) + This widget provides information about the current charge of the battery, whether it is attached to a powersupply and charging from it, or running off the powersupply without charging. it also detects desktop pcs having no battery. Display any icon for the battery you'd like with: + ```bash set -g @dracula-battery-label "♥ " ``` @@ -202,10 +212,11 @@ set -g @dracula-no-battery-label " " ``` ### compact-alt - [up](#table-of-contents) + This widget allows the user to switch to an alternate list of widgets when the terminal becomes narrow. Switching only works if the widget is added to `set -g @dracula-plugins "your-plugins-here"`. -to set what widgets should be shown in narrow mode, set the following variable. *make sure to include the compact-alt widget as you won't be able to switch out of narrow mode otherwise.* +to set what widgets should be shown in narrow mode, set the following variable. _make sure to include the compact-alt widget as you won't be able to switch out of narrow mode otherwise._ ```bash set -g @dracula-narrow-plugins "compact-alt battery network weather" @@ -242,6 +253,7 @@ set -g @dracula-narrow-mode some-value ### continuum - [up](#table-of-contents) Set the output mode. Options are: + - **countdown**: Show a T- countdown to the next save (default) - **time**: Show the time since the last save - **alert**: Hide output if no save has been performed recently @@ -258,6 +270,7 @@ set -g @dracula-continuum-time-threshold 60 ``` Other options. + ```bash @dracula-continuum-first-save @resurrect-dir @@ -266,110 +279,136 @@ Other options. ``` ### cpu-arch - [up](#table-of-contents) + This widget displays the cpu architecture. possible nerdfont settings for cpu arch label: + ```bash set -g @dracula-cpu-arch-label "󰍛 " ``` ### cpu-usage - [up](#table-of-contents) + This widget displays the cpu usage in percent by default, but can display cpu load on linux. Load average – is the average system load calculated over a given period of time of 1, 5 and 15 minutes (output: x.x x.x x.x) + ```bash set -g @dracula-cpu-display-load true ``` possible nerdfont settings for cpu usage label: + ```bash set -g @dracula-cpu-usage-label " " ``` nerdfont icons to consider: + ```bash    󰍛 󰘚 󰻟 󰻠 ``` `set -g @dracula-refresh-rate 5` affects this widget + ### cwd - [up](#table-of-contents) + This widget displays the path of the current working directory, where the path of the users home directory will be shortened to `~`. The maximum number of directories and number of characters used for that is unlimited by default, but can be set with the following two options: + ```bash set -g @dracula-cwd-max-dirs "0" set -g @dracula-cwd-max-chars "0" ``` + ### fossil - [up](#table-of-contents) + **TODO** + ### git - [up](#table-of-contents) + This widget displays info about the current git repository. Hide details of git changes + ```bash set -g @dracula-git-disable-status true ``` Set symbol to use for when branch is up to date with HEAD + ```bash # default is ✓. Avoid using non unicode characters that bash uses like $, * and ! set -g @dracula-git-show-current-symbol ✓ ``` Set symbol to use for when branch diverges from HEAD + ```bash # default is unicode !. Avoid bash special characters set -g @dracula-git-show-diff-symbol ! ``` Set symbol or message to use when the current pane has no git repo + ```bash # default is unicode no message set -g @dracula-git-no-repo-message "" ``` Hide untracked files from being displayed as local changes + ```bash # default is false set -g @dracula-git-no-untracked-files true ``` Show remote tracking branch together with diverge/sync state + ```bash # default is false set -g @dracula-git-show-remote-status true ``` ### gpu-info - [up](#table-of-contents) + These widgets display the current computational, ram, and power usage of installed graphics cards. They are split into widgets with the names: `gpu-usage, gpu-ram-usage, gpu-power-draw`. hardware support: + - full support for NVIDIA gpus on linux, when using official nvidia drivers. - partial support for apple m-chips on MacOS. - partial support for amd and intel on linux If your gpu is not recognised, force the script to assume a certain brand. + ```bash set -g @dracula-force-gpu "NVIDIA" ``` To display the used vram in percent (gigabyte is default unit): + ```bash set -g @dracula-gpu-vram-percent true ``` Vram usage is displayed in gigabyte without decimal places per default. To change that behaviour, use the following options with the respective number of decimal places you'd like to get: + ```bash set -g @dracula-gpu-vram-used-accuracy ".2f" set -g @dracula-gpu-vram-total-accuracy ".1f" ``` To display the power usage in percent (watt is default unit): + ```bash set -g @dracula-gpu-power-percent true ``` Possible nerdfont settings for gpu info labels: + ```bash set -g @dracula-gpu-power-label "󰢮 " set -g @dracula-gpu-usage-label "󰢮 " @@ -377,44 +416,53 @@ set -g @dracula-gpu-vram-label "󰢮 " ``` nerdfont icons to consider: + ```bash 󰢮 ``` `set -g @dracula-refresh-rate 5` affects this widget + ### hg - [up](#table-of-contents) + This widget displays info about the current mercurial repository. Hide details of hg changes + ```bash set -g @dracula-hg-disable-status true ``` Set symbol to use for when branch is up to date with HEAD + ```bash #default is ✓.Avoid using non unicode characters that bash uses like $, * and ! set -g @dracula-hg-show-current-symbol ✓ ``` Set symbol to use for when branch diverges from HEAD + ```bash #default is unicode !.Avoid bash special characters set -g @dracula-hg-show-diff-symbol ! ``` Set symbol or message to use when the current pane has no hg repo + ```bash #default is unicode no message set -g @dracula-hg-no-repo-message "" ``` Hide untracked files from being displayed as local changes + ```bash #default is false set -g @dracula-hg-no-untracked-files false ``` ### Kerberos TGT - [up](#table-of-contents) + This widgets name is `krbtgt`. Set the principal to check the TGT expiration date for (with or without the REALM) @@ -450,28 +498,36 @@ set -g @dracula-kubernetes-eks-extract-account true ``` ### libreview - [up](#table-of-contents) + 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. + ### mpc - [up](#table-of-contents) + This widget displays music information provided by mpc. To format the display format: + ```bash set -g @dracula-mpc-format "%title% - %artist%" ``` `set -g @dracula-refresh-rate 5` affects this widget + ### network - [up](#table-of-contents) + This widget displays one of three states: offline, ethernet connected, or wifi connected. however, per default **this will only display the wifi you're connected to, if it provides internet access!** You can use different hosts to ping in order to check for a wifi or wired connection. If you frequently use networks without internet access, you can use local ip-addresses here to still display the connection. + ```bash set -g @dracula-network-hosts "1.1.1.1 8.8.8.8" ``` Possible nerdfont settings for network info: + ```bash set -g @dracula-network-ethernet-label "󰈀 Eth" set -g @dracula-network-offline-label "󱍢 " @@ -479,6 +535,7 @@ set -g @dracula-network-wifi-label " " ``` Nerdfont icons to consider: + ``` ethernet: 󰈀 󰒪 󰒍 󰌗 󰌘 offline: 󰖪 󱍢 @@ -486,25 +543,34 @@ wifi:    󰖩 󰘊 󰒢 ``` Known issues: + - If for some reason `iw` is only in the path for root and not the normal user, wifi connections will be considered ethernet connections. + ### network-bandwidth - [up](#table-of-contents) + This widget gives the currently used up and download speeds per second for one interface. The most common interfaces name are `eth0` for a wired connection and `wlan0` for a wireless connection. To set a specific network interface you'd like to monitor, used: + ```bash set -g @dracula-network-bandwidth "eno0" ``` + To display the interface name alongside the speeds, set: + ```bash set -g @dracula-network-bandwidth-show-interface true ``` + Per default, this widget checks the speeds as frequently as it can. to set longer intervals, use the following: + ```bash set -g @dracula-network-bandwidth-interval 5 ``` ### network-ping - [up](#table-of-contents) + This widget displays the current ping to a specific server. You can configure which server (hostname, IP) you want to ping and at which rate (in seconds). Default is google.com at every 5 seconds. @@ -515,77 +581,137 @@ set -g @dracula-ping-rate 5 ``` ### network-vpn - [up](#table-of-contents) + This widget displays whether a vpn is connected. These options are not available yet. + ```bash set -g @dracula-network-vpn-verbose true set -g @dracula-network-vpn-label ``` + ### playerctl - [up](#table-of-contents) + This widget displays playerctl info. Set the playerctl metadata format like so: + ```bash set -g @dracula-playerctl-format "► {{ artist }} - {{ title }}" ``` ### ram-usage - [up](#table-of-contents) + This widget displays the currently used ram as GB per GB. Possible nerdfont settings for ram usage: + ```bash set -g @dracula-ram-usage-label " " ``` Nerdfont icons to consider: + ```    󰍛 󰘚 ``` + ### spotify-tui - [up](#table-of-contents) + This widget displays music information provided by spotify-tui. Spotify-tui must be installed to use this widget. To format the display format: + ```bash set -g @dracula-spotify-tui-format "%f %s %t - %a" ``` To limit the maximum length (0 means unlimited length): + ```bash set -g @dracula-spotify-tui-max-len 30 ``` -`set -g @dracula-refresh-rate 5` affects this widget +`set remote-g @dracula-refresh-rate 5` affects this widget + +### 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" "❚❚ " + +``` + +This contains a remote (experimental) but limits the use of the display widget in 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: + +- ` + P` - Play/Pause +- ` + R` - Back to position 0/previous track +- ` + N` - Next track + +To change the keybinds: + +```bash +set -g @dracula-spr-remote-pp "P" +set -g @dracula-spr-remote-back "R" +set -g @dracula-spr-remote-next "N" +``` + ### 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. To output nothing (and maybe hide the widget) when not connected via ssh: + ```bash set -g @dracula-show-ssh-only-when-connected true ``` Show SSH session port: + ```bash set -g @dracula-show-ssh-session-port true ``` nerdfont icons to consider: + ``` 󰣀 ``` + ### synchronize-panes - [up](#table-of-contents) + This widget displays whether the tmux panes are currently synchronised or not. To change the label: + ```bash set -g @dracula-synchronize-panes-label "Sync" ``` `set -g @dracula-refresh-rate 5` affects this widget + ### sys-temp - [up](#table-of-contents) + This widget displays the system temperature. ### terraform - [up](#table-of-contents) + **TODO** ``` @@ -593,7 +719,9 @@ set -g @dracula-terraform-label "" ``` `set -g @dracula-refresh-rate 5` affects this widget + ### time - [up](#table-of-contents) + This widget displays current date and time. Disable timezone @@ -615,33 +743,41 @@ set -g @dracula-military-time true ``` Set custom time format e.g (2023-01-01 14:00) + ```bash set -g @dracula-time-format "%F %R" ``` + See [[this page]](https://man7.org/linux/man-pages/man1/date.1.html) for other format symbols. ### tmux-ram-usage - [up](#table-of-contents) + This widget displays the ram currently used by tmux. Possible nerdfont settings for tmux ram usage: + ``` @dracula-tmux-ram-usage-label " " ``` Nerdfont icons to consider: + ```    󰍛 󰘚 ``` ### uptime - [up](#table-of-contents) + Shows how long the system has been running. Possible nerdfont settings for uptime: + ``` @dracula-uptime-label "󱎫 " ``` ### weather - [up](#table-of-contents) + Show weather information for given location. Switch from default fahrenheit to celsius @@ -663,5 +799,6 @@ set -g @dracula-show-location false ``` ### custom:script-name - [up](#table-of-contents) + For testing/ running custom plugins, put the bash script into the scripts directory of dracula/tmux plugin. Additionally, in the `@dracula-plugins` option, add the script as `custom:name-of-script.sh`. diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 172a6da0..602897c8 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -272,6 +272,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)" diff --git a/scripts/spr.sh b/scripts/spr.sh new file mode 100755 index 00000000..4293eb06 --- /dev/null +++ b/scripts/spr.sh @@ -0,0 +1,112 @@ +#!/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" + local play_icon="$2" + local track_info + + 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-pp" "P") + BACK_BUTTON=$(get_tmux_option "@dracula-spr-remote-back" "R") + NEXT_BUTTON=$(get_tmux_option "@dracula-spr-remote-next" "N") + + # 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 + From 3f8655faafc31d40e682b9b46431391d161efb48 Mon Sep 17 00:00:00 2001 From: bernie-haxx Date: Fri, 30 May 2025 14:04:19 +0300 Subject: [PATCH 02/15] feat: spotify_player checker --- scripts/spr.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/spr.sh b/scripts/spr.sh index 4293eb06..6debfc5a 100755 --- a/scripts/spr.sh +++ b/scripts/spr.sh @@ -91,6 +91,11 @@ main() { 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" From 38f31214ae996b2b168b4cda6cbafbda05c89264 Mon Sep 17 00:00:00 2001 From: Hugo/ Theo Meinhof Date: Sat, 21 Jun 2025 18:52:35 +0200 Subject: [PATCH 03/15] removing " from CONFIG.md where probably unintentional --- docs/CONFIG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 6d3d0eca..54d9418f 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -644,8 +644,8 @@ 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" "❚❚ " +set -g @dracula-spr-play-icon "♪ " +set -g @dracula-spr-pause-icon "❚❚ " ``` From a7fcc6f722390ff4bb125b994a0bf4091554af92 Mon Sep 17 00:00:00 2001 From: iberniex Date: Sat, 21 Jun 2025 22:52:33 +0300 Subject: [PATCH 04/15] fix: code rabbit suggestions --- docs/CONFIG.md | 2 +- scripts/spr.sh | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 54d9418f..d391b927 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -649,7 +649,7 @@ set -g @dracula-spr-pause-icon "❚❚ " ``` -This contains a remote (experimental) but limits the use of the display widget in MacOS. +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: diff --git a/scripts/spr.sh b/scripts/spr.sh index 6debfc5a..31054fbc 100755 --- a/scripts/spr.sh +++ b/scripts/spr.sh @@ -7,9 +7,8 @@ source "$current_dir/utils.sh" function trackStatus() { - local pause_icon="$1" - local play_icon="$2" - local track_info + local pause_icon="$1" play_icon="$2" + local track_info playback status track_result playback=$(spotify_player get key playback) @@ -42,7 +41,7 @@ function sliceTrack() local result="" if [[ $len > $std ]]; then - result="${str:0:std}" + result="${str:0:$std}" result+="..." else result=$str From c77118b75f9379649f22a67b5d72b950b6eae642 Mon Sep 17 00:00:00 2001 From: iberniex Date: Sat, 21 Jun 2025 22:52:58 +0300 Subject: [PATCH 05/15] docs: remote-pp change to remote-play-pause --- docs/CONFIG.md | 2 +- scripts/spr.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/CONFIG.md b/docs/CONFIG.md index d391b927..7b6df6d3 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -667,7 +667,7 @@ The default keybinds are: To change the keybinds: ```bash -set -g @dracula-spr-remote-pp "P" +set -g @dracula-spr-remote-play-pause "P" set -g @dracula-spr-remote-back "R" set -g @dracula-spr-remote-next "N" ``` diff --git a/scripts/spr.sh b/scripts/spr.sh index 31054fbc..0cae5c66 100755 --- a/scripts/spr.sh +++ b/scripts/spr.sh @@ -86,7 +86,7 @@ main() { PAUSE_ICON=$(get_tmux_option "@dracula-spr-pause-icon" "❚❚ ") # Remote Control Buttons Customizations - PLAY_PAUSE_BUTTON=$(get_tmux_option "@dracula-spr-remote-pp" "P") + 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") From c1559922a9047b9ca274425fb7e73afd7f399439 Mon Sep 17 00:00:00 2001 From: iberniex Date: Sat, 21 Jun 2025 22:56:56 +0300 Subject: [PATCH 06/15] fix: code-rabbit suggestions --- docs/CONFIG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 7b6df6d3..d7be6efe 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -30,7 +30,7 @@ - [playerctl](#playerctl---up) - [ram-usage](#ram-usage---up) - [spotify-tui](#spotify-tui---up) - - [spr](#spr--up) + - [spr](#spr---up) - [ssh-session](#ssh-session---up) - [synchronize-panes](#synchronize-panes---up) - [sys-temp](#sys-temp---up) From c90405d1e29d391fc1728fd2d441908e92831f58 Mon Sep 17 00:00:00 2001 From: iberniex Date: Sat, 19 Jul 2025 19:49:24 +0300 Subject: [PATCH 07/15] fix: boolean mistakes --- scripts/spr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/spr.sh b/scripts/spr.sh index 0cae5c66..fb703980 100755 --- a/scripts/spr.sh +++ b/scripts/spr.sh @@ -17,7 +17,7 @@ function trackStatus() { track_info=$(echo "$playback" | jq -r '.item | "\(.artists | map(.name) | join(", ")) - \(.name)"') track_result="" - if [[ $status == true ]]; then + if [[ $status == "true" ]]; then track_result+=$play_icon track_result+=$track_info else From 308b3c3c0812ac515fa62aaa2ccebbbd78d78dec Mon Sep 17 00:00:00 2001 From: iberniex Date: Sat, 19 Jul 2025 19:50:05 +0300 Subject: [PATCH 08/15] fix: solve tmux going blank --- scripts/spr.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/spr.sh b/scripts/spr.sh index fb703980..c5cdaec1 100755 --- a/scripts/spr.sh +++ b/scripts/spr.sh @@ -51,19 +51,18 @@ function sliceTrack() } -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" + local toggle="spotify_player playback play-pause > /dev/null 2>&1" + local back="spotify_player playback previous > /dev/null 2>&1" + local next="spotify_player playback next > /dev/null 2>&1" - tmux unbind-key "$toggle_button" - tmux unbind-key "$back_button" - tmux unbind-key "$next_button" + tmux unbind-key "$toggle_button" 2>/dev/null + tmux unbind-key "$back_button" 2>/dev/null + tmux unbind-key "$next_button" 2>/dev/null tmux bind-key "$toggle_button" run-shell "$toggle" tmux bind-key "$back_button" run-shell "$back" From c6c13e48877cc182ccf0f5288b4766c1c4c8b84e Mon Sep 17 00:00:00 2001 From: iberniex Date: Sat, 19 Jul 2025 19:50:48 +0300 Subject: [PATCH 09/15] fix: solve remote errors based on guard checks --- scripts/spr.sh | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/scripts/spr.sh b/scripts/spr.sh index c5cdaec1..5ed54509 100755 --- a/scripts/spr.sh +++ b/scripts/spr.sh @@ -6,7 +6,7 @@ current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$current_dir/utils.sh" -function trackStatus() { +trackStatus() { local pause_icon="$1" play_icon="$2" local track_info playback status track_result @@ -51,6 +51,7 @@ function sliceTrack() } +function sprRemoteControl() { local toggle_button="$1" local back_button="$2" local next_button="$3" @@ -74,33 +75,28 @@ main() { # save buffer to prevent lag local cache_file="/tmp/tmux_spr_cache" - RATE=$(get_tmux_option "@dracula-refresh-rate" 5) + RATE="$(get_tmux_option "@dracula-refresh-rate" 5)" - MAX_LENGTH=$(get_tmux_option "@dracula-spr-length" 25) + MAX_LENGTH="$(get_tmux_option "@dracula-spr-length" 25)" # Remote Control checker - REMOTE_ACCESS=$(get_tmux_option "@dracula-spr-remote" false) + SPR_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" + # Remote Access + if [[ "$SPR_REMOTE_ACCESS" == "true" ]]; then + 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") + sprRemoteControl "$PLAY_PAUSE_BUTTON" "$BACK_BUTTON" "$NEXT_BUTTON" fi if [ ! -f "$cache_file" ] || [ $(($(date +%s) - $(stat -f%c "$cache_file"))) -ge "$RATE" ]; then From 90ed44ef1d1fe3c12294d7f9c14524c4fec10f4f Mon Sep 17 00:00:00 2001 From: iberniex Date: Sat, 19 Jul 2025 19:51:03 +0300 Subject: [PATCH 10/15] chore: dry and optimize caching --- scripts/spr.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/spr.sh b/scripts/spr.sh index 5ed54509..037e4862 100755 --- a/scripts/spr.sh +++ b/scripts/spr.sh @@ -99,12 +99,14 @@ main() { sprRemoteControl "$PLAY_PAUSE_BUTTON" "$BACK_BUTTON" "$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" + + if [ ! -f "$cache_file" ] || [ $(($(date +%s) - $(stat -c%Y "$cache_file" 2>/dev/null || stat -f%m "$cache_file"))) -ge "$RATE" ]; then + local full_track + full_track=$(trackStatus "$PAUSE_ICON" "$PLAY_ICON") + sliceTrack "$full_track" "$MAX_LENGTH" > "$cache_file" fi - cat "$cache_file" + echo "$BACK_BUTTON" } main From 0dce28cb762aaf6ae05705ed77ba15ed9aa2b3de Mon Sep 17 00:00:00 2001 From: iberniex Date: Sat, 19 Jul 2025 20:13:10 +0300 Subject: [PATCH 11/15] fix: clean up the commands when remote flag is false --- scripts/spr.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/spr.sh b/scripts/spr.sh index 037e4862..18b6ad97 100755 --- a/scripts/spr.sh +++ b/scripts/spr.sh @@ -97,6 +97,13 @@ main() { BACK_BUTTON=$(get_tmux_option "@dracula-spr-remote-back" "R") NEXT_BUTTON=$(get_tmux_option "@dracula-spr-remote-next" "N") sprRemoteControl "$PLAY_PAUSE_BUTTON" "$BACK_BUTTON" "$NEXT_BUTTON" + else + tmux set -g @dracula-spr-remote-play-pause "" + tmux set -g @dracula-spr-remote-back "" + tmux set -g @dracula-spr-remote-next "" + tmux unbind-key "$PLAY_PAUSE_BUTTON" 2>/dev/null + tmux unbind-key "$BACK_BUTTON" 2>/dev/null + tmux unbind-key "$NEXT_BUTTON" 2>/dev/null fi From 7625de4c2a5db5ceb45d11e99cb904f67897e1fe Mon Sep 17 00:00:00 2001 From: Hugo/ Theo Meinhof Date: Thu, 14 Aug 2025 13:37:18 +0200 Subject: [PATCH 12/15] Update CONFIG.md --- docs/CONFIG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CONFIG.md b/docs/CONFIG.md index c84fe79b..ba914cb4 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -716,7 +716,7 @@ set -g @dracula-spotify-tui-max-len 30 ``` -`set remote-g @dracula-refresh-rate 5` affects this widget +`set -g @dracula-refresh-rate 5` affects this widget ### spr - [up](#table-of-contents) From 69f1089aeff1de64d59f9b2c201798e7730df28f Mon Sep 17 00:00:00 2001 From: Hugo/ Theo Meinhof Date: Thu, 14 Aug 2025 13:39:07 +0200 Subject: [PATCH 13/15] Update CONFIG.md --- docs/CONFIG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/CONFIG.md b/docs/CONFIG.md index ba914cb4..bdfc1501 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -537,8 +537,6 @@ The supported remote players are: - Spotify - Music - Apple Music -NOTE: `set -g @dracula-refresh-rate 5` affects this widget - To change player icons: ```bash From 0aa155d2031e83bd9ccc16a1d1f5449af7bef797 Mon Sep 17 00:00:00 2001 From: Hugo/ Theo Meinhof Date: Thu, 14 Aug 2025 13:40:44 +0200 Subject: [PATCH 14/15] Update CONFIG.md --- docs/CONFIG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/CONFIG.md b/docs/CONFIG.md index bdfc1501..851f56b2 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -720,8 +720,6 @@ set -g @dracula-spotify-tui-max-len 30 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 From 7cf2f55cc74abd875b032ccadea8e807e193abab Mon Sep 17 00:00:00 2001 From: Hugo/ Theo Meinhof Date: Thu, 14 Aug 2025 14:01:52 +0200 Subject: [PATCH 15/15] Update spr.sh --- scripts/spr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/spr.sh b/scripts/spr.sh index 18b6ad97..7dfec955 100755 --- a/scripts/spr.sh +++ b/scripts/spr.sh @@ -91,7 +91,7 @@ main() { exit 1 fi - # Remote Access + # Remote Access if [[ "$SPR_REMOTE_ACCESS" == "true" ]]; then PLAY_PAUSE_BUTTON=$(get_tmux_option "@dracula-spr-remote-play-pause" "P") BACK_BUTTON=$(get_tmux_option "@dracula-spr-remote-back" "R")