kimmoli

DIY Icons script

May 1st, 2016
362
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Check that we run this as root
  4. whoami | grep -q root || { echo needs to run as root. quitting; exit; }
  5.  
  6. # check that proper scale is given as argument
  7. if [[ ! "$1" =~ "^[0-2]\.[0-9]{1,2}$" ]] ; then
  8.   echo missing argument. give scale, e.g. 1.8. quitting
  9.   exit
  10. fi
  11.  
  12. # Check theme path
  13. if [ -d "/usr/share/themes/sailfish-default/meegotouch/z2.0" ]; then
  14.   THEMEPATH=sailfish-default
  15. elif [ -d "/usr/share/themes/jolla-ambient/meegotouch/z2.0" ]; then
  16.   THEMEPATH=jolla-ambient
  17. else
  18.   echo theme path not found. quitting
  19.   exit
  20. fi
  21.  
  22. # Check is imagemagick installed (this uses mogrify)
  23. if [ ! -f "/usr/bin/mogrify" ] ; then
  24.   echo imagemagick missing
  25.   read -r -p "do you want to install it now? [y/N] " response
  26.   if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
  27.   then
  28.     curl https://openrepos.net/sites/default/files/packages/500/imagemagick-6.8.8-7.armv7hl.rpm -o /tmp/imagemagick.armv7hl.rpm
  29.     if [ ! -f "/tmp/imagemagick.armv7hl.rpm" ] ; then
  30.       echo failed to download imagemagick. quitting
  31.       exit
  32.     fi
  33.     pkcon install-local /tmp/imagemagick.armv7hl.rpm -y
  34.     rm /tmp/imagemagick.armv7hl.rpm
  35.   else
  36.     echo oh ok. quitting
  37.     exit
  38.   fi
  39. fi
  40.  
  41. echo Using $THEMEPATH
  42.  
  43. SCALE=`awk "BEGIN {print $1*100/2.0}"`
  44. echo using scale $SCALE%
  45.  
  46. # copy
  47. echo copying
  48. cp -r /usr/share/themes/$THEMEPATH/meegotouch/z2.0 /usr/share/themes/$THEMEPATH/meegotouch/z$1
  49.  
  50. # rescale
  51. echo rescaling
  52. mogrify -resize $SCALE% /usr/share/themes/$THEMEPATH/meegotouch/z$1/icons/*.png
  53.  
  54. # setting new pixel ratio
  55. echo unlocking pixel-ratio
  56. rm -f /etc/dconf/db/vendor.d/locks/silica-configs.txt
  57. dconf update
  58. su -l nemo -c "dconf write /desktop/sailfish/silica/theme_pixel_ratio $1"
  59.  
  60. # restart lipstick
  61. echo restarting lipstick
  62. systemctl-user restart lipstick
  63.  
  64. echo done
RAW Paste Data