2

I have been developing a Cydia tweak called BrightnessControl (I am very new to developing). For now, all it does is use Winterboard to patch var/stash/Applications/Brightness.plist with my modified version. Is there a way, maybe with Theos, that I can patch this file without Winterboard? I am wanting to back this file up somehow and replace it with my modified .plist upon imstall, and then upon un-install delete my modified .plist and restore the original .plist. I have seen something like this done with other tweaks, but I don't know how this is done. May anyone please push me in the right direction?

Brian Kieffer
  • 194
  • 4
  • 11

1 Answers1

2

You don't even need to know programming to do this. The trick is inside the Debian packages' postinst and prerm scripts.

Edit: as per @Nate's comments: beware, because these scripts also run upon updating a package. So, for example, a package with one update which is then removed would do this:

1st installation:
run preinst
(APT installs your package)
run postinst

update:
run prerm of the old version
(APT removes old version)
run postrm of old version

run preinst of new version
(APT installs new version)
run postinst of new version

removal:
run prerm of new version
(APT removes the new version... you no longer have the package)
run postrm of new version
  • Thank you! *kisses your feet* – Brian Kieffer Jul 31 '12 at 06:02
  • Voting up requires 15 rep. :( – Brian Kieffer Jul 31 '12 at 06:33
  • @BrianKieffer thanks (you got an upvote for you question, just in case :) –  Jul 31 '12 at 07:47
  • 1
    +1 on behalf of @BrianKieffer :). Unless doing so is going to mess up your chances for an **Unsung Hero** badge (in which case, let me know and I'll unvote!). One more note regarding the `rm` scripts: I got bitten once because I didn't realize that the `rm` scripts (at least `postrm`, I would assume `prerm`, too) also get run when **updating** an app. Cydia (via `dpkg`) does something like an uninstall of the old version, and an install of the new version. If I remember correctly, the order of those was also screwy, so be sure to test well if you have stuff in the uninstall scripts! – Nate Aug 01 '12 at 01:40
  • @Nate thank you! No, I think I don't have chance for that badge anyway :P (I am rather willing to get a Legendary one...) Anyway, your comment was useful so I'll update my answer. –  Aug 01 '12 at 04:40
  • I managed to get the files patched fine on install/uninstall/re-install/upgrade. I checked [ -z "$2" ] to see if the package is getting upgraded or re-installed to dodge the upgrade/re-install problems. Thanks again! The patching is flawless, although it took me many attempts to get it just right! – Brian Kieffer Aug 02 '12 at 03:00
  • @BrianKieffer no problem, and be prepared to encounter more and more standard Unix tools on iOS ;) –  Aug 02 '12 at 05:52