IScript

From AwkwardTV
Jump to: navigation, search

iScript is an AppleTV (ATV) plugin that allows the user to execute shell script. and also works as an application menu. WORKS ONLY ON TV 2.0.
If I forgot to mention something, please tell me
Now with Mouse Locator Support.

I also have an installer ready to install Perian and Mouse Locator for the people who don't want to do it themselves. If you guys want, i'll post it

iScript
version 1.2.2
June 6, 2008
http://iscripts.googlecode.com/files/Scripts-1.2.2.tar.gz //New Location: googlecode
added installer ... small installer ... very basic... once you choose what you want to install click and wait it can take up to a min or more depending on your connection.
It's just an easier way to install mouse locator
http://iscripts.googlecode.com/files/iinstaller.tar.gz // does not work properly yet
source is there too

Copyright (C) 2008 Thomas Cool

Installation

  1. download the file Scripts-1.2.2.tar.gz,
  2. extract it this should give you a folder Scripts.frappliance
  3. put it on your TV
  4. install it to the plugins folder (/System/Library/CoreServices/Finder.app/Contents/Plugins/)
  5. restart finder


the shell script install.sh* is a script you can run to set up mouse locator preferences, remove old versions of iscript and install the new one

  • the file needs to be in a folder called Scripts-1.2.2 directory to work properly

Self-Extracting Archive

  1. Download the file Scripts-1.2.2.sh
  2. Transfer the file to your TV
  3. Execute ./Scripts-1.2.2.sh
  4. It will not ask anymore questions
  5. restart the Finder or the TV sudo shutdown -r now will restart

Use

Finder Coming back when app Quit

There are now two ways to launch applications from app.plist if the identifier prefix is scripts-applsn- , then the Program will Launch in the new method: It will Launch the program, hide the finder, wait for the app to quit then come back to the finder. In the meantime, all remote control commands sent will be to the frontmost application running ... for you eyetv and vlc users ...
Unfortunately, in theory, for this to work, you need to have the path to the binary as such

<?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">
<array>
<dict>
		<key>identifier</key>
		<string>scripts-applsn-/Users/frontrow/Applications/Firefox.app/Contents/MacOS/firefox</string>
		<key>name</key>
		<string>Firefox2</string>
		<key>preferred-order</key>
		<real>102</real>
	</dict>
	<dict>
		<key>identifier</key>
		<string>scripts-applsn-/Users/frontrow/Applications/VLC.app/Contents/MacOS/VLC</string>
		<key>name</key>
		<string>VLC</string>
		<key>preferred-order</key>
		<real>103</real>
	</dict>
</array>
</plist>

Important

The programs should still work if you point to the .app file

	<dict>
		<key>identifier</key>
		<string>scripts-applsn-/Users/frontrow/Applications/VLC.app</string>
		<key>name</key>
		<string>VLC</string>
		<key>preferred-order</key>
		<real>103</real>
	</dict>

