Archive for May, 2008

May 12 2008

Login Screenshot Challenge

Published by john under System

In my last post 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 root as one of the available login names (instead, the name Other is listed).

Attempting to capture the login screen has been an interesting diversion. Up to this point I’ve been unsuccessful in capturing the elusive screenshot.

So here’s a challenge for you…can you be the first to figure out how to capture a screenshot of the login screen? There are a couple of ground rules:

  1. You must be running Leopard (or at a minimum, the solution must work on Leopard).
  2. Since I want to show how the login screen does not display root as one of the available login accounts, the screenshot will have to be of the login window. Put another way, simply selecting a name from the drop-down of the fast user switching dialog is not an option.
  3. I’d like this to be a “free” solution, as in, no software to buy.
  4. Finally, I am looking for a solution that doesn’t require more than one Mac (e.g. using SSH from one Mac to another).

To save you some time, I’ve listed below the options I’ve tried:

Attempt #1 - Hotkeys
From the login screenscreen, I tried the following hotkeys:

- Shift+Command+3 (capture entire screen to file)
- Control+Shift+Command+3 (capture entire screen to clipboard)
- Shift+Command+4 (capture area defined with mouse to file)
Each of the above greeted me with a pleasant beep, nothing more.

Attempt #2 - Grab application
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.

Attempt #3 - Fast Switching
Next, I enabled fast user switching. My thinking was, maybe if I don’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):

Seemed logical, however, upon choosing Login Window I was shuffled over to the same login screen as if logging out. No luck.

Attempt #4 - Getting a little more creative, I tried this from within a terminal:

screen -d -m bash -c “sleep 30; screencapture /Users/John/login.png”

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…I heard the camera sound of the screencapture application and was psyched, “yes!”…I navigated to my home directory and located the file login.png…I opened the file with the Preview application…and much to my dismay…it was an image alright…a big, black, blank image. So close, but no cigar.

So, now it’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 drop me an email. And please verify your trick works with Leopard, as other published solutions I’ve found seem to work only on releases prior to Leopard.

I’m doing my best to see if I can find a volunteer to donate a prize (software, book, t-shirt, etc). If that doesn’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.

If anyone reading is interested in donating a prize, contact me and we’ll get the ball rolling.

I am very intrigued to see if/how this can be done.

Technorati Tags: ,

5 responses so far

May 09 2008

Working as Root

Published by john under System

Root is the uber system account. Although handy at times (for example when installing applications), it’s generally recommended that root not be used as your everyday login. What follows are some options for working as root.

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):

$ sudo periodic daily

Now that’s all well and good, however, it’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:

$ sudo -s

This command will enable the root account and update your prompt as shown in the figure below:

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.

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.

Root account option #1: Enter the following from a terminal:

$ dsenableroot

You’ll be prompted for your (current) password, as well as the new root password.

Root account, option #2: Enter the following from a terminal:

$ sudo passwd

You’ll be prompted for the same series of passwords as above.

Root account, option #3: Follow the steps below:

- Start the Directory Utility application (/Applications/Utilities/Directory Utility)
- Click the lock icon in the lower left corner (to unlock it)
- From the Edit menu (across the top of screen), select Enable Root User

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 shows up as Other (for security reasons).

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’ll show the tricks that I tried for capturing the elusive login screen and I will pose an intriguing challenge for you…

Technorati Tags: ,

No responses yet

May 07 2008

Dashcode 2, Beta

Published by john under Dashcode

If you are interested in working with the next beta of Dashcode, although there is no public announcement of the beta, it is available, read on for the details…

If you are not familiar with Dashcode, it’s a development tool created by Apple for building Dashboard widgets. The 1.0x release was bundled with Leopard. Dashcode is an impressive application, with drag-n-drop support and a no-coding option for creating a widget. Of course, as with any “no coding required” statement there is the unstated disclaimer that there are limitations on how far you can take a widget without digging into some code. And on that note, Dashcode offers excellent support for both writing and debugging code that make up a widget (CSS, HTML and JavaScript).

To give you an idea of what you can do with Dashcode, the widget below is an RSS feed of this blog that was created with version 1.0x.

You can try Dashcode 1.0 if you are running Leopard by installing the developer tools on the Leopard install DVD.

