Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

feat: the lock screen's star switches between moving artwork and lyrics

My-Name-Is-Jeff720017e5439e
diff --git a/docs/tweaks.md b/docs/tweaks.md
index 951ea268..dcd1a01c 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -163,7 +163,13 @@ Shared:
looked up again when its Canvas comes in a later state, and the next track's clip is fetched ahead
(SGMotionFollower.m). The lock screen takes a clip under a key the system lists, cut to that key's
shape when it is not, with its still filled to the size asked (SGMotionClip.m), and a change of the
- choice applies at once, but to or from Lyrics. The cut and the service's wire format are checked on
+ choice applies at once, Lyrics too. Switch with the star (spotifyglass.lockscreen.star, off;
+ LockScreenStar.x) puts a star on the lock screen widget, MediaPlayer's like command, whose tap swaps
+ the choice between the lyrics and the moving artwork it left (Moving artwork or Every song, kept under
+ spotifyglass.lockscreen.star.back), filled while the lyrics show; the choice is the setting, so the
+ mode outlives a relaunch and the page's row follows it. The star takes the slot of Spotify's like
+ and dislike buttons, so their flag is forced off at launch while the switch is on, over the row's
+ own override, and the row shows it locked. The cut and the service's wire format are checked on
the Mac against harness/motion/
LocalFiles/ local files (LocalFiles.h lists its files): Edit info in the player's ⋯ menu, the table's footer
under Speed and pitch, which closes the menu and opens a form sheet (the three names, the cover
@@ -731,9 +737,10 @@ saying which, then the switch; its row is on the main page too, under Karaoke's)
Checking among its states) and its removal, Toggle from lyrics (the redesign's mic, on until switched off, issue #12),
Ignore heat warnings, and under Advanced Runs on (Automatic: the Neural Engine
beside the CPU; CPU only) and Prepare after updates, all applying straight away. Lock screen, on the main
-page under either look, opens the lock screen widget's page, titled Lock screen (Moving artwork, Lyrics or Every song, and the lyrics' style,
-Still or Animated, and Spotify's like and dislike buttons' flag; its podcast, audiobook and artwork flags stay in
-All flags). Player: Gestures and Blocked artists (with the count on the row), which work with either look;
+page under either look, opens the lock screen widget's page, titled Lock screen: Widget (the line in place of the artist,
+and Spotify's like and dislike buttons' flag, locked off while the star is on) then Artwork (Off, Moving artwork, Lyrics
+or Every song, the lyrics' style, Still or Animated, Switch with the star, the sources and Low Data Mode; below iOS 26
+one row saying why not). Spotify's podcast, audiobook and artwork flags stay in All flags. Player: Gestures and Blocked artists (with the count on the row), which work with either look;
in the native look also Now playing bar (its device button and its flags), Queue & devices, and
Spotify's own player screen (artwork background, glass header buttons, Disable Canvas and the sheet,
header, slider and sticky header flags, the cards under the player and the lyrics preview and player
diff --git a/tweak/Sources/Shared/AnimatedArtwork/AnimatedArtwork.h b/tweak/Sources/Shared/AnimatedArtwork/AnimatedArtwork.h
index 947f4bd2..131318cd 100644
--- a/tweak/Sources/Shared/AnimatedArtwork/AnimatedArtwork.h
+++ b/tweak/Sources/Shared/AnimatedArtwork/AnimatedArtwork.h
@@ -18,6 +18,11 @@ typedef NS_ENUM(NSInteger, SGLockArtwork) {
SGLockArtwork SGLockScreenArtwork(void);
// How the lyrics are drawn, stored as the index of SGLyricsClipStyle (Still unless changed).
#define SGKeyLockScreenLyricsStyle @"spotifyglass.lockscreen.lyricsStyle"
+// Off until switched on: the lock screen widget's star switches the choice between moving artwork and
+// Lyrics (LockScreenStar.x), and takes the place of Spotify's like and dislike buttons. StarBack is the
+// choice the star left for Lyrics, Moving artwork or Every song, to go back to.
+#define SGKeyLockScreenStar @"spotifyglass.lockscreen.star"
+#define SGKeyLockScreenStarBack @"spotifyglass.lockscreen.star.back"
// Off until switched on: download in Low Data Mode too.
#define SGKeyMotionLowData @"spotifyglass.motion.lowdata"
diff --git a/tweak/Sources/Shared/AnimatedArtwork/AnimatedArtworkSettings.m b/tweak/Sources/Shared/AnimatedArtwork/AnimatedArtworkSettings.m
index 212bc8d2..2fae6e16 100644
--- a/tweak/Sources/Shared/AnimatedArtwork/AnimatedArtworkSettings.m
+++ b/tweak/Sources/Shared/AnimatedArtwork/AnimatedArtworkSettings.m
@@ -28,11 +28,16 @@ NSArray *SGLockScreenMotionRows(void) {
};
SGModRow *sources = SGMotionSourcesRow();
sources.visible = lowData.visible;
+ SGModRow *star = SGOptionRow(@"Switch with the star", @"The lock screen widget's star swaps the moving artwork for the lyrics "
+ @"and back. It takes the place of Spotify's like and dislike buttons",
+ SGKeyLockScreenStar);
+ star.visible = ^BOOL { return SGLockScreenArtwork() != SGLockArtworkOff; };
return @[
SGChoiceRow(@"Full-screen artwork", @"The Canvas or Apple Music's animated cover, or the lyrics a line at a time. "
@"Every song puts the cover over a moving blur of it where a song has neither",
SGKeyLockScreenArtwork, @[@"Off", @"Moving artwork", @"Lyrics", @"Every song"], SGLockArtworkOff),
style,
+ star,
sources,
lowData,
];
diff --git a/tweak/Sources/Shared/AnimatedArtwork/LockScreenMotion.x b/tweak/Sources/Shared/AnimatedArtwork/LockScreenMotion.x
index 7fc9090d..d3ae9b5f 100644
--- a/tweak/Sources/Shared/AnimatedArtwork/LockScreenMotion.x
+++ b/tweak/Sources/Shared/AnimatedArtwork/LockScreenMotion.x
@@ -10,8 +10,8 @@
// the track names, so an album's songs share one.
//
// The choice is read on every track, and a change applies at once: Off takes the clip away, Moving artwork
-// and Every song look the playing track up. Lyrics is LyricsArtwork.x's, which reads it only at launch, so
-// a launch with Lyrics leaves this off until the next one.
+// and Every song look the playing track up. Lyrics is LyricsArtwork.x's, which reads it the same way, so the
+// lock screen widget's star (LockScreenStar.x) can swap the two without a restart.
#import <MediaPlayer/MediaPlayer.h>
#import "Core/SGCore.h"
#import "AnimatedArtwork.h"
diff --git a/tweak/Sources/Shared/AnimatedArtwork/LockScreenStar.x b/tweak/Sources/Shared/AnimatedArtwork/LockScreenStar.x
new file mode 100644
index 00000000..800353d4
--- /dev/null
+++ b/tweak/Sources/Shared/AnimatedArtwork/LockScreenStar.x
@@ -0,0 +1,120 @@
+// The lock screen widget's star: a tap switches the full-screen artwork between moving artwork and the
+// lyrics, at once, by writing the choice LockScreenMotion.x and LyricsArtwork.x both watch. The star is
+// MediaPlayer's like command, the slot Apple Music's Favorite star takes; it is filled while the lyrics
+// show. Spotify's own like and dislike buttons (its like_dislike flag) take the same slot, so the flag
+// is forced off while the switch is on and the Lock screen page's row shows it locked. iOS 26 only, as
+// the artwork is.
+#import <MediaPlayer/MediaPlayer.h>
+#import "Core/SGCore.h"
+#import "AnimatedArtwork.h"
+#import "Shared/Player/PlayerState.h"
+
+static NSString *const kLikeDislikeFlag = @"ios-feature-lockscreen.like_dislike_enabled";
+static MPFeedbackCommand *sg_like; // the command while the star is on it, else nil
+static id sg_target;
+
+static BOOL starOn(void) {
+ return SGHidden(SGKeyLockScreenStar) && SGLockScreenArtwork() != SGLockArtworkOff;
+}
+
+static MPRemoteCommandHandlerStatus tapped(void) {
+ SGLockArtwork choice = SGLockScreenArtwork();
+ if (choice == SGLockArtworkOff) return MPRemoteCommandHandlerStatusCommandFailed;
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if (choice == SGLockArtworkLyrics) {
+ SGSetInt(SGKeyLockScreenArtwork, SGInt(SGKeyLockScreenStarBack, SGLockArtworkMotion));
+ } else {
+ SGSetInt(SGKeyLockScreenStarBack, choice);
+ SGSetInt(SGKeyLockScreenArtwork, SGLockArtworkLyrics);
+ }
+ SGLog(@"lock star: tapped, the lock screen takes %ld", (long)SGLockScreenArtwork());
+ });
+ return MPRemoteCommandHandlerStatusSuccess;
+}
+
+// Main thread, on every defaults write and player state: the command is touched only when the star's state
+// changed, or when Spotify's lock screen policy turned it off under the star, which the log says.
+static void arm(void) {
+ static BOOL lastOn, lastActive;
+ BOOL on = starOn(), active = on && SGLockScreenArtwork() == SGLockArtworkLyrics;
+ if (sg_like && !sg_like.enabled) {
+ static int told;
+ if (told++ < 3) SGLog(@"lock star: the like command was off under the star, set again");
+ sg_like.enabled = YES;
+ }
+ if (on == lastOn && active == lastActive && on == (sg_like != nil)) return;
+ lastOn = on;
+ lastActive = active;
+ if (!on && !sg_like) return; // the command is Spotify's
+ MPFeedbackCommand *like = MPRemoteCommandCenter.sharedCommandCenter.likeCommand;
+ if (!on) {
+ [like removeTarget:sg_target];
+ sg_target = nil;
+ sg_like = nil;
+ like.enabled = NO;
+ like.active = NO;
+ SGLog(@"lock star: off");
+ return;
+ }
+ if (!sg_like) {
+ // Spotify's handler, if the flag had it on one, would like the song on the same tap.
+ [like removeTarget:nil];
+ sg_target = [like addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent *event) { return tapped(); }];
+ like.localizedTitle = @"Lock screen lyrics";
+ sg_like = like;
+ SGLog(@"lock star: on the like command");
+ }
+ like.enabled = YES;
+ like.active = active;
+}
+
+// Spotify's two ways of taking the like command back under the star: turning it off is kept on; taking the
+// handlers off is let through and logged, with the star armed again on the next player state.
+%hook MPRemoteCommand
+- (void)setEnabled:(BOOL)enabled {
+ if (!enabled && sg_like && self == sg_like) {
+ static int told;
+ if (told++ < 3) SGLog(@"lock star: Spotify turned the like command off, kept on");
+ enabled = YES;
+ }
+ %orig(enabled);
+}
+- (void)removeTarget:(id)target {
+ if (sg_like && self == sg_like && target != sg_target) {
+ SGLog(@"lock star: Spotify took %@ off the like command", target ? @"its handler" : @"every handler");
+ if (!target) sg_like = nil;
+ }
+ %orig;
+}
+%end
+
+@interface SGLockScreenStar : NSObject <SGPlayerStateObserver>
+@end
+
+@implementation SGLockScreenStar
+- (void)playerStateDidChange:(SPTPlayerState *)state {
+ arm();
+}
+@end
+
+%ctor {
+ if (@available(iOS 26.0, *)) {
+ // Read at launch as Spotify reads the flag; the row locks from the switches as they are stored now.
+ BOOL atLaunch = starOn();
+ SGRegisterFlagForcer(YES, ^id(NSString *key) {
+ return atLaunch && [key isEqualToString:kLikeDislikeFlag] ? @NO : nil;
+ }, ^id(NSString *key) {
+ return starOn() && [key isEqualToString:kLikeDislikeFlag] ? @NO : nil;
+ });
+ %init;
+ static SGLockScreenStar *observer;
+ observer = [SGLockScreenStar new];
+ SGAddPlayerStateObserver(observer);
+ // Heard on the writing thread and handed to main without waiting (AGENTS.md).
+ [NSNotificationCenter.defaultCenter addObserverForName:NSUserDefaultsDidChangeNotification object:nil queue:nil
+ usingBlock:^(NSNotification *note) {
+ dispatch_async(dispatch_get_main_queue(), ^{ arm(); });
+ }];
+ SGLog(@"lock star: %@", atLaunch ? @"on, Spotify's like and dislike buttons forced off" : @"off");
+ }
+}
diff --git a/tweak/Sources/Shared/Player/PlayerSettings.m b/tweak/Sources/Shared/Player/PlayerSettings.m
index fe367c1e..45f23233 100644
--- a/tweak/Sources/Shared/Player/PlayerSettings.m
+++ b/tweak/Sources/Shared/Player/PlayerSettings.m
@@ -5,16 +5,15 @@
#import "Shared/AnimatedArtwork/AnimatedArtwork.h"
#import "Shared/Lyrics/Lyrics.h"
-// Like and dislike is the one lock screen control a song gets. Spotify's flags for podcasts, audiobooks and its
-// own lock screen artwork stay on the All flags page: the artwork section above is the mod's. The line in place of the
-// artist is on the Lyrics page too, the same switch.
+// Widget first: the line in place of the artist (on the Lyrics page too, the same switch) and Like and dislike,
+// the one lock screen control a song gets, which the Artwork section's star takes the place of
+// (Shared/AnimatedArtwork/LockScreenStar.x locks the flag off). Spotify's flags for podcasts, audiobooks and its
+// own lock screen artwork stay on the All flags page: the Artwork section is the mod's.
UIViewController *SGLockScreenWidgetPage(void) {
- NSArray *motion = SGLockScreenMotionRows();
- NSArray<SGModSection *> *mod = motion.count ? @[SGSection(@"Lock screen artwork", motion)] : @[];
- return [[SGModPage alloc] initWithTitle:@"Lock screen" intro:SGRestartNote sections:[mod arrayByAddingObjectsFromArray:@[
- SGSection(@"Lyrics", @[SGLockScreenLyricsRow()]),
- SGSection(@"Controls", @[
- SGFlagRow(@"Like and dislike buttons", @"ios-feature-lockscreen.like_dislike_enabled"),
- ]),
- ]] footer:nil];
+ SGModRow *likes = SGFlagRow(@"Like and dislike buttons", @"ios-feature-lockscreen.like_dislike_enabled");
+ likes.subtitle = @"Off and locked while Switch with the star is on: the star takes their place";
+ return [[SGModPage alloc] initWithTitle:@"Lock screen" intro:SGRestartNote sections:@[
+ SGSection(@"Widget", @[SGLockScreenLyricsRow(), likes]),
+ SGSection(@"Artwork", SGLockScreenMotionRows()),
+ ] footer:nil];
}