Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Development

How to get the user home directory from Javascript?

Author Message
mquesada



Joined: 23 Jan 2009
Posts: 3

Posted: Mon Jan 26, 2009 - 4:13 pm    Post subject: How to get the user home directory from Javascript? Reply with quote

Hi All,

I need to get the user's home directory using Javascript inside the widget, is there any function in the widget object to do this?

Basically I need to get the string "/Users/[current_user]/" from the widget Javascript file.

Any idea would be appreciated!

Thanks!
View user's profile Send private message Send e-mail Widgets
Quill



Joined: 23 Feb 2007
Posts: 11

Posted: Sat Feb 07, 2009 - 6:16 pm    Post subject: Getting the Path to a User's Home Directory Reply with quote

I've written a post on my blog about this very topic: http://quintusquill.com/console/2009/01/getting-the-path-to-a-users-home-directory-in-a-dashboard-widget/.

We can find the path to the user's home directory (e.g. "/Users/steve") by running the Terminal command "echo ~" with "widget.system":

Code:

widget.system("/bin/echo ~", function() {

   var output = this.outputString;

   // Output includes a line break that we have to remove
   var pathToHome = output.replace("\n", "");

};


This code will work regardless of where the widget is located on the computer.

Quill
View user's profile Send private message Send e-mail Visit poster's website Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group