This will also work and has been tested with firefox and vlc. unfortunately, it only works for programs that have, in **.app/Contents/MacOS/** (which i think is all of them)

This means that if you launch an app this way, The finder will remain stuck till you quit the App itself. If you want to keep an app running in the background, i would recommend launching it the old way with scripts-appls-- as prefix


Firefox works, no matter if you use firefox-bin or firefox (tested on firefox3 RC3)

Mouse Locator Support

If you have the .prefpane installed in the correct location and the mac cursor, it will set up the preferences and launch it for you. no need to try to access system preferences
no need to install system preferences.
in any case for manual install of mouse locator follow the wiki till step 3 included

Application Menu Functionality


as of version 1.2 IScript also has Applications support.
it works on the same principle as its scripts functionality. Unfortunately you have to make the .plist yourself The Plist has to be called apps.plist and has to be located in the Scripts directory
you can launch an application using the menu option and then you go to show/hide to ... obviously show hide the finder
Important
The Application Menu functionality is still very basic: you can launch applications but you have to then manually hide the finder. In the next release i will make it hide itself using another variable in the plist.
you cannot use the remote while the finder is hidden. To return to the frontrow menu, just press any remote key then play. in effect, you're selection Show/Hide again.
apps.plist location is ~/Documents/Scripts/apps.plist

Scripts Menu Functionality

BuiltIn Scripts


Builtin Scripts are three scripts that already come with the frappliance
Reboot: simply Reboots the TV
Populate: scans the folder ~/Documents/Scripts/ for files ending in .sh and creates a plist for you: this needs only be done when you add new scripts to the folder
Help: well.... helps you

Self Made Scripts


Self Made Scripts are scripts that will be in the ~/Documents/Scripts Folder
Script file name CANNOT include space (for populate to work)
they will be added to the list when you run Populate.
Please make sure they have the extension .sh
they will NOT run as root so if you want it to execute code with sudo, you need to add echo "frontrow" | sudo -S command under the shell descriptor

Example Script

This would be a script for people who want to load TVComposite only some of the time

#!/bin/bash 
# 
## script 1
## Author: tomcool420
echo "frontrow" | sudo -S command
sudo kextload /System/Library/Extensions/TVComposite.kext

Name it TVComposite.sh drop it in your ~/Documents/Scripts folder, populate and you're set to go

plist Format for Apps

<?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">
<array>
	
	<dict>
		<key>identifier</key>
		<string>scripts-appls--/Users/frontrow/Applications/Chmox.app</string>
		<key>name</key>
		<string>Chmox</string>
		<key>preferred-order</key>
		<real>101</real>
	</dict>
	<dict>
		<key>identifier</key>
		<string>scripts-appls--/Users/frontrow/Applications/firefox.app</string>
		<key>name</key>
		<string>Firefox</string>
		<key>preferred-order</key>
		<real>102</real>
	</dict>
	</array>
</plist>


the location of apps.plist is also ~/Documents/Scripts/apps.plist
Identifier is again the important part, i'll make it easier to write later but for now it's like this
the first part of the identifier is scripts-appls-- (two dashes at the send so it is the same length as for scripts -- I'm lazy.) that is APPLS in lowercase.
the second part is the path to the Application itself. As opposed to the old method, you just point to the .app itself.

plist Format for Scripts

<?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">
<array>
	<dict>
		<key>identifier</key>
		<string>scripts-scripts-Treboot</string>
		<key>name</key>
		<string>Treboot</string>
		<key>preferred-order</key>
		<real>110</real>
	</dict>
	<dict>
		<key>identifier</key>
		<string>scripts-script-TVCompositeLoad</string>
		<key>name</key>
		<string>TVCompositeLoad</string>
		<key>preferred-order</key>
		<real>111</real>
	</dict>
	<dict>
		<key>identifier</key>
		<string>scripts-script-TVCompositeUnLoad</string>
		<key>name</key>
		<string>TVCompositeUnLoad</string>
		<key>preferred-order</key>
		<real>112</real>
	</dict>
</array>
</plist>


To be honest, you only really need

<dict>
      <key>name</key>
      <string>$thename</string>
</dict>

For each item


identifier is for when you want to have a different show up than the script name
In that case you put the name you want to see in <key>name</key>
and assuming the script filename is theScript.sh, you would put scripts-script-theScript in <key>identifier</key>
the preferred-order simply set the order of the scripts. populate, will make it alphabetical
unfortunately for now, populate overrides manually entered settings
for information, the script reboot has a value of 150, populate 199 and help 200

To do

  • use NSPipe do get the return of the shell script -- have an idea how to do that -- done
  • modify it so it can open applications -- easy to do but -- done
    • I have no idea how to either hide the Finder and make it come back with remote --done will be improved
    • Quit the Finder without having it restart -- ignored
  • Need to make the plist easier to make with more options
  • Make it setup Mouse Locator easily
  • and anything else people want me to try

License

NOT TO BE DISTRIBUTED COMMERCIALLY WITHOUT AUTHOR AGREEMENT


Copyright (C), 2008 Thomas Cool iScript is licensed under GPL3. The full license can be found in LICENSE.txt.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/

Notice

This frappliance works perfectly well on my TV 2.0 but it is my first release and: This program is provided at your own risk. The author claims no responsibility for any damage or other outcome that may occur from use of this software. The author is not affiliated with Apple, Inc.

Acknowledgements

Thanks to person who made FRAppliance 200 which in turn is based on the work of alan_quatermain
thanks to gbooker who didn't laugh at my stupid questions in the forum
If i forgot someone, please feel free to yell at me in a PM

Versions


1.2.2: Auto Hide and Show Finder If you want
1.2.1: If you have mouse Locator Installed, it will set it up properly for you launch/Quit it when you use show/hide.. Bonus also installs killall
1.2: Support for Applications, restoring basic Applications Menu functionality to ATV2.0. Change of Plugin Format
1.1: Support for the standard and error output of shell scripts
1.0: release