Editing the application .plist file

I am creating a sbsettings switch for a cydia application with an on / off button in the settings.

I downloaded "SBsettings Scripty" from the insanely cydia repo, which is a ready-made switch. I need to write a command to execute when the button is on and off.

There are two files for editing:

1- com.mytoggle.toggle1-launch-when-toggle-is-on

It contains by default:

#!/bin/sh rm /var/mobile/Library/Preferences/com.mytoggle.toggle1.flagfile echo "the toggle is now OFF" >>/var/mobile/scripty.txt 

This turns off the switch and writes "now the switch is off" in scripty.txt .

Another file, com.mytoggle.toggle1-launch-when-toggle-is-off, does exactly the opposite: turns on the switch and writes "the switch is now on."

I am trying to replace this script; instead of writing text in a scripty.txt file, I want to change the values ​​in the application .plist.

This is my plist file:

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>something1</key> <false/> <key>something2</key> <false/> </dict> </plist> 

I want to replace </false> with <key>something1</key> by </true> which will enable the button.

+4
source share
1 answer

This is actually a great tool for OS X called PlistBuddy, so you don't need to do crazy sed or perl to update these values. (For more details see his manual ).

Example usage to switch your key with the name "something1" true or false:

 /usr/libexec/PlistBuddy -c "Set :something1 true" /path/to/your.plist /usr/libexec/PlistBuddy -c "Set :something1 false" /path/to/your.plist 

Thus, to solve your problem, simply replace this echo, which prints to "scripty.txt" with the appropriate call to PlistBuddy, to turn this key on or off.

0
source

Source: https://habr.com/ru/post/1493825/


All Articles