added patch-dark-mode.ps1

This commit is contained in:
Julien Maille 2021-12-04 14:13:46 +01:00
parent 34bd5fe4f8
commit 55b714dbda
2 changed files with 32 additions and 1 deletions

View file

@ -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 src="https://raw.githubusercontent.com/JulienMaille/dribbblish-dynamic-theme/main/showcase-images/windows-shortcut-instruction.png" alt="img">
@ -74,6 +74,13 @@ In addition to `--transparent-window-controls` you can set `Windows Top Bars` to
<img src="https://raw.githubusercontent.com/JulienMaille/dribbblish-dynamic-theme/main/showcase-images/top-bars.png" alt="img" width="500px">
## 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

24
patch-dark-mode.ps1 Normal file
View file

@ -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);