From 4c260ce620e7fa152e4e52c2e73b0926f162ffb9 Mon Sep 17 00:00:00 2001 From: Theoreticallyhugo Date: Mon, 19 Aug 2024 10:45:39 +0200 Subject: [PATCH] feature/ add max len to spotify and fix output when no device available --- README.md | 2 +- scripts/spotify-tui.sh | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8908c4aa..c2d15e6a 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul - When charging, 'AC' is displayed - If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature - Info if the Panes are synchronized -- Spotify playback (needs the tool spotify-tui installed) +- Spotify playback (needs the tool spotify-tui installed). max-len can be configured. - Music Player Daemon status (needs the tool mpc installed) - Playerctl, get current track metadata - Current kubernetes context diff --git a/scripts/spotify-tui.sh b/scripts/spotify-tui.sh index 33ff32f3..ab6e39d7 100755 --- a/scripts/spotify-tui.sh +++ b/scripts/spotify-tui.sh @@ -15,10 +15,20 @@ main() exit 1 fi + if [ "$(spt list --devices)" = "No devices available" ] + then + echo "" + exit 0 + fi + FORMAT=$(get_tmux_option "@dracula-spotify-tui-format" "%f %s %t - %a") spotify_playback=$(spt playback -f "${FORMAT}") - echo ${spotify_playback} - + max_len=$(get_tmux_option "@dracula-spotify-tui-max-len" 0) + if [[ $max_len -ne 0 ]] ; then + echo ${spotify_playback} | head -c $max_len + else + echo ${spotify_playback} + fi } # run the main driver