From 55b714dbdaa6948dc73f61512efc70eae8dfdbfc Mon Sep 17 00:00:00 2001 From: Julien Maille Date: Sat, 4 Dec 2021 14:13:46 +0100 Subject: [PATCH] added patch-dark-mode.ps1 --- README.md | 9 ++++++++- patch-dark-mode.ps1 | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 patch-dark-mode.ps1 diff --git a/README.md b/README.md index 1588006..0c20b13 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ xpui.js_repl_8008 = ,${1}58, ## Hide Window Controls Windows user, please edit your Spotify shortcut and add flag `--transparent-window-controls` after the Spotify.exe: -To edit an taskbar shortcut, right click it, then right click Spotify in the list again. +To edit a taskbar shortcut, right click it, then right click Spotify in the list again. img @@ -74,6 +74,13 @@ In addition to `--transparent-window-controls` you can set `Windows Top Bars` to img +## Follow system dark/light theme (Powershell) +Automatic dark mode should work on MacOs and Linux out of the box. +From Spotify > v1.1.70, dark mode is forced in Windows builds. You will need to patch Spotify.exe using this script: +```powershell +Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/JulienMaille/dribbblish-dynamic-theme/master/patch-dark-mode.ps1" | Invoke-Expression +``` + ## Uninstall ### Windows (PowerShell) ```powershell diff --git a/patch-dark-mode.ps1 b/patch-dark-mode.ps1 new file mode 100644 index 0000000..376726e --- /dev/null +++ b/patch-dark-mode.ps1 @@ -0,0 +1,24 @@ +$sp = "$env:APPDATA\Spotify\Spotify.exe" +Copy-Item $sp ($sp + ".backup") + +$bytes = [System.IO.File]::ReadAllBytes($sp); +$toRemove = [System.Text.Encoding]::UTF8.GetBytes("force-dark-mode"); + +for ($i = 0; $i -lt $bytes.Length; $i++) { + $found = $true + for ($j = 0; $j -lt $toRemove.Length; $j++) { + if ($bytes[$i + $j] -ne $toRemove[$j]) { + $found = $false; + break; + } + } + + if ($found -eq $true) { + for ($j = 0; $j -lt $toRemove.Length; $j++) { + $bytes[$i + $j] = [byte]65; + } + break; + } +} + +[System.IO.File]::WriteAllBytes($sp, $bytes); \ No newline at end of file