Monday, August 13, 2012

Applescript for Activating Airplay Mirroring on OS X Mountain Lion 10.8

This script activates AirPlay mirroring on OS X Mountain Lion 10.8:

tell application "System Preferences"
set current pane to pane ""
end tell

tell application "System Events"
tell process "System Preferences"
click pop up button 1 of window 1
click menu item 2 of menu 1 of pop up button 1 of window 1
end tell
end tell

tell application "System Preferences"
end tell

Wednesday, May 30, 2012

How to Define Logitech Harmony Favorite Channels in Remote Buddy - Part 1

This is an addon/continuation to the Mac Mini/Harmony Remote guide by Nuno's blog at 

These instructions would not be possible with out Nuno’s comprehensive work done to date. 

Launching a program from the Logitech Harmony remote using Remote Buddy and defining an action key on the remote is shown in Nuno's Blog Episode 3 and 4. Now we’re going to define “Favorite Channels” hot key to switch to TV Channels in EyeTV and launch specific plugins in Plex. To make this happen we need to do a few different tasks.

In remote buddy we create 10 different dummy behaviors HTPC0, HTPC1, HTPC2 ... HTPC9. These 10 different dummy behaviors are used as key press actions in the global behavior. So when you press “Plex TV” on your harmony remote and it sends “Channel 011” to the Mac then Remote Buddy interprets that information via the dummy behaviors and launches Plex and loads your TV show. Or you can press and TV Channel and Remote Buddy launches EyeTV and switches to the TV Channel. 

Here is the overview explanation: 

1. Open Remote Buddy menu and select "Behavior Construction Kit" option. Then select "Behavior Factory"

2. Create a "Scripted Behavior" by clicking "+" button on the bottom left corner. Type the name "HTPC0" and identifier type "HTPC0"

3. Make sure that the behavior you created is not assigned to an application.

4. Make sure that the behavior you created is not assigned to an application.

5. Now repeat these steps (Step 2 to 4) to HTPC1 to HTPC9 where you should have the following script behaviors.

6. Now you have to Compile and install the scripted behavior. To do this, you have to click on the "gear" icon and select "Compile, testdrive, and permanently install Scripted Behavior" as shown below. Note: You have to do this for each dummy behaviors that you created.

7. Open the Remote Buddy menu and select "Preferences" then select "Mapping".
Notice the blank items in the behaviors list, those are the dummy behaviours that we created (HTPC0 to HTPC9) since they do not have any text identifying them we will need to count them from 0 to 9 when we use them. 

8. Now it is time to assign HTPC0 Global Mapping to Logitech Harmony button "0". We will only assign HTPC0. To do this, select "Global mapping" in the preferences and assign "AR154" "Right" button to "Activate HTPC0 Behaviour" key.

9. Next, switch to HTPC0 Behaviour and assign Logitech Harmony 1 Button (AR151-Up) to "Activate HTPC1 Behaviour". Do this for Button 1 to 9. 
Below is the mapped key actions of Plex in Remote Buddy. You should use this keymap to assign behaviors to Harmony buttons.

10. Now you can go to HTPC1 behavior and assign a test action "Activate Plex Behaviour" action for Logitech Button 2. This means that, when you press 012;
  • Remote Buddy will Activate HTPC0 from Global Mapping, because Button 0 is assigned to HTPC0 behavior in Global Mapping. 
  • Using the HTPC0 behavior, Remote Buddy will switch to HTPC1 behavior because Button 1 is assigned to HTPC1 in the HTPC0 Behavior.
  • Finally, Remote Buddy will start Plex because Button 2 (AR151-Down, as shown on the keymap) for HTPC1 is assigned as "Activate Plex Behaviour"

11. Finally, we have to define Favorite Channel 012 in Logitech Harmony Remote Software and add an Plex icon. Below is the screenshots for Logitech Harmony Remote Software:

Saturday, May 19, 2012

Transmission Quit Script in PHP

This PHP CLI script quits transmission after all downloads and seedings are complete. 
Arguments can be passed to the script.

-u (--username): Username for transmission remote access. Default: none 
-p (--password): Password for transmission remote access. Default: none 
-h (--hostname): Hostname transmission remote access runs. Default: localhost 
-t (--port): Port number transmission remote access runs. Default: 9091 

php.exe Transmission_Quit.php --port=9999 --hostname=