views:

20

answers:

1

I'm trying to access command line from a simple Dashboard Widget on Snow Leopard. My intention is to fill the contents of the widget from a command-line script I call. This should be possible.

I'm calling the script every time the widget is shown using it's onshow callback:

if (window.widget) { 
    widget.onshow = onshow; 
} 

function onshow() {
    document.getElementById("mydynamicarea").innerHTML = widget.system("/usr/bin/id -un", null).outputString;
} 

Above I'm trying to use just a simple command showing my username to test the command-line access. This doesn't work, the widget shows just the static text which I have on the HTML:

  <div id="mydynamicarea">No data available</div>

The same Javascript works if I use a static string instead of the widget.system call:

if (window.widget) { 
    widget.onshow = onshow; 
} 

function onshow() {
    document.getElementById("mydynamicarea").innerHTML = "This text is actually shown on widget";
} 

When I look at the Console, I can see this error-message:

TypeError: Result of expression 'widget.system' [undefined] is not a function. 

I have configured the command-line access in info.plist:

<key>AllowSystem</key>
<true/>

Any idea what I'm doing wrong?

A: 

There seems to be some bug in Dashboard. I managed to make the Widget work by renaming it. The widget worked just fine in Dashcode before renaming (thanks, Till Theis) and when I installed it from there with another name it worked. That inspired me to just trying to rename it and that worked as well.

auramo