Index: Slim/Buttons/Common.pm =================================================================== --- Slim/Buttons/Common.pm (revision 8735) +++ Slim/Buttons/Common.pm (working copy) @@ -570,7 +570,16 @@ }, 'sleep' => sub { my $client = shift; - my @sleepChoices = (0,15,30,45,60,90); + + my $remaining; + if (Slim::Player::Source::playingSong($client) && $client->playmode =~ /play/) { + my $dur = Slim::Player::Source::playingSongDuration($client); + + $remaining = $dur - Slim::Player::Source::songTime($client); + $remaining = $remaining / 60; + } + + my @sleepChoices = $remaining ? (0, $remaining, 15,30,45,60,90) : (0,15,30,45,60,90); my $i; # find the next value for the sleep timer for ($i = 0; $i <= $#sleepChoices; $i++) {