1

I need a terminal to a Linux vm inside my osx installation. Its a dropdown terminal and in the vm I can use F12 as a global hotkey to toggle show/hide.

The name of the dropdown terminal is yakuake, I know there is a dropdown terminal that works with osx to, but for various reasons, I need both a Linux terminal and easy access to it.

There is several things that makes this difficult.

  • VMware fusion doesnt have any good applescript support
  • I need to be able to run several vm's on the same time.
  • Speed
  • Hiding the application.

I am using iKey to get a global hotkey on my mac binded to a little oneliner:

  • /Library/Application\ Support/VMware\ Fusion/vmrun -T fusion -gu username -gp password runScriptInGuest "/Users/username/Documents/Virtual Machines.localized/Ubuntu.vmwarevm/Ubuntu.vmx" -interactive "/bin/bash" "/home/username/bin/toggle_yakuake"

The /home/username/bin/toggle_yakuake script is just a:

  • /usr/bin/xdotool key Control+Shift+Y # Which is what I bound to yakuake

This works, except its taking around 1-2 seconds, and yakuake will show up below every other windows. Therefor I will use logic to just do this if yakuake isnt running, and then I can just hide/show it in osx to toggle it instantly. However, I am able to show yakuake using a simple "tell application "Yakuake - Ubuntu" to activate. I am not able to hide it without hiding every other application belonging to the same vm.

It seems that every application spawned by vmware is tied together a little to tight. Even if I find the pid of yakuake on my osx installastion, and uses it like:

tell application "System Events"
    set yakuakeproc to every process whose unix id is 58518
    repeat with proc in yakuakeproc
        set the frontmost of proc to true
    end repeat
end tell

It will hide every application belonging to that vm.

I have tried to figure out a solution for this for days now. Is there anyone that have any tips or anything? How can I get applescript to hide one specific application which is inside my vm?

xeor
  • 5,301
  • 5
  • 36
  • 59

1 Answers1

0

The way you're starting yakukake is unnecessarily complex. You should be able to simply run the VMware proxy application, rather than using a shell script; i.e. your tell application "Yakukake - Ubuntu" to activate.

Then your only real problem is how to show and hide an application from a script. I think it is possible to do this with System Events, but it's easier to do it with my tool appswitch:

I don't have GUI Linux installed in VMware Fusion but here's an example with Windows.

To view information about a process:

% appswitch -La Notepad 
        PSN   PID TYPE CREA NAME                PATH (bundle identifier)
 15994688.0 24758 APPL ???? Notepad             /Users/nicholas/Library/Application Support/VMware Fusion/Virtual Machines/Boot Camp/Boot Camp.vmwarevm/Applications/Notepad — Windows 7.app (com.vmware.proxyApp.564dbc100b31a4b5-4f8d8088bf0c3705.2009924420)

To hide it:

% appswitch -ha Notepad

To show it:

% appswitch -a Notepad

That's it.

Nicholas Riley
  • 43,532
  • 6
  • 101
  • 124
  • Thanks! [Appswitch](http://sabi.net/nriley/software/) made this better, however, it looks like it have some of the same problems I already been fighting. It brings all of my Linux app to the forground from time to time, example if I have used one Linux app, goes back to firefox, then launch appscript -a, all Linux app will come to front. The same time happens from time to time when sending them to the backound. Maybe its an vmware bug..? It is however kinda usable like this, but will wait for another response. Thanks! – xeor Mar 13 '11 at 19:24
  • Yeah, that sounds more like a Unity bug than anything else. You could try to explicitly hide all the other proxy apps with appswitch (use appswitch -L, grep for com.vmware.proxyApp and run appswitch -hp on each one). There is also some unfortunate flakiness in the underlying OS mechanisms, but I've always been able to work around that by inserting some brief delays. – Nicholas Riley Mar 13 '11 at 20:14
  • I can try that. I am running mostly (if not only) terminal application in this vm, in different yakuake tabs, so I think I am close enough to a workable solution. Thanks! – xeor Mar 13 '11 at 22:12
  • One thing I forgot to mention - you can use `appswitch -f` (in this case, e.g. `appswitch -fa Notepad`) to bring just the frontmost window forward. This depends a lot on the window ordering but it may help (I tested it with two Internet Explorer windows and it seemed to work). – Nicholas Riley Mar 16 '11 at 19:31