public
Description: Beautify your SpringBoard on firmware 2.0.
Homepage: http://r-ch.net/sr/
Clone URL: git://github.com/Sakurina/springroll.git
springroll / sr
100755 815 lines (771 sloc) 26.515 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
#!/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