katzohki
Posts: 9
Joined: Fri Apr 27, 2012 6:24 pm

RPi Desktop Start v1.0 [OS X applescript app]

Sun Sep 02, 2012 12:27 am

Hi all,
I've created an Applescript to launch lxsession in a X11 environment on the Mac.
It's mostly terminal commands, but it's just a quickie way to start it up. (Requires X11 to be installed) (Also assumes the RPi is @ 192.168.1.10)

Here is the code:

Code: Select all

tell application "X11" to activate

#Open new terminal window in X11
tell application "System Events"
	delay 1
	keystroke "n" using command down
	delay 3
	#login to default IP with default password
	keystroke "ssh -X pi@192.168.1.10" & return
	delay 3
	keystroke "raspberry" & return
	delay 3
	#start GUI
	keystroke "lxsession" & return
end tell
delay 1

# For lack of a better method to minimize front window
tell application "System Events"
	#dirty minimize window
	keystroke "m" using command down
end tell

#hide the Dock
set DockState to (do shell script "defaults read com.apple.Dock autohide")
if (DockState is equal to "0") then
	tell application "System Events"
		keystroke "d" using [command down, option down]
	end tell
end if

#tell application "X11"
#set miniaturized of front window to true
#end tell

#Hide all other programs besides X11
tell application "Finder"
	set visible of every process whose visible is true and name is not "X11" to false
end tell
It's not entirely elegant and I'd like to find a better way to minimize and hide windows (as it relies on a lot of keystrokes).
My plans to improve it for v1.1 would be to allow an interface for setting up the IP of your Pi and the login/pass for it. Preferably it would be a first-run kind of thing where it will ask you to input this info or use defaults the first time it is run. And also to check if X11 is installed and report an error if not (honestly, not a lot of experience in that).

Thanks, and let me know what you guys think.

The executable is here:
https://sites.google.com/site/katzohki/ ... 20v1.0.zip

PS: Yeah, I know there are better ways to do this, such as VNC. I guess that will be RPi Desktop Start v2.0.
PPS: Midori will crash it (at least on mine), but Dillo and Netsurf work. Go to your minimized X11 Xterm to and do a ctrl-c (ctrl-c not command-c) to leave the desktop and logout if you're ready to break connection to your RPi.

Return to “Other programming languages”