<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mac Developer Tips &#187; System</title>
	<atom:link href="http://MacDeveloperTips.com/category/system/feed" rel="self" type="application/rss+xml" />
	<link>http://MacDeveloperTips.com</link>
	<description>Tips, tools and code for iPhone and Mac developers.</description>
	<lastBuildDate>Thu, 12 Aug 2010 23:45:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Comparing Directories</title>
		<link>http://MacDeveloperTips.com/system/comparing-directories.html</link>
		<comments>http://MacDeveloperTips.com/system/comparing-directories.html#comments</comments>
		<pubDate>Thu, 29 May 2008 13:02:45 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://MacDeveloperTips.com/system/comparing-directories.html</guid>
		<description><![CDATA[The typical use of diff from within a terminal (using the default Bash shell) is to compare files. However, with a little slight of hand, known a process substitution, we can use diff to compare the contents of two directories. The syntax looks as follows: &#60;(commands) &#62;(commands) Commands represents a single command (such as find) [...]]]></description>
			<content:encoded><![CDATA[<p>The typical use of <em>diff</em> from within a terminal (using the default Bash shell) is to compare files. However, with a little slight of hand, known a process substitution, we can use <em>diff</em> to compare the contents of two directories.</p>
<p>The syntax looks as follows:</p>
<p><em>&lt;(commands)  </em></p>
<p><em>&gt;(commands)  </em></p>
<p><em>Commands</em> represents a single command (such as find) or a piped list of commands. The end result of using process substitution is that the commands act as a file. In the first example, the process substitution results in what looks like a file that can be fed into another command. The second example is the opposite, the process substitution enables one or more commands to act as a file for input. Let&#8217;s look at how we can use process substitution for comparing directories.</p>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/05/diff1.png" /></p>
<p>Let&#8217;s say we want to compare the contents of the two directories above. The screenshot was captured from Finder, and in this case, provides a concise view of each directory. However, if the directories are not as conveniently located (in the same sub-directory) or have many more files, or if you need to compare directories from within a terminal, then you could run the following from a terminal:</p>
<p>$ <font color="#800000"><em>diff &lt;(find tmp1) &lt;(find tmp2)</em></font></p>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/05/diff2.png" /></p>
<p>Here we use the <em>find</em> command to walk through the directories. Using the process substitution, the results of the <em>find</em> command look as though they are files, which enables us to feed both into <em>diff</em>.</p>
<p>You can learn more about process substitution on the Bash man page at the <a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/bash.1.html" target="_blank">Apple Developer Connection</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://MacDeveloperTips.com/system/comparing-directories.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Login Screenshot Challenge &#8211; Part 3</title>
		<link>http://MacDeveloperTips.com/system/login-screenshot-challenge-part-3.html</link>
		<comments>http://MacDeveloperTips.com/system/login-screenshot-challenge-part-3.html#comments</comments>
		<pubDate>Fri, 16 May 2008 13:02:58 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[screenshot]]></category>

		<guid isPermaLink="false">http://MacDeveloperTips.com/system/login-screenshot-challenge-part-3.html</guid>
		<description><![CDATA[As explained on the previous post, no doubt there is a means to capture a screenshot of the login screen, including all available user names. The question is, how to get there from here? Brett on the Cocoa developer mailing list provided a link to OpenGLScreenSnapshot, which is a Mac OS X application that demonstrates [...]]]></description>
			<content:encoded><![CDATA[<p>As explained on the <a href="http://macdevelopertips.com/system/login-screenshot-challenge-part-2.html" target="_blank">previous post</a>, no doubt there is a means to capture a screenshot of the login screen, including all available user names. The question is, how to get there from here? Brett on the <a href="http://lists.apple.com/mailman/listinfo/cocoa-dev" target="_blank">Cocoa developer mailing list</a> provided a link to <a href="http://developer.apple.com/samplecode/OpenGLScreenSnapshot/index.html" target="_blank">OpenGLScreenSnapshot</a>, which is a Mac OS X application that demonstrates how to use OpenGL to grab a snaphost of the screen and save it to an image.</p>
<p>The example is an Xcode project which is easily imported and ran from with Xcode. The only problem is that the short example uses a menu to invoke the screencapture, so there is no means to logout and invoke the application.</p>
<p>I imagine the code change to make this an application that can be run from a terminal (at which point it could be run in the background using <em>sleep</em>) is trivial. However, problem is, I haven&#8217;t spent any time working with Xcode so it may take some time to figure this out.</p>
<p>Needless to say, it&#8217;s been an interesting challenge to try and capture the login screen. As I mentioned before, I think we&#8217;re 99% of the way there and if anyone can take the above example and make a command line version of the application, who knows, maybe that will bring this thing full circle.</p>
<p>It&#8217;s been a great diversion. So what&#8217;s the next challenge we can take on ?</p>
]]></content:encoded>
			<wfw:commentRss>http://MacDeveloperTips.com/system/login-screenshot-challenge-part-3.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Login Screenshot Challenge &#8211; Part 2</title>
		<link>http://MacDeveloperTips.com/system/login-screenshot-challenge-part-2.html</link>
		<comments>http://MacDeveloperTips.com/system/login-screenshot-challenge-part-2.html#comments</comments>
		<pubDate>Wed, 14 May 2008 12:21:27 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[screenshot]]></category>

		<guid isPermaLink="false">http://MacDeveloperTips.com/system/login-screenshot-challenge-part-2.html</guid>
		<description><![CDATA[Part 2 in a series on how to capture a screenshot of the the login screen on Mac OS X.]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://macdevelopertips.com/system/login-screenshot-challenge.html" target="_blank">Part 1 of this series</a> I described my attempts to get a screenshot of the login screen on Mac OS X. The attempts included using hotkeys, Grab application, fast user switching and putting the system to sleep and using the terminal utility &#8216;screencapture.&#8217; All to no avail. The real challenge at hand is that I am looking to accomplish this feat from just one Mac system.</p>
<p>There were several ideas shared by others, including using cron, apple remote desktop and ssh. Again, good intentions, however, no luck.</p>
<p>I was able to dig up one approach that get that gets us 99% of the way there. From a terminal, I can enter the following, where I specify the login name using the switchToUserID parameter:</p>
<p><font color="#800000"><em>/System/Library/CoreServices/&#8221;Menu Extras&#8221;/User.menu/Contents/Resources/CGSession -switchToUserID `id -u root`. </em></font></p>
<p>The last parameter <font color="#800000"><em>`id -u root`</em></font> uses the terminal command <em><font color="#800000">id</font></em> to convert a user name to a number. Upon running this command, a login window is popped up for the login id specified, see the figure below.</p>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/05/login1.png" /></p>
<p>If I change the login id to another user, the login window changes as well:</p>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/05/login2.png" /></p>
<p>The 1% that remains is that what I really hope to capture is the login window where all available login ids are shown.</p>
<p>There is a related command (below) that displays the login window I am after, however, this brings me back to the same problem I started with, that is, no means to get a screenshot.</p>
<p><font color="#800000"><em>/System/Library/CoreServices/&#8221;Menu Extras&#8221;/User.menu/Contents/Resources/CGSession -suspend</em></font></p>
<p>With some further digging I was able to successfully get the screenshot that I&#8217;m after with a couple of approaches:</p>
<ol>
<li>Using a screen recording program such as ScreenFlow: enable fast user switching, start the recording and select the <em>login window</em> option from the fast user switching dialog. This will capture the sequence of events including the elusive login window.</li>
<li> I also found a few screenshot applications that can successfully capture the login window while running in the background. For example, Christian at <a href="http://www.monkeybreadsoftware.de/Freeware/TimedScreenshot.shtml" target="_blank">MonkeyBread Software</a> wrote a freeware application in REALbasic <a href="http://www.monkeybreadsoftware.de/Freeware/TimedScreenshot.shtml" target="_blank">TimedScreenshot</a> (<a href="http://www.monkeybreadsoftware.de/Freeware/TimedScreenshot-source.shtml" target="_blank">here&#8217;s the source code</a>) that will capture the screenshot I am after:</li>
</ol>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/05/login3.png" /></p>
<p>So, it&#8217;s obvious we can get there from here. The question that remains is, what system level API/library can we call to make this happen?</p>
<p>Ideally I&#8217;d like to have a very simple application, written in as few lines of code as possible, using tools that are freely available (e.g. Xcode or even better, just terminal commands). If this involves running a program in the background using a terminal command such as <em>sleep</em> (as I did with <em>screencapture</em> in the <a href="http://macdevelopertips.com/system/login-screenshot-challenge.html" target="_blank">previous post</a>), that works for me.</p>
<p>Any developers (Cocoa or otherwise) who can take this challenge the last mile?</p>
]]></content:encoded>
			<wfw:commentRss>http://MacDeveloperTips.com/system/login-screenshot-challenge-part-2.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Login Screenshot Challenge &#8211; Part 1</title>
		<link>http://MacDeveloperTips.com/system/login-screenshot-challenge.html</link>
		<comments>http://MacDeveloperTips.com/system/login-screenshot-challenge.html#comments</comments>
		<pubDate>Mon, 12 May 2008 07:08:33 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[screenshot]]></category>

		<guid isPermaLink="false">http://MacDeveloperTips.com/system/login-screenshot-challenge.html</guid>
		<description><![CDATA[Capturing a screenshot of the login screen in Mac OS X Leopard appears to be something of a trick. Join this challenge on how to capture this elusive screenshot.]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://macdevelopertips.com/system/working-as-root.html" target="_blank">last post</a> I was showing various options for working with the root account. Near the end of the post I was planning to show how when logging in as root, the login dialog does not offer <em>root</em> as one of the available login names.</p>
<p>Attempting to capture the login screen has been an interesting diversion. Up to this point I&#8217;ve been unsuccessful in capturing the elusive screenshot.</p>
<p>So here&#8217;s a challenge for you&#8230;can you be the first to figure out how to capture a screenshot of the login screen for the root account? There are a couple of ground rules:</p>
<ol>
<li>You must be running Leopard (or at a minimum, the solution must work on Leopard).</li>
<li>I&#8217;d like this to be a &#8220;free&#8221; solution, as in, no software to buy.</li>
<li>Finally, I am looking for a solution that doesn&#8217;t require more than one Mac (e.g. using SSH from one Mac to another).</li>
</ol>
<p>To save you some time, I&#8217;ve listed below the options I&#8217;ve tried:</p>
<p><strong>Attempt #1</strong> &#8211; Hotkeys<br />
From the login screenscreen, I tried the following hotkeys:</p>
<p>- Shift+Command+3 (capture entire screen to file)<br />
- Control+Shift+Command+3 (capture entire screen to clipboard)<br />
- Shift+Command+4 (capture area defined with mouse to file)<br />
Each of the above greeted me with a pleasant beep, nothing more.</p>
<p><strong>Attempt #2</strong> &#8211; Grab application<br />
My next attempt was to try the timed capture option with the Grab application. Seemed like a clever idea, however, when I started the timer and logged out (to get to the login screen), Grab just seems to quietly go away. No warning, no error, no screenshot.</p>
<p><strong>Attempt #3</strong> &#8211; Fast Switching<br />
Next, I enabled fast user switching. My thinking was, maybe if I don&#8217;t logout per se, and request the Login Window (see the figure below) that the login screen might somehow be different (as in, something I can capture using hotkeys):</p>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/05/screenshot1.png" style="max-width: 800px" /></p>
<p>Seemed logical, however, first notice that the root account doesn&#8217;t show up in the list of available accounts. Next, upon choosing Login Window I was shuffled over to the same login screen as if logging out. No luck.</p>
<p><strong>Attempt #4</strong> &#8211;  Getting a little more creative, I tried this from within a terminal:</p>
<p><font color="#800000"><em>screen -d -m bash -c &#8220;sleep 30; screencapture /Users/John/login.png&#8221;</em></font></p>
<p>This option uses a screen manager (more on that in an upcoming post) and calls the screencapture application after sleeping for 30 seconds. Once I ran this option from a terminal, I quickly logged out and patiently waited&#8230;I heard the camera sound of the screencapture application and was psyched, &#8220;yes!&#8221;&#8230;I navigated to my home directory and located the file login.png&#8230;I opened the file with the Preview application&#8230;and much to my dismay&#8230;it was an image alright&#8230;a big, black, blank image. So close, but no cigar.</p>
<p>So, now it&#8217;s up to you. Can you figure what it takes to capture the login screenshot? You can submit your idea as a comment (below) or <a href="http://macdevelopertips.com/?page_id=91" target="_blank">drop me an email</a>. And please verify your trick works with Leopard, as other published solutions I&#8217;ve found seem to work only on releases prior to Leopard.</p>
<p>I&#8217;m doing my best to see if I can find a volunteer to donate a prize (software, book, t-shirt, etc). If that doesn&#8217;t come through, what I can offer is a little lime-light, blog style. If you are the first to contact me with a solution (within the parameters above), we can collaborate on a post where you can tell the world how you got so smart :)  and share your bio, picture, blog/website, etc.</p>
<p>If anyone reading is interested in donating a prize, <a href="http://macdevelopertips.com/?page_id=91" target="_blank">contact me</a> and we&#8217;ll get the ball rolling.</p>
<p>I am very intrigued to see if/how this can be done.</p>
]]></content:encoded>
			<wfw:commentRss>http://MacDeveloperTips.com/system/login-screenshot-challenge.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Working as Root</title>
		<link>http://MacDeveloperTips.com/system/working-as-root.html</link>
		<comments>http://MacDeveloperTips.com/system/working-as-root.html#comments</comments>
		<pubDate>Fri, 09 May 2008 07:08:07 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[sudo]]></category>

		<guid isPermaLink="false">http://MacDeveloperTips.com/system/working-as-root.html</guid>
		<description><![CDATA[Working with the root account on Mac OS X.]]></description>
			<content:encoded><![CDATA[<p>Root is the uber system account. Although handy at times (for example when installing applications), it&#8217;s generally recommended that root not be used as your everyday login. What follows are some options for working as root.</p>
<p>If you need to run a command as root, you can use the sudo command. For example, to run the script for daily system maintenance, you can run this command (the $represent the terminal prompt):</p>
<p><font color="#800000"><em>$ sudo periodic daily</em></font></p>
<p>Now that&#8217;s all well and good, however, it&#8217;s generally applicable only for one command. What if you are in a terminal and want to login as root to do some larger scale maintenance or system work? Try this:</p>
<p><font color="#800000"><em>$ sudo -s</em></font></p>
<p>This command will enable the root account and update your prompt as shown in the figure below:</p>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/05/sudo1.png" /></p>
<p>The above screenshot assumes you are using the bash shell and have admin rights on the account you are logged in with. The $ typically represents a user account whereas # represents root.</p>
<p>The last option is to create/enable a root account, thus you can login (when restarting/rebooting) as root. This approach offers the most flexibility and power, however, use with caution as there are no limits to what (damage) you can do.</p>
<p><strong>Root account option #1</strong>:  Enter the following from a terminal:</p>
<p><font color="#800000">$ dsenableroot</font></p>
<p>You&#8217;ll be prompted for your (current) password, as well as the new root password.</p>
<p><strong>Root account, option #2</strong>:  Enter the following from a terminal:</p>
<p><font color="#800000">$ sudo passwd</font></p>
<p>You&#8217;ll be prompted for the same series of passwords as above.</p>
<p><strong>Root account, option #3</strong>:  Follow the steps below:</p>
<p>- Start the Directory Utility application (/Applications/Utilities/Directory Utility)<br />
- Click the lock icon in the lower left corner (to unlock it)<br />
- From the Edit menu (across the top of screen), select <em>Enable Root User</em></p>
<p>To wrap up this post I was planning to show you how the login window changes when a root account is enabled. Unlike other accounts on your system where a name is typically displayed as one of the login options, the root account is not listed as one of the options (for security reasons).</p>
<p>However, getting a screenshot of the login screen is a considerable feat. This is a great segue to a post coming next week where I&#8217;ll show the tricks that I tried for capturing the elusive login screen and I will pose an intriguing challenge for you&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://MacDeveloperTips.com/system/working-as-root.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing an Application Icon</title>
		<link>http://MacDeveloperTips.com/system/changing-an-application-icon.html</link>
		<comments>http://MacDeveloperTips.com/system/changing-an-application-icon.html#comments</comments>
		<pubDate>Fri, 02 May 2008 12:03:50 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[screencast]]></category>

		<guid isPermaLink="false">http://MacDeveloperTips.com/system/changing-an-application-icon.html</guid>
		<description><![CDATA[Screencast on how to change an application icon on Mac OS. X]]></description>
			<content:encoded><![CDATA[<p>One of the defining concepts of working on a Mac is that things (usually) work just as you think they should. This is the culmination of good design translated into working code. The short video that follows is an example demonstrating how easy and intuitive it is to change the icon for an application. Believe it or not, it&#8217;s as simple as copy/paste.</p>
<p><a href="javascript:lynkVideoPop(719,'1209684113');" class="lynkvp"><img src="http://macdevelopertips.com/wp-content/uploads/2008/05/change-icon.png" /></a></p>
<p>This is a great trick to have up your sleeve when working with development tools that create a default icon, for example the Script Editor. With this approach you can quickly change an icon to reflect that something visually represents what the application does. And to help, do a quick search on Google for <font color="#800000"><em>Mac OS X icons</em></font> and you&#8217;ll be amused for hours&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://MacDeveloperTips.com/system/changing-an-application-icon.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Multiple Monitors, Moving Menu Bar</title>
		<link>http://MacDeveloperTips.com/system/multiple-monitors-specifying-menu-location.html</link>
		<comments>http://MacDeveloperTips.com/system/multiple-monitors-specifying-menu-location.html#comments</comments>
		<pubDate>Mon, 28 Apr 2008 13:02:01 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://MacDeveloperTips.com/system/multiple-monitors-specifying-menu-location.html</guid>
		<description><![CDATA[Working with multiple monitors is a must when doing any serious coding work. Code on one side, output on the other. No more swapping applications from the foreground to background. Mac OS X make working with multiple monitors a snap: plugin in the secondary monitor, open System Preferences, click on Displays, click on the Arrangement [...]]]></description>
			<content:encoded><![CDATA[<p> Working with multiple monitors is a must when doing any serious coding work. Code on one side, output on the other. No more swapping applications from the foreground to background.</p>
<p>Mac OS X make working with multiple monitors  a snap: plugin in the secondary monitor, open System Preferences, click on Displays, click on the Arrangement tab and arrange the displays by dragging and dropping. That&#8217;s it. In the figure below the larger box is the secondary monitor (larger view area) and the smaller is my laptop.</p>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/04/prefs1.png" /></p>
<p>There is one default setting that I want to mention here that hopefully will save you some time. When you set up an additional monitor the menu bar stays on the original display. Depending on your arrangement, this may be no worry. In my case I wanted the secondary monitor to be the primary display. When working on an application in what is now my primary display,  it&#8217;s anything but intuitive to move the mouse back over to the laptop display to click a menu item.</p>
<p>I spent some time searching for a tip, trick or hack to fix this little problem, to no avail. I went back into the system settings any number of times looking for a preference setting. I even did a search for a Mac <a href="http://macdevelopertips.com/category/defaults" target="_blank">Defaults</a> option to specify where the menu should land. Again, no luck.</p>
<p>Here&#8217;s the punch line, the fix was so obvious, it wasn&#8217;t obvious. If you look closely at the figure above, notice the second line in the description area&#8230;&#8221;<font color="#003300"><em>To relocate the menu bar, drag it to a different display.</em></font>&#8221; Heh, was that there the whole time&#8230;??</p>
<p>So here&#8217;s the tip: to move the menu bar simply drag-n-drop as you prefer.</p>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/04/prefs2.png" /></p>
<p>Okay, so here&#8217;s where I have a question for you. I recently upgraded to Leopard (10.5), and I&#8217;m curious if this feature existed on Tiger (10.4)?  Essentially I&#8217;m looking for an excuse as to  why I didn&#8217;t see the obvious solution to my question, right in front of me. Maybe you can help me out here :)</p>
]]></content:encoded>
			<wfw:commentRss>http://MacDeveloperTips.com/system/multiple-monitors-specifying-menu-location.html/feed</wfw:commentRss>
		<slash:comments>70</slash:comments>
		</item>
		<item>
		<title>MacFUSE</title>
		<link>http://MacDeveloperTips.com/system/macfuse.html</link>
		<comments>http://MacDeveloperTips.com/system/macfuse.html#comments</comments>
		<pubDate>Fri, 25 Apr 2008 11:35:04 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[MacFUSE]]></category>

		<guid isPermaLink="false">http://MacDeveloperTips.com/system/macfuse.html</guid>
		<description><![CDATA[MacFUSE is an open source project that simplifies the process of adding a file system to Mac OS X. If you&#8217;ve ever had an inclination to create a file system, or thought that a file system like &#8220;interface&#8221; would be an intuitive approach to solving a problem, yet, upon delving into what it takes to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/macfuse/" target="_blank">MacFUSE</a> is an open source project that simplifies the process of adding a file system to Mac OS X. If you&#8217;ve ever had an inclination to create a file system, or thought that a file system like &#8220;interface&#8221; would be an intuitive approach to solving a problem,  yet, <img src="http://macdevelopertips.com/wp-content/uploads/2008/04/MacFUSE.jpg" align="left" height="117" width="105" />upon delving into what it takes to create a kernel extension, you opted to rethink your idea (or at least the approach) here&#8217;s where MacFUSE comes in, effectively offering an API to implement a file system.</p>
<p><a href="http://fuse.sourceforge.net/" target="_blank">FUSE</a> (file system in user space) was born and bred as a Linux tool. <span id="intelliTxt">MacFUSE is a port of FUSE to the Mac by <a href="http://osxbook.com/" target="_blank">Amit Singh</a>. From the highest level, there are two key aspects to FUSE. First and foremost (without it you have nothing) the dynamically loadable kernel extension. This is where all the hard work (aka magic) takes place. The second aspect is the API, not unlike any other API you&#8217;ve worked with, the FUSE library offers an interface to communicate with the kernel extension. Using calls such as read, open and write, working with your own file system on FUSE becomes a rather trivial undertaking.</span></p>
<p>Following are a few examples of application using MacFUSE:</p>
<ul>
<li><a href="http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SPOTLIGHTFS" target="_blank">SpotlightFS</a>: an application that dynamically generates smart folders from Spotlight queries</li>
<li><a href="http://fuse.sourceforge.net/sshfs.html" target="_blank">SSH FileSystem</a>: file system client based on the SSH</li>
</ul>
<p>To learn more about MacFUSE, you can watch <a href="http://video.google.com/videoplay?docid=3138515991250095768" target="_blank">this video</a> of Amit reviewing his MacWorld 2007 presentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://MacDeveloperTips.com/system/macfuse.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Launch Applications from Terminal</title>
		<link>http://MacDeveloperTips.com/system/launch-applications-from-terminal.html</link>
		<comments>http://MacDeveloperTips.com/system/launch-applications-from-terminal.html#comments</comments>
		<pubDate>Tue, 15 Apr 2008 12:30:07 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[finder]]></category>
		<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://MacDeveloperTips.com/system/launch-applications-from-terminal.html</guid>
		<description><![CDATA[Launch Mac OS X applications from a terminal.]]></description>
			<content:encoded><![CDATA[<p>When working inside a terminal window, there&#8217;s a quick shortcut you can use to open a file (read, launch an application on a specific file or set of files). The beauty of this trick is that the command will work as if you clicked on an application icon(s) in Finder. For example, if you request to open a file with an extension of xml, the application associated with that extension will be started and the specified file will be passed to the application.</p>
<p>The command I am referring to is <font color="#800000"><em>open</em></font>; read on to see a few examples:</p>
<p>From a terminal window, to all the files with a &#8220;.rb&#8221; extension (in the current directory):</p>
<p>&gt; <em><font color="#800000">open *.rb</font></em></p>
<p>To launch a browser at a specified URL, try this:</p>
<p>&gt; <em><font color="#800000">open http://macDeveloperTips.com</font></em></p>
<p>And to open Finder in the current directory:</p>
<p>&gt; <font color="#800000"><em>open .</em></font></p>
<p>You can get more information about using the open command by viewing the manual page:</p>
<p>&gt; <font color="#800000"><em>man open </em></font></p>
]]></content:encoded>
			<wfw:commentRss>http://MacDeveloperTips.com/system/launch-applications-from-terminal.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Copy Finder Path to Clipboard &#8211; Tip 2</title>
		<link>http://MacDeveloperTips.com/applescript/copy-finder-path-to-clipboard-tip-2.html</link>
		<comments>http://MacDeveloperTips.com/applescript/copy-finder-path-to-clipboard-tip-2.html#comments</comments>
		<pubDate>Fri, 28 Mar 2008 12:03:59 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Tools/Utilities]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[finder]]></category>

		<guid isPermaLink="false">http://MacDeveloperTips.com/applescript/copy-finder-path-to-clipboard-tip-2.html</guid>
		<description><![CDATA[Copy path from Finder to clipboard, including drag and drop support for folders within the Finder window.]]></description>
			<content:encoded><![CDATA[<p><a href="http://macdevelopertips.com/applescript/copy-finder-path-to-clipboard-tip-1.html" target="_blank">Yesterday</a> I wrote a short AppleScript application that copied the current path of the Finder window to the clipboard. A rather unassuming, yet handy application. One downside to this application is that if you want the path of a folder selected in Finder, you would have to double-click on the folder to change the Finder path to that folder location, and then you could engage the AppleSscript application to copy the path.</p>
<p>For example, in the figure below clicking the Script Editor icon that we created in yesterday&#8217;s post (to the right of the terminal window with green arrow) will copy the path <em><font color="#800000">/Applications/</font></em> to the clipboard. However, what if you intention was to copy the path of the highlighted folder, that is,  <font color="#800000"><em>/Applications/Utilities/Java/</em></font> ?</p>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/03/copypath1.png" /></p>
<p>I&#8217;ve reworked the original example to add support for dragging a folder onto the icon and also moved the code for displaying a dialog box when an error occurs into a subroutine. Take a look at updated application below:</p>
<p><img src="/images/script-editor.png" alt="Script Editor" /> <a href="applescript://com.apple.scripteditor?action=new&amp;script=--%20When%20clicking%20on%20the%20icon%0Atry%0A%09tell%20application%20%22Finder%22%0A%09%09set%20currentPath%20to%20%28POSIX%20path%20of%20%28target%20of%20front%20window%20as%20alias%29%29%0A%09%09set%20the%20clipboard%20to%20currentPath%0A%09end%20tell%0Aon%20error%0A%09my%20finderErrorMsg%28%29%0Aend%20try%0A%0A--%20When%20dropping%20a%20folder%20onto%20the%20icon%0Aon%20open%20%7BdroppedFolder%7D%0A%09try%0A%09%09tell%20application%20%22Finder%22%0A%09%09%09set%20currentPath%20to%20%28POSIX%20path%20of%20droppedFolder%20as%20text%29%0A%09%09%09set%20the%20clipboard%20to%20currentPath%0A%09%09end%20tell%0A%09on%20error%0A%09%09my%20finderErrorMsg%0A%09end%20try%0Aend%20open%0A%0A--%20Error%20msg%20when%20unable%20to%20copy%20a%20path%20to%20the%20clipboard%0Aon%20finderErrorMsg%28%29%0A%09display%20dialog%20%22Unable%20to%20copy%20a%20path%20to%20the%20clipboard.%20Make%20sure%20Finder%20is%20referencing%20a%20directory%2Ffolder%20within%20the%20file%20system.%22%20buttons%20%7B%22Ok%22%7D%20with%20icon%20caution%20with%20title%20%22Error%22%0Aend%20finderErrorMsg">Click here</a> to paste the code below into the Script Editor</p>
<pre>
-- When clicking on the icon
try
  tell application "Finder"
    set currentPath to (POSIX path of (target of front window as alias))
    set the clipboard to currentPath
  end tell
on error
  my finderErrorMsg()
end try

-- When dropping a folder onto the icon
on open {droppedFolder}
  try
    tell application "Finder"
      set the currentPath to (POSIX path of droppedFolder as text)
      set the clipboard to currentPath
    end tell
  on error
    my finderErrorMsg
  end try
end open

-- Error msg when unable to copy a path to the clipboard
on finderErrorMsg()
  display dialog "Unable to copy a path to the clipboard.
                      Make sure Finder is referencing a directory/folder
                      within the file system."
                      buttons {"Ok"} with icon caution with title "Error"
end finderErrorMsg</pre>
<p>With the addition of the <font color="#800000"><em>on open</em></font> reference (line 12) you can now drag/drop a folder in Finder onto the application icon and its path will be copied to the clipboard. Before you can use the script, you will need to save the AppleScript code as an application and drag the script onto the toolbar (remove any previous version of the program by right clicking and selecting &#8216;Remove Item&#8217;).</p>
<p>As a quick debugging tip, you can add a dialog box as shown below to display the path that was copied into the clipboard:</p>
<pre>
tell application "Finder"
  set currentPath to (POSIX path of (target of front window as text))
  set the clipboard to currentPath
  display dialog currentPath buttons {"ok"}
end tell
...</pre>
<p>Now you can view the clipboard contents (through the dialog box) which makes the debugging process a little easier should you decide to tweak this application.</p>
<p><img src="http://MacDeveloperTips.com/wp-content/uploads/2008/03/copypath2.png" /></p>
<p>Another good example of the power of scripting on a Mac.</p>
]]></content:encoded>
			<wfw:commentRss>http://MacDeveloperTips.com/applescript/copy-finder-path-to-clipboard-tip-2.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

