Category: Arch Linux

Automatic fix for Spotify scaling bad on HiDPI screens on Arch Linux using yaourt, hooks and pacman

Spotify scales pretty bad on HiDPI screens (like the XPS 13 with 4k screen). All the text is small and barely readable. Tangram mentioned a fix for this issue, but everytime you update Spotify from the AUR it will update and break the .desktop file.

To make pacman fix this automatically there is a feature called Hooks. In the following we will create a hook to replace the .desktop file, which is the starter for spotify on a lot of window managers.

First we need a small script that will rewrite this file:

#!/bin/bash

echo '[Desktop Entry]
Name=Spotify
GenericName=Music Player
Comment=Spotify streaming music client
Icon=spotify-client
Exec=spotify --force-device-scale-factor=2.3 %U
TryExec=spotify
Terminal=false
Type=Application
Categories=Audio;Music;Player;AudioVideo;
MimeType=x-scheme-handler/spotify;' > /usr/share/applications/spotify.desktop

Do not forget to set your scaling factor in line 8 to a reasonable value. 2.3 works fine for the XPS13 with a 4k display.

You need to save this file to

/usr/local/sbin/fix-scaling-spotify.sh

Then we will create a hook, that will run on “Upgrade” and “Install”.

[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = spotify

[Action]
Depends = spotify
When = PostTransaction
Exec = /usr/local/sbin/fix-scaling-spotify.sh

Save this hook to

/etc/pacman.d/hooks/

If this directory does not exist, create it using

mkdir -p /etc/pacman.d/hooks
yaourt -S spotify

==> Lade PKGBUILD von spotify aus dem AUR herunter...
x .SRCINFO
x .gitignore
x LICENSE
x PKGBUILD
x spotify
x spotify.protocol
annata83 commented on 2017-05-27 00:06			 
Hi, I just starting out with arch.. don't understand much of how  building goes yet, I downloaded the snapshot and execute it with makepkg -si.. now i get this:
usr/share/spotify/spotify: /usr/lib/libssl.so.1.0.0: version `OPENSSL_1.0.0' not found (required by /usr/share/spotify/spotify)
/usr/share/spotify/spotify: /usr/lib/libcrypto.so.1.0.0: version `OPENSSL_1.0.0' not found (required by /usr/share/spotify/spotify)
/usr/share/spotify/spotify: /usr/lib/libcurl.so.3: no version information available (required by /usr/share/spotify/spotify)
...............................
I also run yaourt -S libopenssl-1.0-compat libcurl-openssl-1.0 spotify after adding the keys but same thing. What is this and how can I fix it?

By the way trying to check for openssl 1.0 i get this:
openssl-1.0-compat and libopenssl-1.0-compat are in conflict

d4n3sh commented on 2017-05-27 01:43			 
Confirmed, ssl was officially reverted. #sudo pacman -Syu today and the problem is fixed.

NicoHood commented on 2017-05-27 08:57			 
@ayoung The terms of use forbid to redistribute Spotify in our official repositories. If you package it on your own, thats a different procedure.

I've contacted spotify and was forwarded to the boss of the desktop app and the main 2 linux devs. However I got no response back after that.

If you guys want to have spotify in our official repository I suggest opening a thread in their forum. People need to upvote this and then we can possibly work closer with spotify. I am willing to package spotify for [community].

Lenovsky commented on 2017-05-28 08:59			 
@NicoHood 
Hey, since you know the problem better than us, could you start such a thread and link it here or/and  somewhere? It would be great ;)

NicoHood commented on 2017-05-28 14:45			 
@Lenovsky There you go. Please upvote this topic if you wish to have spotify in the official ArchLinux [community] repository.

https://community.spotify.com/t5/Desktop-Linux-Windows-Web-Player/Redistribute-Spotify-on-Linux-Distributions/m-p/1695334#M188735

spotify 1.0.55.487-2  (2017-05-26 02:14)
(Nicht unterstütztes Paket: Potenziell gefährlich!)
==> PKGBUILD bearbeiten? [J/n] („A“ zum Abbrechen)
==> ----------------------------------------------
==> n

==> Von spotify benötigt:
 - alsa-lib>=1.0.14 (bereits installiert)
 - gconf (bereits installiert)
 - gtk2 (bereits installiert)
 - glib2 (bereits installiert)
 - nss (bereits installiert)
 - libsystemd (bereits installiert)
 - libxtst (bereits installiert)
 - libx11 (bereits installiert)
 - libxss (bereits installiert)
 - openssl-1.0 (bereits installiert)
 - libcurl-compat (bereits installiert)
 - desktop-file-utils (bereits installiert)
 - rtmpdump (bereits installiert)


==> Mit dem Erstellen von spotify fortfahren?[J/n]
==> ----------------------------------------------
==> 

==> Erstelle und installiere Paket
==> Erstelle Paket: spotify 1.0.55.487-2 (Di 30. Mai 08:44:14 CEST 2017)
==> Prüfe Laufzeit-Abhängigkeiten...
==> Prüfe Buildtime-Abhängigkeiten...
==> Empfange Quellen...
  -> spotify gefunden
  -> spotify.protocol gefunden
  -> LICENSE gefunden
  -> Lade spotify-client_1.0.55.487.g256699aa-16_amd64.deb herunter...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 86.8M  100 86.8M    0     0  2557k      0  0:00:34  0:00:34 --:--:-- 6809k
==> Überprüfe source Dateien mit sha256sums...
    spotify ... Durchgelaufen
    spotify.protocol ... Durchgelaufen
    LICENSE ... Durchgelaufen
==> Überprüfe source_x86_64 Dateien mit sha256sums...
    spotify-client_1.0.55.487.g256699aa-16_amd64.deb ... Durchgelaufen
==> Entpacke Quellen...
  -> Entpacke spotify-client_1.0.55.487.g256699aa-16_amd64.deb mit bsdtar
==> Betrete fakeroot Umgebung...
==> Beginne package()...
==> Säubere Installation...
  -> Entferne libtool Dateien...
  -> Bereinige ungewollte Dateien...
  -> Entferne statische Bibliotheken...
  -> Komprimiere Man-Pages und Info-Seiten...
==> Prüfe auf Paketierungsprobleme...
==> Erstelle Paket "spotify"...
  -> Erstelle .PKGINFO Datei...
  -> Erstelle .BUILDINFO Datei...
  -> Erstelle .MTREE-Datei...
  -> Komprimiere Paket... 
==> Verlasse fakeroot Umgebung.
==> Beendete Erstellung: spotify 1.0.55.487-2 (Di 30. Mai 08:46:34 CEST 2017)
==> Räume auf...

==> Mit der Installation von spotify fortfahren? [J/n]
==> [I]nhalte des Pakets ansehen [P]aket mit Namcap überprüfen
==> ----------------------------------------------------------
==> J

[sudo] Passwort für jan: 
Lade Pakete...
Löse Abhängigkeiten auf...
Suche nach in Konflikt stehenden Paketen...

Pakete (1) spotify-1.0.55.487-2

Gesamtgröße der installierten Pakete:  203,45 MiB

:: Installation fortsetzen? [J/n] 
(1/1) Prüfe Schlüssel im Schlüsselring               [###########################] 100%
(1/1) Überprüfe Paket-Integrität                     [###########################] 100%
(1/1) Lade Paket-Dateien                             [###########################] 100%
(1/1) Prüfe auf Dateikonflikte                       [###########################] 100%
(1/1) Überprüfe verfügbaren Festplattenspeicher      [###########################] 100%
:: Verarbeite Paketänderungen...
(1/1) Installiere spotify                            [###########################] 100%
Optionale Abhängigkeiten für spotify
    ffmpeg0.10: Adds support for playback of local files
    zenity: Adds support for importing local files [Installiert]
:: Starte post-transaction hooks...
(1/4) Updating icon theme caches...
(2/4) spotify-fix-scaling-PostInstall.hook
(3/4) Arming ConditionNeedsUpdate...
(4/4) Updating the desktop file MIME type cache...

That’s it. Just upgrade spotify using yaourt and pacman will run the hook.