install-spotify.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. SPOTIFY_URL=http://repository.spotify.com/pool/non-free/s/spotify-client/
  3. SPOTIFY_NAME=spotify-client_1.0.57.474.gca9c9538-30_amd64.deb
  4. if [ `id -u` = 0 ] ; then
  5. echo "Please don't run this script as root."
  6. exit;
  7. fi
  8. function clean_up {
  9. rm -rf spotify-client/
  10. }
  11. trap clean_up SIGHUP SIGINT SIGTERM
  12. if [ ! -d "spotify-client" ]; then
  13. mkdir -p spotify-client
  14. fi
  15. cd spotify-client
  16. echo "Downloading Spotify Client..."
  17. wget $SPOTIFY_URL$SPOTIFY_NAME
  18. if [ -f "/etc/debian_version" ]; then
  19. echo "Detected Debian based system"
  20. echo "Do you want to install .deb package instead?"
  21. select yn in "Yes" "No"; do
  22. case $yn in
  23. Yes ) sudo dpkg -i $SPOTIFY_NAME; sudo apt-get -y -f install; cd ../; rm -rf spotify-client; echo "Done. To unistall, use 'apt purge spotify-client'"; exit;;
  24. No ) break;;
  25. esac
  26. done
  27. fi
  28. echo "Decompressing files..."
  29. ar x $SPOTIFY_NAME
  30. tar -xvzf data.tar.gz
  31. echo "Copying files..."
  32. mkdir -p $HOME/bin/
  33. mkdir -p $HOME/.local/share/icons/hicolor/128x128/apps/
  34. cp usr/share/spotify/icons/spotify-linux-128.png $HOME/.local/share/icons/hicolor/128x128/apps/spotify-client.png
  35. cp -r usr/share/spotify/ $HOME/.local/share/
  36. ln -s $HOME/.local/share/spotify/spotify $HOME/bin/
  37. declare file_content=$( cat "$HOME/.bashrc" )
  38. if [[ " $file_content " =~ "export PATH="$HOME/bin:$PATH"" ]]
  39. then
  40. echo "PATH already added in .bashrc."
  41. else
  42. echo "Adding patch in .bashrc."
  43. echo "export PATH="$HOME/bin:$PATH"" >> $HOME/.bashrc
  44. fi
  45. cd ../
  46. update-desktop-database -q
  47. cp spotify.desktop $HOME/.local/share/applications/
  48. echo "Cleaning folder..."
  49. clean_up
  50. echo "Done."