iToggle
iToggle is a spinoff the Services application.
I've added additional controls (Phone, Socks server, Tinyproxy and Auto-lock) and changed the handling of EDGE ON/OFF.
You can download iToggle from here
To
install:
- Unpack
- move "Toggle.app" to "/Applications" in the phone
- Set the execute bit of "Toggle" (chmod +x Toggle)
- Reboot
Implementation notes:
-
Phone on/off starts or stops CommCenter.
-
EDGE is turned on/off by inserting/removing an invalid IP address in the "ip1" interface.
Turning it off is straightforward, turning it back on requires a CommCenter "recycle".
It works with firmware 1.0.2 and 1.1.1 but is not persistent. If you reboot the phone EDGE will be on again.
-
Auto-Lock on/off requires a SpringBoard "recycle"
The Auto-Lock timeout can be modified by editing Info.plist and setting the "AutoLockTimeout" key.
-
Phone, EDGE, Bt, WiFi and Auto-Lock switch controls can be hidden if you don't need some of them.
Info.plist has a key named "ToggleFlags". It holds a number where each bit enables/disables a switch as follows:
0x01 - Phone
0x02 - Edge
0x04 - Bluetooth
0x08 - Wifi
0x10 - Auto-Lock
You can combine them by "ORing" the bits you want. 0x1F (decimal 31) enables them all.
-
Daemons (SSH, Socks server, Tinyproxy or any other) are defined in "daemons.plist".
Edit "daemons.plist" and include any daemon you want. The key names are self explanatory.
If the daemon requires a startup parameter, add a key named "parameters".
SSH, Socks server and Tinyproxy are pre-defined in the "daemons.plist" provided with the package. Remove if you don't want one of them.
A switch for a deamon is shown only if the file is found on the specified path.
The follwoing is a sample of how to define a daemon:
<dict>
<key>label</key>
<string>SSH</string>
<key>processname</key>
<string>sshd</string>
<key>processpath</key>
<string>/usr/sbin</string>
<key>icon</key>
<string>ssh</string>
</dict>
-
Depending on how the daemon was installed it may be controlled by "launchd". If you "turn it off" with iToggle, launchd will restart it.
If that is the case, use "launchctl unload -w ....." or Ulctl to stop automatic restart and use iToggle to start/stop as needed.
Most likely SSH and Tinyproxy are controlled by "launchd".
With iToggle 1.0.5 you can optionally modify "daemons.plist" to support daemons controlled by "launchd".
- Starting with iToggle 1.0.5 daemons controlled by "launchd" can be kept under "launchd" control.
Edit "daemons.plist" and modify it according to the sample below.
The follwoing is a sample of how to define a daemon controlled by "launchd":
<dict>
<key>label</key>
<string>SSH</string>
<key>processname</key>
<string>launchctl</string>
<key>processpath</key>
<string>/Library/LaunchDaemons/com.openssh.sshd.plist</string>
<key>parameters</key>
<string>-w</string>
<key>killbyname</key>
<string>sshd</string>
<key>icon</key>
<string>ssh</string>
</dict>
The key named "killbyname" is optional.
If specified, when a switch of a process controlled by "launchd" is set to off, iToggle sets "launchd" to no longer launch the process and kills all running instances.
If not specified, when a switch of a process controlled by "launchd" is set to off, iToggle sets "launchd" to no longer launch the process.
- Starting with iToggle 1.0.6 scripts or any program can be "launched" by iToggle.
Edit "daemons.plist" and modify it according to the sample below.
The follwoing is a sample of how to define a script controlled by iToggle:
<key>scripts</key>
<array>
<dict>
<key>label</key>
<string>MyScript</string>
<key>scriptname</key>
<string>test.sh</string>
<key>scriptpath</key>
<string>/Applications/Toggle.app</string>
<key>start</key>
<string>-start</string>
<key>stop</key>
<string>-stop</string>
<key>query</key>
<string>-query</string>
<key>icon</key>
<string>ssh</string>
</dict>
</array>
The script must support parameters for the following actions: "start", "stop" and "query".
If "query" returns 0, the Toggle switch is set to "ON" else it is set to "OFF".
When you set the switch to "ON", the script will be invoked with the "start" parameter.
When you set the switch to "OFF", the script will be invoked with the "stop" parameter.
iToggle was written by Marcio C. Almeida based on the original code by Chris Hoffman.
As for license it is DIY, you can choose the license that best fits your needs as long as you don't blame me for anything.
If you don't agree with the above don't download the code.
Changelog:
- 1.0.7 - adjusted to work with firmware 1.1.4
- 1.0.6 - added support to run a script when a toggle switch is pressed
- 1.0.5 - does not enable "Phone switch" if firmware > 1.1.1
added support for daemons controlled by "launchd"
- 1.0.4 - you can now specify any daemon to be started/stopped (see daemons.plist) and you can select switches that are shown.
If you are migrating from version 1.0.3, note that SSHD is no longer started/stopped using "launchctl". Read the implementation notes above.
- 1.0.3 - first public release
MCA's iPhone home