#!/usr/bin/env ruby
# SpringRoll - SpringBoard beautifier
# by Yanik Magnan - http://r-ch.net/sr
# == Usage
#
# sr [OPTIONS]
#
# backup
# backs up current interface
#
# theme [themename]
# applies the specified theme
#
# restore
# restores backed up interface
#
# smbconv [themename]
# converts SummerBoard themes into SpringRoll themes
#
# -h, --help, help
# shows this help message
require 'rdoc/usage'
require 'fileutils'
=begin
!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! INITIAL SETUP !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!
=end
# Verify to see if user is root.
if ENV['USER'] != 'root' then
raise StandardError, "You must run this as root!"
end
# Determine whether or not the device is running 2.0 (darwin9)
# or 1.1.x (darwin8) by seeing if AppStore exists.
if Dir.entries("/Applications").include?("AppStore.app") then
$ostype = "darwin9"
else
$ostype = "darwin8"
end
# Initialize constants
SR_VERSION = "r8-github"
SB = "/System/Library/CoreServices/SpringBoard.app"
SR = "/var/root/SpringRoll"
APPSTORE_SUPPORT = false
case $ostype
when "darwin8": SLIDER_PREFIX = "/System/Library/Frameworks/TelephonyUI.framework"
when "darwin9": SLIDER_PREFIX = "/System/Library/PrivateFrameworks/TelephonyUI.framework"
end
# Custom preferences
# APPSTORE_IN_NORMALAPPS: Allows exception checking in normal
# /Applications directory, for people who've moved their apps
# there.
if $ostype == "darwin9" and File.exists?("#{SR}/.appstore_in_normalapps") then
APPSTORE_IN_NORMALAPPS = true
else
APPSTORE_IN_NORMALAPPS = false
end
# What's new text
def new
puts <<-new
* WHAT'S NEW in #{SR_VERSION}?
- Web clip support has been added.
Just name icons the name of the webclip,
dot png.
- List all available themes with 'sr list'
- Preliminary support for AppStore apps in
/Applications/
new
end
=begin
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! APPSTORE SUPPORT !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=end
# Warn users that AppStore support is now disabled
if File.exists?("#{SR}/.r8firstrun") then
else
if $ostype == "darwin9" then
puts <<-doc
* SPRINGROLL r8 AND LATER!
Apparently, using this nag message to give
you all important messages is working. Good.
This release removes AppStore support entirely
and rather gives preliminary support for
AppStore applications copied to /Applications.
Much like the previous AppStore support, this
is a preference. If you want to turn it on,
you'll have to run the following command:
touch /var/root/SpringRoll/.appstore_in_normalapps
If you don't know how to do this, then I suggest
you stay away from it.
doc
sleep 10
end
`touch #{SR}/.r8firstrun`
end
# Exceptions hash table courtesy of fujin
Exceptions = {
"CurrencyConverterApp.app" => "CurrencyAppIcon.png",
"SimpleFlashLight.app" => "flashlighticon.png",
"Exposure.app" => "Exposure.png",
"NYTimes.app" => "NYTApplicationIcon.png",
"aSubnet.app" => "logo.png",
"Reviews.app" => "IGN_57x57.png",
"Twitterrific.app" => [ "Icon.png", "Icon_free.png"],
"VNC.app" => [ "vnciconLITE.png", "vncicon.png", "vnciconDEMO.png"],
"SudokuFree.app" => "SudokuFreeIcon.png",
"AOL Radio.app" => "radio.png",
"Flashlight.app" => "appicon.png",
"MySpace.app" => "applicationIcon_prerendered.png",
"WeatherBug.app" => "apple-touch-icon.png",
"YelpIPhone_take5.app" => "yelpicon.png",
"imaze.app" => "maze.png",
"iMmo.app" => "Icon2.png",
"Bubbles.app" => "BubblesIcon.png",
"WritingPad.app" => "WritingPadlogo57X57.png",
"Jott.app" => "jotttouch_icon.png",
"iYardage.app" => "iyardage_icon_57x57_dc.png",
"korebasi lite.app" => "korebasi_icon.png",
"YPmobile.app" => "rubicon.png",
"Mobile News.app" => "apple-touch-icon.png",
"Rhythm.app" => "vSnax_Logo.png",
"WordPress.app" => "application-icon.png",
"RubyRepeat.app" => "rubyrepeat_icon.png",
"Tanjas SOS.app" => "AppIcon.png",
"Save Benjis.app" => "benji_face.png",
"Barcode.app" => "Barcode.png",
"Stanza.app" => "Icon57x57.png",
"Eventful.app" => "eventful-icon.png",
"eReader.app" => "app-icon.png",
"SQLiteBooks.app" => "ToDo_57.png" }
=begin
!!!!!!!!!!!!!!!!!!!!
!!!! BACKUP !!!!
!!!!!!!!!!!!!!!!!!!!
=end
def bakcp(full,base)
print "*** #{base} ... "
FileUtils::cp(full,"#{SR}/Default/#{base}")
print "DONE \n"
end
def backup
# Back up icons, dock, badge, slider resources to the Default theme
puts "* Backing up resources:"
# Change directory to /var/root
puts "** Changing directory to /var/root"
Dir.chdir "/var/root"
# prepare theme directories if nonexistant
puts "** Verifying theme directory structure"
if File.exists?("SpringRoll") == false then
print "*** Creating SpringRoll directory ... "
Dir.mkdir 'SpringRoll'
print "DONE \n"
end
Dir.chdir SR
if File.exists?("Default") == false then
print "*** Creating Default directory ... "
Dir.mkdir 'Default'
print "DONE \n"
end
Dir.chdir "#{SR}/Default"
if File.exists?("Icons") == false then
print "*** Creating Icons directory ... "
Dir.mkdir 'Icons'
print "DONE \n"
end
# NON-ICON EXTRAS
# DOCK
puts "** Backing up Dock resources:"
bakcp("#{SB}/SBDockBG.png","SBDockBG.png")
bakcp("#{SB}/SBDockBG2.png","SBDockBG2.png")
# BADGE
puts "** Backing up Badge resources:"
bakcp("#{SB}/SBBadgeBG.png","SBBadgeBG.png")
# SLIDERS
puts "** Backing up Slider resources:"
slider_rsrc = {
"#{SLIDER_PREFIX}/bottombarknobgray.png" => "bottombarknobgray.png",
"#{SLIDER_PREFIX}/bottombarknobgreen.png" => "bottombarknobgreen.png",
"#{SLIDER_PREFIX}/bottombarknobred.png" => "bottombarknobred.png",
"#{SLIDER_PREFIX}/bottombarbkgndlock.png" => "bottombarbkgndlock.png",
"#{SLIDER_PREFIX}/bottombarlocktextmask.png" => "bottombarlocktextmask.png",
"#{SLIDER_PREFIX}/topbarbkgnd.png" => "topbarbkgnd.png" }
slider_rsrc.each do |src,dest|
bakcp(src,dest)
end
# BATTERY
puts "** Backing up Battery resources:"
(1..17).each do |i|
bakcp("#{SB}/BatteryBG_#{i}.png","BatteryBG_#{i}.png")
end
# STATUSBAR
puts "** Backing up StatusBar resources:"
statusbar_rsrc = {
"#{SB}/Default_BG.png" => "Default_BG.png",
"#{SB}/FSO_BG.png" => "FSO_BG.png",
"#{SB}/FST_BG.png" => "FST_BG.png" }
statusbar_rsrc.each do |src,dest|
bakcp(src,dest)
end
# ICONS
puts "** Backing up application icons:"
Dir.chdir '/Applications'
$apps = Dir.entries('/Applications')
$apps.delete('.')
$apps.delete('..')
while $apps.nitems > 0:
if File.directory?("/Applications/#{$apps[0]}") then
Dir.chdir("/Applications/#{$apps[0]}")
def b_mobilemusicplayer
bakcp('/Applications/MobileMusicPlayer.app/icon-AudioPlayer.png','Icons/MobileMusicPlayer-AudioPlayer.png')
bakcp('/Applications/MobileMusicPlayer.app/icon-MediaPlayer.png','Icons/MobileMusicPlayer-MediaPlayer.png')
bakcp('/Applications/MobileMusicPlayer.app/icon-VideoPlayer.png','Icons/MobileMusicPlayer-VideoPlayer.png')
end
def b_mobileslideshow
bakcp('/Applications/MobileSlideShow.app/icon-Camera.png', 'Icons/MobileSlideShow-Camera.png')
bakcp('/Applications/MobileSlideShow.app/icon-Photos.png', 'Icons/MobileSlideShow-Photos.png')
end
def b_others
basename = $apps[0].gsub('.app','.png')
if APPSTORE_IN_NORMALAPPS == true
# Is the running app an exception?
if Exceptions.has_key?($apps[0]) then
target = Exceptions.fetch($apps[0])
if target.is_a?String
print "*** #{$apps[0]} - #{target} ... "
FileUtils::cp("/Applications/#{$apps[0]}/#{target}","#{SR}/Default/Icons/#{basename}")
puts "DONE"
elsif target.is_a?Array
target.each do |file|
print "*** #{$apps[0]} - #{file} ... "
FileUtils::cp("/Applications/#{$apps[0]}/#{file}","#{SR}/Default/Icons/#{basename}")
puts "DONE"
end
end
else
if File.exists?("icon.png") then
print "*** #{$apps[0]} - icon.png ... "
FileUtils::cp("/Applications/#{$apps[0]}/icon.png","#{SR}/Default/Icons/#{basename}")
puts "DONE"
elsif File.exists?("Icon.png") then
print "*** #{$apps[0]} - Icon.png ... "
FileUtils::cp("/Applications/#{$apps[0]}/Icon.png","#{SR}/Default/Icons/#{basename}")
puts "DONE"
end
end
else
print "*** #{$apps[0]} - icon.png ... "
if File.exists?("icon.png") then
FileUtils::cp("/Applications/#{$apps[0]}/icon.png","#{SR}/Default/Icons/#{basename}")
puts "DONE"
else
puts "NOT FOUND!"
end
end
end
case $apps[0]
when 'MobileMusicPlayer.app': b_mobilemusicplayer
when 'MobileSlideShow.app': b_mobileslideshow
else b_others
end
$apps.shift
else
$apps.shift
end
end
# WEBCLIP ICONS
puts "** Backing up webclip icons:"
if Dir.entries("/var/mobile/Library").include?("WebClips") then
if File.directory?("/var/mobile/Library/WebClips") then
webclips = Dir.entries("/var/mobile/Library/WebClips")
webclips.delete(".")
webclips.delete("..")
webclips.each do |wc|
Dir.chdir("/var/mobile/Library/WebClips/#{wc}")
if File.exists?("icon.png") then
print "*** #{wc_name} ... "
FileUtils::cp("/var/mobile/Library/WebClips/#{wc}/icon.png","#{SR}/Default/Icons/#{wc_name}.png")
puts "DONE"
end
end
end
end
puts "* Backup complete."
puts " To restore, use 'sr restore'."
end
=begin
!!!!!!!!!!!!!!!!!!!
!!!! THEME !!!!
!!!!!!!!!!!!!!!!!!!
=end
def thcp(base, full)
if File.exists?(base) then
print "*** #{base} ... "
FileUtils::cp(base,"#{full}")
print "DONE \n"
else
puts "*** #{base} ... NOT FOUND"
end
end
def theme(theme_name)
# Keep people from screwing their iPhones badly by verifying if the theme is Default.
raise StandardError, "DO NOT USE SPRINGROLL THEME DEFAULT! If you want to restore your backup, use sr restore." if ARGV[1] == "Default"
puts "* Theming interface with theme: #{theme_name}"
# Verify to see if the theme in question exists!
print "** Does the theme even exist to begin with? ... "
Dir.chdir SR
if File.exists?(ARGV[1]) == false then
print "NO \n"
raise StandardError, "The theme you have specified does not exist! Make sure your theme is one word only!"
end
print "YES \n"
# Force the user to run a backup if he/she hasn't yet.
if File.exists?("Default") == false then
puts "** WARNING: I strongly recommend running"
puts " 'sr backup' before doing this to keep"
puts " backup of your UI just in case."
raise StandardError, "Run sr backup to back things up for your own safety."
end
Dir.chdir("#{SR}/#{theme_name}")
# NON-ICON EXTRAS
# DOCK
puts "** Copying dock resources:"
dock_rsrc = {
"Dock.png" => [ "#{SB}/SBDockBG.png", "#{SB}/SBDockBG2.png" ]
}
dock_rsrc.each do |src,dest|
if dest.is_a?Array
dest.each do |realdest|
thcp(src,realdest)
end
end
end
# BADGE
puts "** Copying badge resources:"
thcp("Badge.png","#{SB}/SBBadgeBG.png")
# SLIDERS
puts "** Copying slider resources:"
slider_rsrc = {
"Slider-Gray.png" => "#{SLIDER_PREFIX}/bottombarknobgray.png",
"Slider-Green.png" => "#{SLIDER_PREFIX}/bottombarknobgreen.png",
"Slider-Red.png" => "#{SLIDER_PREFIX}/bottombarknobred.png",
"Slider-bkgndlock.png" => "#{SLIDER_PREFIX}/bottombarbkgndlock.png",
"Slider-textmask.png" => "#{SLIDER_PREFIX}/bottombarlocktextmask.png",
"Slider-topbarbkgnd.png" => "#{SLIDER_PREFIX}/topbarbkgnd.png" }
slider_rsrc.each do |src,dest|
thcp(src,dest)
end
# BATTERY
puts "** Copying battery resources:"
if File.exists?("Battery") then
Dir.chdir("Battery")
(1..17).each do |i|
thcp("BatteryBG_#{i}.png","#{SB}/BatteryBG_#{i}.png")
end
Dir.chdir("..")
else
puts "*** No battery subfolder found."
end
# STATUS BAR
puts "** Copying status bar resources:"
statusbar_rsrc = {
"StatusBar-Default.png" => "#{SB}/Default_BG.png",
"StatusBar-FSO.png" => "#{SB}/FSO_BG.png",
"StatusBar-FST.png" => "#{SB}/FST_BG.png"
}
statusbar_rsrc.each do |src,dest|
thcp(src,dest)
end
# ICONS
if Dir.entries("/var/root/SpringRoll/#{theme_name}").include?('Icons') then
puts "** Copying icons..."
Dir.chdir('/Applications')
$apps = Dir.entries('/Applications')
$apps.delete('.')
$apps.delete('..')
while $apps.nitems > 0:
if File.directory?("/Applications/#{$apps[0]}") then
Dir.chdir("/Applications/#{$apps[0]}")
def t_mobilemusicplayer(theme_name)
if Dir.entries("#{SR}/#{theme_name}/Icons").include?('MobileMusicPlayer-AudioPlayer.png') then
print "*** MobileMusicPlayer-AudioPlayer.png ... "
FileUtils::cp("#{SR}/#{theme_name}/Icons/MobileMusicPlayer-AudioPlayer.png","/Applications/MobileMusicPlayer.app/icon-AudioPlayer.png")
print "DONE \n"
else
puts "*** MobileMusicPlayer-AudioPlayer.png ... "
end
if Dir.entries("#{SR}/#{theme_name}/Icons").include?('MobileMusicPlayer-MediaPlayer.png') then
print "*** MobileMusicPlayer-MediaPlayer.png ... "
FileUtils::cp("#{SR}/#{theme_name}/Icons/MobileMusicPlayer-MediaPlayer.png","/Applications/MobileMusicPlayer.app/icon-MediaPlayer.png")
print "DONE \n"
else
puts "*** MobileMusicPlayer-MediaPlayer.png ... NOT FOUND"
end
if Dir.entries("#{SR}/#{theme_name}/Icons").include?('MobileMusicPlayer-VideoPlayer.png') then
print "*** MobileMusicPlayer-VideoPlayer.png ... "
FileUtils::cp("#{SR}/#{theme_name}/Icons/MobileMusicPlayer-VideoPlayer.png","/Applications/MobileMusicPlayer.app/icon-VideoPlayer.png")
print "DONE \n"
else
puts "*** MobileMusicPlayer-VideoPlayer.png ... NOT FOUND!"
end
end
def t_mobileslideshow(theme_name)
if Dir.entries("#{SR}/#{theme_name}/Icons").include?('MobileSlideShow-Camera.png') then
print "*** MobileSlideShow-Camera.png ... "
FileUtils::cp("#{SR}/#{theme_name}/Icons/MobileSlideShow-Camera.png","/Applications/MobileSlideShow.app/icon-Camera.png")
print "DONE \n"
else
puts "*** MobileSlideShow-Camera.png ... NOT FOUND"
end
if Dir.entries("#{SR}/#{theme_name}/Icons").include?('MobileSlideShow-Photos.png') then
print "*** MobileSlideShow-Photos.png ... "
FileUtils::cp("#{SR}/#{theme_name}/Icons/MobileSlideShow-Photos.png","/Applications/MobileSlideShow.app/icon-Photos.png")
print "DONE \n"
else
puts "*** MobileSlideShow-Photos.png ... NOT FOUND"
end
end
def t_others(theme_name)
basename = $apps[0].gsub('.app','.png')
if APPSTORE_IN_NORMALAPPS == true
# Does the theme have an icon for this app?
if File.exists?("#{SR}/#{theme_name}/Icons/#{basename}") then
# Is the theme an exception?
if Exceptions.has_key?($apps[0]) then
target = Exceptions.fetch($apps[0])
if target.is_a?String
print "*** #{$apps[0]} - #{target} ... "
FileUtils::cp("#{SR}/#{theme_name}/Icons/#{basename}","/Applications/#{$apps[0]}/#{target}")
puts "DONE"
elsif target.is_a?Array
target.each do |file|
print "*** #{$apps[0]} - #{file} ... "
FileUtils::cp("#{SR}/#{theme_name}/Icons/#{basename}","/Applications/#{$apps[0]}/#{file}")
puts "DONE"
end
end
else
if File.exists?("icon.png") then
print "*** #{$apps[0]} - icon.png ... "
FileUtils::cp("#{SR}/#{theme_name}/Icons/#{basename}","/Applications/#{$apps[0]}/icon.png")
puts "DONE"
elsif File.exists?("Icon.png") then
print "*** #{$apps[0]} - Icon.png ... "
FileUtils::cp("#{SR}/#{theme_name}/Icons/#{basename}","/Applications/#{$apps[0]}/Icon.png")
puts "DONE"
end
end
end
else
print "*** #{$apps[0]} - icon.png ... "
if Dir.entries("#{SR}/#{theme_name}/Icons").include?(basename) then
FileUtils::cp("#{SR}/#{theme_name}/Icons/#{basename}","/Applications/#{$apps[0]}/icon.png")
puts "DONE"
else
puts "NOT FOUND!"
end
end
end
case $apps[0]
when "MobileMusicPlayer.app": t_mobilemusicplayer(theme_name)
when "MobileSlideShow.app": t_mobileslideshow(theme_name)
else t_others(theme_name)
end
$apps.shift
else
$apps.shift
end
end
else
puts "** No Icons folder detected. Skipping icons."
end
# WEBCLIP ICONS
puts "** Copying webclip icons:"
if Dir.entries("/var/mobile/Library").include?("WebClips") then
if File.directory?("/var/mobile/Library/WebClips") then
webclips = Dir.entries("/var/mobile/Library/WebClips")
webclips.delete(".")
webclips.delete("..")
webclips.each do |wc|
Dir.chdir("/var/mobile/Library/WebClips/#{wc}")
if File.exists?("icon.png") and File.exists?("#{SR}/#{theme_name}/Icons/#{wc_name}.png") then
print "*** #{wc_name} ... "
FileUtils::cp("#{SR}/#{theme_name}/Icons/#{wc_name}.png", "/var/mobile/Library/WebClips/#{wc}/icon.png")
puts "DONE"
end
end
end
end
`killall SpringBoard`
puts "* Theming complete."
puts " To restore: use 'sr restore'"
puts " Device will respring shortly."
end
=begin
!!!!!!!!!!!!!!!!!!!!!
!!!! RESTORE !!!!
!!!!!!!!!!!!!!!!!!!!!
=end
def restcp(base, full)
print "*** #{base} ... "
FileUtils::cp("#{SR}/Default/#{base}","#{full}")
print "DONE \n"
end
def restore
# Set SpringBoard prefix.
puts "* Restoring backup."
# DOCK
puts "** Restoring original Dock resources:"
restcp("SBDockBG.png","#{SB}/SBDockBG.png")
restcp("SBDockBG2.png","#{SB}/SBDockBG2.png")
# BADGE
puts "** Restoring original Badge resources:"
restcp("SBBadgeBG.png","#{SB}/SBBadgeBG.png")
# SLIDERS
puts "** Restoring original Slider resources:"
slider_rsrc = {
"bottombarknobgray.png" => "#{SLIDER_PREFIX}/bottombarknobgray.png",
"bottombarknobgreen.png" => "#{SLIDER_PREFIX}/bottombarknobgreen.png",
"bottombarknobred.png" => "#{SLIDER_PREFIX}/bottombarknobred.png",
"bottombarbkgndlock.png" => "#{SLIDER_PREFIX}/bottombarbkgndlock.png",
"bottombarlocktextmask.png" => "#{SLIDER_PREFIX}/bottombartextmask.png",
"topbarbkgnd.png" => "#{SLIDER_PREFIX}/topbarbkgnd.png" }
slider_rsrc.each do |src,dest|
restcp(src,dest)
end
# BATTERY
puts "** Restoring original Battery resources:"
(1..17).each do |i|
restcp("BatteryBG_#{i}.png","#{SB}/BatteryBG_#{i}.png")
end
# STATUS BAR
puts "** Restoring original StatusBar resources:"
statusbar_rsrc = {
"Default_BG.png" => "#{SB}/Default_BG.png",
"FSO_BG.png" => "#{SB}/FSO_BG.png",
"FST_BG.png" => "#{SB}/FST_BG.png" }
statusbar_rsrc.each do |src,dest|
restcp(src,dest)
end
# NORMAL APP ICONS
puts '** Restoring application icons:'
Dir.chdir('/Applications')
$apps = Dir.entries('/Applications')
$apps.delete('.')
$apps.delete('..')
while $apps.nitems > 0:
if File.directory?("/Applications/#{$apps[0]}") then
Dir.chdir("/Applications/#{$apps[0]}")
def r_mobilemusicplayer
mmp_rsrc = {
"Icons/MobileMusicPlayer-AudioPlayer.png" => "#{Dir.pwd}/icon-AudioPlayer.png",
"Icons/MobileMusicPlayer-MediaPlayer.png" => "#{Dir.pwd}/icon-MediaPlayer.png",
"Icons/MobileMusicPlayer-VideoPlayer.png" => "#{Dir.pwd}/icon-VideoPlayer.png" }
mmp_rsrc.each do |src,dest|
restcp(src,dest)
end
end
def r_mobileslideshow
mss_rsrc = {
"Icons/MobileSlideShow-Camera.png", "#{Dir.pwd}/icon-Camera.png",
"Icons/MobileSlideShow-Photos.png", "#{Dir.pwd}/icon-Photos.png" }
mss_rsrc.each do |src,dest|
restcp(src,dest)
end
end
def r_others
basename = $apps[0].gsub('.app','.png')
if APPSTORE_IN_NORMALAPPS == true
# Is the running app an exception?
if Exceptions.has_key?($apps[0]) then
target = Exceptions.fetch($apps[0])
if target.is_a?String
print "*** #{$apps[0]} - #{target} ... "
FileUtils::cp("#{SR}/Default/Icons/#{basename}","/Applications/#{$apps[0]}/#{target}")
puts "DONE"
elsif target.is_a?Array
target.each do |file|
print "*** #{$apps[0]} - #{file} ... "
FileUtils::cp("#{SR}/Default/Icons/#{basename}","/Applications/#{$apps[0]}/#{file}")
puts "DONE"
end
end
else
if File.exists?("icon.png") then
print "*** #{$apps[0]} - icon.png ... "
FileUtils::cp("#{SR}/Default/Icons/#{basename}","/Applications/#{$apps[0]}/icon.png")
puts "DONE"
elsif File.exists?("Icon.png") then
print "*** #{$apps[0]} - Icon.png ... "
FileUtils::cp("#{SR}/Default/Icons/#{basename}","/Applications/#{$apps[0]}/Icon.png")
puts "DONE"
end
end
else
print "*** #{$apps[0]} - icon.png ... "
if Dir.entries("#{SR}/Default/Icons").include?(basename) then
FileUtils::cp("#{SR}/Default/Icons/#{basename}","/Applications/#{$apps[0]}/icon.png")
puts "DONE"
else
puts "NOT FOUND!"
end
end
end
case $apps[0]
when 'MobileMusicPlayer.app': r_mobilemusicplayer
when 'MobileSlideShow.app': r_mobileslideshow
else r_others
end
$apps.shift
else
$apps.shift
end
end
# WEBCLIP ICONS
puts "** Restoring webclip icons:"
if Dir.entries("/var/mobile/Library").include?("WebClips") then
if File.directory?("/var/mobile/Library/WebClips") then
webclips = Dir.entries("/var/mobile/Library/WebClips")
webclips.delete(".")
webclips.delete("..")
webclips.each do |wc|
Dir.chdir("/var/mobile/Library/WebClips/#{wc}")
if File.exists?("icon.png") and File.exists?("#{SR}/Default/Icons/#{wc_name}.png") then
print "*** #{wc_name} ... "
FileUtils::cp("#{SR}/Default/Icons/#{wc_name}.png","/var/mobile/Library/WebClips/#{wc}/icon.png")
puts "DONE"
end
end
end
end
# END OF RESTORE
`killall SpringBoard`
puts "* Interface restored."
puts " Device will respring shortly."
end
=begin
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! SUMMERBOARD SUPPORT !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=end
def smbmv(old,new)
if File.exists?(old) then
print "** #{old} -> #{new} ... "
File.rename(old,new)
print "DONE \n"
end
end
def smbconv(theme_name)
# Verify to see if the theme even exists!
if File.exists? "#{SR}/#{theme_name}" then
Dir.chdir("#{SR}/#{theme_name}")
puts "* Renaming status bar:"
smbmv("StatusBar.png","StatusBar-FSO.png")
puts "* Renaming icons:"
# Don't break if the user's theme doesn't have
# an icons folder!
if File.exists?("Icons") then
Dir.chdir("#{SR}/#{theme_name}/Icons")
smbrenames = {
"Calendar.png" => "MobileCal.png",
"Camera.png" => "MobileSlideShow-Camera.png",
"Clock.png" => "MobileTimer.png",
"Contacts.png" => "MobileAddressBook.png",
"Mail.png" => "MobileMail.png",
"Music.png" => "MobileMusicPlayer-AudioPlayer.png",
"Notes.png" => "MobileNotes.png",
"Phone.png" => "MobilePhone.png",
"Photos.png" => "MobileSlideShow-Photos.png",
"Safari.png" => "MobileSafari.png",
"Settings.png" => "Preferences.png",
"Text.png" => "MobileSMS.png",
"Videos.png" => "MobileMusicPlayer-VideoPlayer.png",
"iPod.png" => "MobileMusicPlayer-MediaPlayer.png",
"iTunes.png" => "MobileStore.png" }
smbrenames.each do |old, new|
smbmv(old,new)
end
else
puts "* WARNING! No icon directory found!"
end
puts "* Conversion complete!"
puts " Use 'sr theme #{theme_name}' to"
puts " apply this theme."
else
raise StandardError, "The theme you've specified doesn't exist."
end
end
=begin
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! WEBCLIP SUPPORT !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=end
def wc_name
if File.exists?("Info.plist") then
@wc_plist = open("Info.plist","r")
@counter = 1
@wc_plist.each do |line|
if @counter == 10 then
@wc_name = line.gsub("\t<string>","")
@wc_name.gsub!("</string>","")
@wc_name.chomp!
end
@counter += 1
end
return @wc_name
end
end
=begin
!!!!!!!!!!!!!!!!!!
!!!! LIST !!!!
!!!!!!!!!!!!!!!!!!
=end
def theme_list
if File.exists?(SR) then
if File.directory?(SR) then
themes = Dir.entries(SR)
# Delete system entries or defaults that are not themes!
themes.delete(".")
themes.delete("..")
themes.delete("Default")
themes.delete("AppStoreSupport")
if themes.empty? then
theme_count = 0
puts "* No themes found!"
puts " Try adding something to your"
puts " #{SR} directory!"
else
theme_count = 1
themes.sort!.each do |theme|
# Is the theme a directory?
if File.directory?("#{SR}/#{theme}") then
puts "[#{theme_count}] #{theme}"
theme_count += 1
end
end
puts "* #{theme_count - 1} themes found!"
puts " Apply the theme of your choice by"
puts " running 'sr theme ThemeName'."
end
end
end
end
=begin
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! ARGUMENT PROCESSING !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=end
case ARGV[0]
when nil: RDoc::usage
when 'r': restore
when 't'
raise ArgumentError, "Enter in a theme name." if ARGV[1].nil?
theme(ARGV[1])
when 'b': backup
when 's'
raise ArgumentError, "Enter in a theme name." if ARGV[1].nil?
smbconv(ARGV[1])
when 'l': theme_list
when 'restore': restore
when 'backup': backup
when 'theme'
raise ArgumentError, "Enter in a theme name." if ARGV[1].nil?
theme(ARGV[1])
when 'smbconv'
raise ArgumentError, "Enter in a theme name." if ARGV[1].nil?
smbconv(ARGV[1])
when 'whatsnew': new
when 'list': theme_list
else RDoc::usage
end