Interested to try the 2.0 Beta? There isn’t a download solely for Dashcode, however, if you download the iPhone SDK, Dashcode is one of many tools included in the download. If you do not have an Apple ID, follow the link near the bottom of this page to download the iPhone SDK, where you’ll find an option to create an ID.

Important note: if you import a 1.0 project into the beta, be aware that you might be able to work in the project with 1.0 if you save the project. To get around this, save any imported project with a new name (and/or location). An additional suggestion is to install the iPhone SDK in a different directory than the default /Developer. I opted to install the beta into /Developer/Beta such that I can use both versions of the tools.

In a screencast to follow, I’ll show you how I created the widget above with Dashcode 1.0.

Technorati Tags: , ,

No responses yet

May 06 2008

Converting Images Types

Published by john under Tools/Utilities

I continue to find the Preview application to be a handy little tool. It’s not that Preview supports an enormous feature set for working with images, as much as each time over the last few months that I’ve look to the Previewer to help me out, it did.

The first time this came about I simply needed to resize an image to post on this blog - from the Tools menu, click Adjust Size and save the file, that’s it, done (and of course it can preserve the aspect ratio). My most recent encounter was when I needed to convert a file type from JPG to GIF. Again, a few clicks and it’s done - open an image, from the file menu choose the Save As option and from the dialog box select the image type. The figure below shows the supported file types; notice you can even save an image as a PDF.

By no means a full-fledged image editing program, and never intended to be, Previewer is still much more than its name suggests.

Technorati Tags: ,

No responses yet

May 05 2008

Google App Engine, Free Preview

Published by john under Web

Google App Engine provides an opportunity to leverage Google’s infrastructure for server side web applications. The platform is built on a Python runtime, includes persistent storage as well as the capability to integrate with existing Google applications (think Google Maps, Gmail…).

The App Engine SDK is an open source project that is hosted on Google code, you can can access the project here. A download of the SDK is available for Mac here.

The App Engine SDK includes a web-server application that provides a means to emulate the App Engine services from within a local development environment. Once deployed, applications can be hosted on the appspot.com domain, or your own domain.

The video below is a good introduction to Google App Engine from a recent CampFire One event:

One of the more intriguing aspects to services like the Google App Engine is that you focus on the application, not the hosting/scaling. Should you build a killer app, your focus still lies on the application itself, not on how to massively scale (which would be a good problem to have). From the App Engine homepage

This is a PREVIEW RELEASE of Google App Engine. For now, account registrations are limited to the first 10,000 developers, and applications are restricted to the free account limits.

Hurry and give it a go…

Technorati Tags: ,

No responses yet

May 02 2008

Changing an Application Icon

Published by john under System

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’s as simple as copy/paste.

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 Mac OS X icons and you’ll be amused for hours…

Technorati Tags: ,

No responses yet

May 01 2008

Toggle Finder Hidden File Status

Published by john under AppleScript

For some reason I prefer to have system files (hidden by default) shown in Finder (must be the Unix in my system from grad school). With that said, there are times when it would be nice to have these same files out of sight when working with a cluttered folder. After having thought many times about writing a short script to toggle hidden files on/off, I finally took a few minutes to crank out the code below:

Script Editor Click to paste code into the Script Editor

----------------------------------------
--  MacDeveloperTips.com
--  Toggle Finder hidden file status
----------------------------------------
try
  -- Get current value
  set toggle to do shell script "defaults read com.apple.finder AppleShowAllFiles"

  -- Toggle it
  if toggle = "ON" then
    do shell script "defaults write com.apple.finder AppleShowAllFiles OFF"
  else
    do shell script "defaults write com.apple.finder AppleShowAllFiles ON"
  end if

  -- Restart Finder
  tell application "Finder" to quit
  delay 0.5 -- If you have problems, you can tweak the delay
  tell application "Finder" to launch
on error
  display dialog "Unable to toggle bit status." buttons {"Better luck next time"}
           with icon caution with title "Error"
end try

Notice the reference to delay - if you have problems with the scripting not running properly, you can experiment with a longer delay. There is minimal error handling, essentially just trapping errors and displaying the message below:

I prefer to save AppleScript code as an application, create an icon that serves as a reminder of what the script does, and drag/drop the application onto the Finder toolbar. You can see a screenshot below what my toolbar looks like (the icon for this script is the blue & white Finder image).

And speaking of icons, in an upcoming tip I’ll show you how easy it is to change an application icon on a Mac.

Technorati Tags: , ,

3 responses so far