Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Script for automatically making use of the right logo version, according to the iDevices screen resolution
- #You may use this script in your own package but please don't remove this comment
- #this script was written by Niels Muendler (nielstron)
- #the screen scale (ie 1 for normal screens, 2 for @2x and 3 for @3x) is read from gsc.main-screen-scale
- model=$(dpkg -s gsc.main-screen-scale | grep -i -e "Version" | cut -b 10- )
- #the following is made functions because... well I hope that it's improving readability
- function mvall2x () {
- #rename all @2x versions to normal versions
- for j in $(seq 0 $count)
- do
- #but only if the files really exists (it double checks here, don't want to loose any important files )
- if test -e "$j@2x.png"
- then
- mv -v -f "$j@2x.png" "$j.png"
- fi
- done
- }
- function mvall3x () {
- #rename all @3x versions to normal versions
- for j in $(seq 0 $count)
- do
- #but only if the files really exists (it double checks here, don't want to loose any important files and yes I DID copy pasta here)
- if test -e "$j@3x.png"
- then
- mv -v -f "$j@3x.png" "$j.png"
- #if there's no @3x version just use the @2x version
- elif test -e "$j@2x.png"
- then
- mv -v -f "$j@2x.png" "$j.png"
- fi
- done
- }
- #if the end device isn't anything exit with error status
- if test -z $model
- then
- exit 1
- fi
- #Go to the Boot Logo home dir
- cd /Library/BootLogos/
- #read all folders and send them to the while loop
- #run the following for each folder in this dir
- ls --hide="*.*" ./ | while read dir
- do
- #enter the dir
- cd "/Library/BootLogos/$dir"
- #read the amount of logos in this dir and save it to $count
- i="0"
- count="0"
- while test -e "$i.png"
- do
- count="$i"
- i=$(expr $i + 1)
- done
- #if the screen scale is 1
- if test $model = "1"
- then
- #do nothing
- echo ""
- #if the screen scale is 2
- elif test $model = "2"
- then
- #use @2x logos
- mvall2x
- #for future compatibility reasons do this for every other screen scale (>= 3)
- else
- #use @3x logos
- mvall3x
- fi
- #remove all remaining @2x and @3x logos to save disk space (there are no @2x logos left on generation 4 to 6 and no @3x logos left on the 6+)
- # note: this actually removes everything but the logos 0.png-n.png
- #do so by reading all files except 0.png-n.png and send them to the while loop
- ls ./ | grep -v -i "[0-9].png") | while read k
- do
- rm -f "$k"
- done
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement