Skip to content

Commit a65d4d6

Browse files
committed
fixes
1 parent 8057a9c commit a65d4d6

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

scripts/mac-player.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ main() {
226226
NEXT_BUTTON=$(get_tmux_option "@dracula-mac-player-remote-next" "N")
227227

228228
# Scroll
229-
SCROLL=$(get_tmux_option "@dracula-mac-player-scroll" false)
229+
SCROLL=$(get_tmux_option "@dracula-mac-player-scroll" "false")
230230
SCROLL_SPEED=$(get_tmux_option "@dracula-mac-player-scroll-speed" 0.08)
231231

232232
# os checker
@@ -252,23 +252,21 @@ main() {
252252
tmux unbind-key "$NEXT_BUTTON" 2>/dev/null
253253
fi
254254

255+
# handle cache separately from the scrolling feature
255256
if [ ! -f "$cache_file" ] || [ $(($(date +%s) - $(stat -f%c "$cache_file"))) -ge "$RATE" ]; then
256257
local full_track
257258
full_track=$(trackStatus "$PAUSE_ICON" "$PLAY_ICON")
258259

259-
if [ "$SCROLL" = "true" ] && [ "${#str}" -ge $MAX_LENGTH ]; then
260-
echo "$full_track" > "$cache_file"
261-
else
262-
sliceTrack "$full_track" "$MAX_LENGTH" > "$cache_file"
263-
fi
260+
echo "$full_track" >"$cache_file"
264261
fi
265262

266-
# Allow scrolling
267-
local str=$(cat "$cache_file")
268-
if [ "$SCROLL" = "true" ]; then
269-
scroll "$str" "$MAX_LENGTH" "$SCROLL_SPEED"
263+
# Allow scrolling and if not default to the string stripping concatenation thingy from length
264+
local final_str
265+
final_str=$(cat "$cache_file")
266+
if [ "$SCROLL" = "true" ] && [ "${#final_str}" -ge "$MAX_LENGTH" ]; then
267+
scroll "$final_str" "$MAX_LENGTH" "$SCROLL_SPEED"
270268
else
271-
echo "$str"
269+
sliceTrack "$final_str" "$MAX_LENGTH"
272270
fi
273271
}
274272

0 commit comments

Comments
 (0)