From 2e59325c22605873bba62c078c196d99c1664590 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 9 Apr 2024 14:15:03 +1000 Subject: [PATCH] Go to the start of the current track before the previous track when hitting back --- lua/playing.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lua/playing.lua b/lua/playing.lua index 3368f590..a88cd961 100644 --- a/lua/playing.lua +++ b/lua/playing.lua @@ -151,9 +151,15 @@ return screen:new { local prev_btn = controls:Button {} - prev_btn:onClicked(queue.previous) + prev_btn:onClicked(function() + if playback.position:get() > 1 or queue.position:get() == 1 then + playback.position:set(0) + else + queue.previous() + end + end) local prev_img = prev_btn:Image { src = img.prev } - theme.set_style(prev_img, icon_disabled_class) + theme.set_style(prev_img, icon_enabled_class) local play_pause_btn = controls:Button {} play_pause_btn:onClicked(function() @@ -217,10 +223,6 @@ return screen:new { theme.set_style( next_img, pos < queue.size:get() and icon_enabled_class or icon_disabled_class ) - - theme.set_style( - prev_img, pos > 1 and icon_enabled_class or icon_disabled_class - ) end), queue.random:bind(function(shuffling) theme.set_style(shuffle_img, shuffling and icon_enabled_class or icon_disabled_class)