xcode

Latest

  • Preparing high-res icon files with Automator

    by 
    Ben Waldie
    Ben Waldie
    12.31.2012

    This week's post is for all those Mac app developers out there. If you're not an app developer yet, it's a new year, and I'm sure becoming an app developer is at at the top of your resolution list. In any case, if you plan to develop apps, then you need to prepare icons for those apps. Apple provides very specific requirements for generating high resolution icons, which you can find listed on the Apple Developer Connection website. In the past, Xcode came with a tool named IconComposer, which could be used to generate icon files. This tool, however, didn't generate high res icon files, so Apple now discourages its use. Instead, Apple provides instructions for generating icons using an iconset, a folder of image files that can be converted to an icon file using either Xcode or the iconutil command line tool. There are, of course, other ways of creating icons. In this post, however, we'll focus on an iconset. To manually generate an iconset folder, you start by creating a square image to serve as your icon. Next, you generate versions of the image scaled to 16x16, 32x32, 128x128, 256x256, 512x512. These scaled versions are to be named as follows: icon_16x16.png icon_16x16@2x.png icon_32x32.png icon_32x32@2x.png icon_128x128.png icon_128x128@2x.png icon_256x256.png icon_256x256@2x.png icon_512x512.png icon_512x512@2x.png You place all of these images into a folder named FolderName.iconset. Then, you can process it with iconutil to generate an icns file. Sure, creating scaled images and processing them isn't too difficult, but it's a lot of repetitive work. If you create icons regularly, it can get tedious. You're probably thinking, surely, Automator can be used to streamline the process. It can. Here, we'll create an application workflow you can run anytime you want to convert an image to an icon file. Let's get started... Note: If you're an iOS developer, feel free to adjust the workflow below accordingly. Creating the Workflow Launch Automator and create a new Application workflow. Next, insert and configure the following actions. Note: This workflow is pretty long and repetitive. It's easy to get lost. If you get stuck, don't worry, you can download the complete workflow here, along with a sample icon image. 1. Ask for Finder Items - Set this action to ask for an image file at least 1024x1024 in size. 2. New Folder - Set this action to create a folder named MyIcon.iconset on your Desktop. 3. Set Value of Variable - From the popup menu in this action, choose New Variable and create a variable named iconset folder. 4. Get Folder Contents 5. Change Type of Images - Set this action to convert images to PNG format. 6. Scale Images - Set this action to scale the image to a size of 1024 pixels. 7. Rename Finder Items - Set this action to name a single item's basename only to icon_512x512@2x. This represents a 1024 image (i.e. a Retina display ready size) when the icon is created. Note that this action's title changes in the workflow to reflect the type of naming, in this case Name Single Item. 8. Duplicate Finder Items 9. Scale Images - Set this action to scale the image to a size of 512 pixels. 10. Rename Finder Items - Set this action to name a single item's basename only to icon_512x512. 11. Duplicate Finder Items 12. Rename Finder Items - Set this action to name a single item's basename only to icon_256x256@2x. 13. Duplicate Finder Items 14. Scale Images - Set this action to scale the image to a size of 256 pixels. 15. Rename Finder Items - Set this action to name a single item's basename only to icon_256x256. 16. Duplicate Finder Items 17. Rename Finder Items - Set this action to name a single item's basename only to icon_128x128@2x. 18. Duplicate Finder Items 19. Scale Images - Set this action to scale the image to a size of 128 pixels. 20. Rename Finder Items - Set this action to name a single item's basename only to icon_128x128. 21. Duplicate Finder Items 22. Scale Images - Set this action to scale the image to a size of 64 pixels. 23. Rename Finder Items - Set this action to name a single item's basename only to icon_32x32@2x. 24. Duplicate Finder Items 25. Scale Images - Set this action to scale the image to a size of 32 pixels. 26. Rename Finder Items - Set this action to name a single item's basename only to icon_32x32. 27. Duplicate Finder Items 28. Rename Finder Items - Set this action to name a single item's basename only to icon_16x16@2x. 29. Duplicate Finder Items 30. Scale Images - Set this action to scale the image to a size of 16 pixels. 31. Rename Finder Items - Set this action to name a single item's basename only to icon_16x16. 32. Get Value of Variable - Set this action to get the iconset folder variable you created way back at the beginning of the workflow. You also need to set this action to ignore its input, so it doesn't continue processing the 16x16px image from the previous action. Select Action > Ignore Image. 33. Run Shell Script - Set this action to pass input as arguments. Then, enter the following command: iconutil -c icns "$@" Preparing the Run the Workflow Before you begin running the workflow, you need an image you can convert to an icon. Note that iconutil requires this image to be square. So, make sure it is. If you really want to be sure it's square, you can insert a Crop Images action between steps 5 and 6, and configure it to crop to 1024x1024, scaling to the shortest side before copping. However, if your image contains transparency, this action will remove it. So, it's best to prepare your starting image as a square. Running the Workflow When you run the workflow, you're first asked to choose an image. Select the desired image and click Choose. The workflow runs, an iconset folder is created on your Desktop and passed to iconutil, which generates an icns file. You're ready to plug your icns file into your app. Now, any time you need to generate an icon, just create a square image and trigger your workflow. Happy New Year and Happy App Developing!

  • Where's my convertible Mac?

    by 
    Erica Sadun
    Erica Sadun
    12.14.2012

    Here at TUAW, we just received our 5 billionth review request for a new iPad keyboard system. More and more, makeshift solutions attempting to turn iPads into laptops is a "been there done that" for me. Is it "too Microsoft" to ask Apple to come out with a proper convertible notebook/tablet, a duo for the new decade? After all, Windows 8 hasn't exactly been redefining the user experience. That's something that Apple usually does. There are, admittedly, problems with the proposition: You can already "kind of sort of" get work done on iPads -- more than ever, now that software is expanding for the touch-based office, Bluetooth accessories are ubiquitous, and onboard dictation means you don't have to hunch over a desktop to get things done. OS X isn't meant for small screens or touch interfaces. You probably don't want to be running Xcode on an iPad mini. Even though many technologies for iOS and OS X are converging, the underlying basis for sandboxing the file system are still far enough apart that running both OS'es on a single unit would be a smidge difficult. Not impossible, but difficult. The raw power needed to compile efficiently would price a convertible out of the market and it would probably have to weigh as much as a Macbook Pro to get any real work done. On the other hand, wouldn't it be awesome if a tablet really could do full desktop-level creation work, be able to dock to monitors wirelessly, be able to operate in tablet mode, and provide all the power of Apple's top systems in a tiny package. By the way, I'd also like sparkles for my rainbow pony unicorn. None of these technologies are unachievable, although ports, storage and battery life would provide strong design challenges, not to mention balancing weight into the equation. And, of course, the bigger question is would a frankentablet sell? Are we heading towards a unified device solution? Or is the triumvurate of desktop / laptop / tablet due to continue for the foreseeable future? You tell us. Vote in this poll and then join in the comments. %Poll-79548%

  • DevJuice: Stanford iTunes U course on iOS dev launches free textbook

    by 
    Erica Sadun
    Erica Sadun
    11.26.2012

    If you're a fan of the highly popular Stanford iTunes U course on iOS development (CS193P), you'll be happy to learn that an official companion text is now available on iBooks. iPad and iPhone App Development covers the latest release of Xcode and the newest Objective C enhancements. Approximately 300 pages in length, this is an iPad-only (i.e., iBooks Author) text. The book supplements and updates the iTunes U videos for Xcode 4.5 and iOS 6. It is available in all 50 iBookstore countries. Best of all, it's free.

  • DevJuice: Parse jumps to OS X Mountain Lion

    by 
    Erica Sadun
    Erica Sadun
    11.19.2012

    If you love Parse, you'll be happy to hear that the company just released an OS X SDK. Parse helps you store, sync and push data, enabling you to build server-based apps in the cloud without having to bring your own infrastructure. The new OS X API supports Mountain Lion development and you can check out the iOS/OS X guide for details on how you can store objects, access social media accounts, create "GeoPoints" and provide push notifications. There's a QuickStart guide that helps you get going in Xcode. Parse offers a free account with up to 1 million pushes per month ($0.07 per 1,000 pushes over that amount) and a "pro" account that supports collaboration, and higher storage and API request calls volumes. I am not personally a Parse user but it has very good buzz as a service.

  • Facebook speaks out on the big app rebuild

    by 
    Mike Schramm
    Mike Schramm
    08.24.2012

    We posted about the Facebook app update the other day, and if you haven't updated your app yet, you really should. The app is a prime example of why native development is almost always better than trying to do things with cross-platform web connections, and why it's so important, even for an online service like Facebook, to make sure an app performs well on a given platform. If you're interested in reading more about the process, Facebook has posted a substantial article over on its own Facebook page, walking through why this change was made and exactly how it was done. It's very interesting to read behind the technical scenes of how this update was created. The app essentially works in the same way that the previous version does, but it was built from the ground up in iOS' native Objective-C. The changes were all core to the process of running the app rather than UI developments, and if you have any development experience, it's wild to see the giant Facebook deal with the same issues that other iOS developers face. Of course, the drawback for all of this is that while the original HTML 5 app was relatively easy to update, this new app requires a little more code tweaking to change even basic things in the app. Facebook has done its best to build things as modular as possible (the new app even uses some of the code from the standalone Facebook Messenger app), but going forward, a more solid foundation may mean we have to wait longer for changes.

  • iOS developer toolchain will bid farewell to the iPhone 3G

    by 
    Mike Schramm
    Mike Schramm
    08.08.2012

    Cocoanetics has noticed something that's become apparent to most iOS developers already: with the advent of iOS 6 in a few weeks, Apple is essentially phasing out support for iOS on the iPhone 3G. Apple is slowly deprecating frameworks that iPhone 3G-compatible apps require from Xcode and app libraries, and the upcoming version of Xcode (4.5, currently in development) specifically states that it does not support armv6 devices or anything below iOS 4.3. In other words, both the original iPhone and the iPhone 3G have become extremely difficult for iOS developers to support, and by the time iOS 6 rolls around this fall, there will be essentially no reason for devs to try and make sure their apps and games work on the older hardware. While it may be technically possible to maintain separate codebases for newer and older hardware (by running old versions of Xcode), even the largest developers won't have financial reasons to do so. And the audience likely won't care much anyway. The number of people this affects grows smaller and smaller every day -- most phone contracts last about two years, which means it's been a few generations since the iPhone 3G was released in 2008. And there are a whole lot of new technologies for developers to take advantage of, including iCloud, Automatic Reference Counting, and Storyboard development, that make apps easier and quicker to develop and would never work with the older iPhone models anyway. Apple's never been accused of sticking with a product for too long -- the company has a reputation for moving on to the newer and better as quickly as possible. For developers, the iPhone 3G is essentially being lowered into the ground for good. Of course, that doesn't mean consumers are obligated to dump them; the existing apps they run will still work.

  • Xcode 4.4.1 released as standalone app

    by 
    Mike Schramm
    Mike Schramm
    08.07.2012

    Apple has finished smoothing out its Xcode releases with version 4.4.1, which finally brings Xcode out as a standalone app. Instead of just including the developer tools (such as legacy simulators and optional command-line tools), it now has sectioned those off into a separate downloads preference pane. This is a smart way to go about things. It allow for Xcode to be easily updated from the Mac App Store. You can get Xcode 4.4.1 for free, though remember that actually submitting apps or developing on iOS will require a developer subscription, from the Mac App Store.

  • Apple updates OS X Server, Xcode, Remote Desktop

    by 
    Megan Lavey-Heaton
    Megan Lavey-Heaton
    07.26.2012

    In addition to the flurry of other updates to go along with the release of OS X Mountain Lion, Apple has updated OS X Server, Xcode and Remote Desktop. OS X Server 2.0 is a $19.99 Mac App Store purchase that can be added to any Mac running Mountain Lion, enabling that machine to be used at a server. Features in the update include the following: File sharing for Macs, PC and iPad; Standards-based AFP, SMB and WebDAV file services; flexible file permissions and Spotlight searching Wiki Server including point-and-click page editor, access controls, tags and comments, revision history, document sharing and Quick Look previews Profile Manager, which includes configuration and management for OS X and iOS, over-the-air enrollment, mobile device management, web-based administration console and a self-service user portal Time Machine Mail Services Calendar, Contacts and Messages Servers Virtual Private Network Xsan Server app and other features Xcode 4.4 is an update for Lion and Mountain Lion and includes the following: SDKs for OS X 10.8 Mountain Lion and iOS 5.1. Enhanced for the MacBook Pro with Retina display. Code completion persists your selections to give more accurate suggestions. Objective-C @synthesize command is generated by default when using properties. Objective-C adds literal syntax for numbers, arrays, dictionaries, and expressions when developing for OS X. Apple LLVM compiler supports additional C++11 features, including lambdas. Assistant editor tracks caller or callee for the current selection. New localization workflow can share a single base .xib file for multiple locales on OS X. Source control can commit individually selected changes. ARC migration tool converts both retain/release and garbage collected code. Fixes an issue where code completion could fail, requiring the user to delete derived data. The Apple Remote Desktop update to 3.6 adds new attributes in the system overview report, support for IPv6 and addresses other concerns. [Via AppleInsider]

  • Devjuice: Installing command line tools (or not)

    by 
    Erica Sadun
    Erica Sadun
    07.12.2012

    Oliver Drobnik over at Cocoanetics has posted another really great how-to write-up, this time about Xcode and command-line tools. He shows you how to access apps from inside the Xcode bundle by using xcrun, and how to set your default Xcode install (via xcode-select). That's especially useful in these days of beta-versus-production Xcode releases. It's a handy little write-up, very worth checking out.

  • Cocos2D 2.0 available now

    by 
    Mike Schramm
    Mike Schramm
    07.09.2012

    After months of testing, the team behind the latest version of the extremely popular Cocos2D game engine for iOS has released version 2.0 of the framework, and it's available for download right now. The framework isn't completely compatible with version 1.0, so devs currently using the previous version on a big project might not want to upgrade in the current build. But the new version is quite fast, includes support for OpenGL ES 2.0, and much simpler code for setting up and maintaining lots and lots of on-screen sprites. Cocos2D is probably the number one open source engine for iOS game development. It sits inside Apple's Xcode software and allows developers to easily and quickly prototype and develop 2D games and apps. This new version of the software should allow for even easier and more powerful development, leading to even better games and apps for end-users.

  • DevJuice: Injection for Xcode

    by 
    Erica Sadun
    Erica Sadun
    05.10.2012

    Are you one of the many devs who miss Xcode's "Fix and Continue" feature? Apple removed "Fix and Continue" in Xcode 4. This option allowed you to patch your binary with updated code, as you ran and debugged it. Well, there's good news. Developer John Holdsworth has released Injection for Xcode. It's an OS X application that lets you inject those same code changes into running applications for development and debugging. It works with both OS X and iOS apps, including those running on devices. It works by allowing your classes to be recompiled selectively as class categories. These are loaded at run time via bundles, and override your originally compiled code. So you can modify, enhance, and adapt your code during run time and tweak elements on the go. Holdsworth has been working with this feature for quite a long time. He writes: In London there were two banks which embraced NeXT for developing front office trading systems in an age before even windows 3.1. The hardware was only just up to it however and build times where at three quarters of an hour so we started using this means of patching the app using bundles rather having to relink the whole thing. I asked him to fill in some of his background about working with Apple and NeXT technology. He responded: I first encountered NeXT in 1989 at IRCAM the computer/music research institute in Paris where I fell in love with Objective-C. It's great to see things coming full circle with all this memory managed stuff, and C++, such a half baked language falling away. How ironic that it should be a mobile device which paved the way. If you ask me the closest we've been to Object-Oriented Nirvana is Smalltalk, and Objective-C is pretty close to that. Steve visited one day spinning the reality distortion field about the new "autorelease" mechanism. Quite the mystic. My only other claim to fame was when the Apple purchase of NeXT came through I sent him an email enthusing greatly and got a reply saying "Thanks John, a Merry Christmas to you and your family." Been a disciple ever since. Shame I didn't buy the stock. Unfortunately, Apple has been a bit squirrelly about letting Injection into the OS. Holdsworth first hoped to start selling Injection on the Mac App Store back in February. Apple has been sitting on the app for months, failing to give it a thumbs up or down. Do you want to help out? Drop Apple a note at appreview@apple.com and ask them to expedite approval on Injection for Xcode (App number #id498448895). Until then, Injection for Xcode is available on Holdsworth's personal site. It offers a two-week trial period and costs US$9.99 (individual license) or $25.00 (corporate) after that. Licenses are issued per-machine. To purchase, the app guides you through PayPal (via a web view) after the trial period.

  • Codea-created app arrives on the App Store

    by 
    Mike Schramm
    Mike Schramm
    04.25.2012

    I've been slowly wading into App Store development recently, and while I've found Apple to be extremely supportive developers on the Mac, it hasn't released any development tools for iOS ("Xcode for iPad" is one of those mythical creatures that developers will tell you they want only after a couple rounds of drinks). This realization drew me to Codify, now named Codea, an iPad app that allows developers to write and even run XML code on the iPad. Unfortunately, the biggest drawback with Codea was that you couldn't run that code anywhere else. The best you could do was copy the code out and then put it into some other development environment. But that gap is being narrowed. The developers of Codea have released an App Store game called Cargo-Bot, which is a title fully developed inside the Codea app on the iPad. The app is free, and it's just a proof of concept at this point (but it does have some nice features, including 36 levels, and even a way to upload solutions to YouTube). But the devs also say they're planning to release the framework they used in Xcode on the Mac. Once that happens, other devs will be able to code on the iPad, download that code to the Mac, put it into Xcode, and then make full-fledged iOS apps written right there on Apple's tablet. [via TouchArcade]

  • Xcode 4.4 and Safari 5.2 seeds pushed to developers

    by 
    Megan Lavey-Heaton
    Megan Lavey-Heaton
    04.18.2012

    In addition to the third developer's preview of OS X Mountain Lion, developers on Wednesday also received new builds of Xcode 4.4 and Safari 5.2. AppleInsider has release notes for both, with Xcode 4.4 having enhancements for Objective-C language features, improved support for 2011 C++ standard and more. The new Safari 5.2 build has a new scalable vector graphic filter, an improved web inspector and HTML5 media controller and more tweaks. All of these previews are available through Apple's Developer Center, along with full release notes.

  • Apple releases Mac updates for iPhoto, iTunes, GarageBand and Xcode

    by 
    Dave Caolo
    Dave Caolo
    03.07.2012

    Apple has issued updates to the Mac versions of iPhoto, iTunes, GarageBand and Xcode. iPhoto is now up to version 9.2.2, which lets users delete images from Photo Stream. Hooray! iTunes 10.6, as we mentioned earlier, adds the ability to play 1080p HD movies and TV shows from the iTunes Store. According to Apple, the new version of GarageBand, 6.0.5, "...supports general compatibility and addresses overall stability and performance, including the following: Updates compatibility with GarageBand for iOS projects Fixes a playback issue with the GarageBand Lesson preview videos Corrects issues with some software instruments triggering incorrect or stuck notes" Finally, Xcode 4.3.1 "...is now distributed as an application," Apple says, "rather than as an installer. This change enables Xcode to be updated directly from the Mac App Store." Other changes include a new code signing workflow which supports signing OS X apps with Developer ID and the addition of command-line tools to the Downloads preference pane. They're all available now, so have at it.

  • DevJuice: Can I move Xcode off my main drive?

    by 
    Erica Sadun
    Erica Sadun
    02.20.2012

    Dear Dev Juice, Now that Xcode 4.3 is supposed to live in /Applications, can I move it off my main drive? I used to have it on my secondary, because I have a fast SSD as my primary. Also, where are all the files located, like the simulator? John Dear John, At over 3 GB, the new Xcode distro is big, but are you sure you really want to mess with the App Store management, which depends on apps residing in /Applications? We gave offloading a try, moving Xcode onto an external USB disk and symbolically linking it into /Applications. It seemed to run fine and we had no problem creating, compiling and archiving apps. Not sure if this is a super-great idea, though, especially when upgrades come down the line. Our wild guess is that at any upgrade, App Store could overwrite the symbolic link and you'll have to manually move it off the drive again. As for the "files," I assume you're talking about the executables like iPhone Simulator.app (which can be found in /Applications/Xcode.app/Contents in the Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/ subfolder) rather than the data files that are stored in /Users/youraccount/Library/Application Support/iPhone Simulator. In /Applications/Xcode.app/Contents/Applications, you'll find some of your old favorites like Icon Composer and FileMerge. Utilities like git, gdb, and nm are now in the Contents Developer/usr/bin subfolder. Older items such as RezWack and SetFile have moved into the Developer/Tools subfolder. Happy Developing!

  • Simple.tv DVR / placeshifter frees free TV from the constraints of location, time

    by 
    Richard Lawler
    Richard Lawler
    01.10.2012

    One of the many innovative products we checked out tonight was this ViXS XCode 4210 powered Simple.TV box, which tunes into free, unencrypted channels (even in HD) via cable or antenna. Where it starts to differ from other boxes like Sling and Monsoon however, is that it eschews any direct video out or even passthrough, working solely to transcode those feeds to variable bitrate MPEG-4 streams for playback on internet-connected mobile devices and TV boxes. Besides the missing TV out, this headless unit also only supports DVRs courtesy of whatever storage you may add yourself, since it doesn't contain any. The Simple.TV box is set to launch this spring and initially should have viewing apps available for Roku and iPad, with Boxee Box and Google TV viewers eventually planned as well (there is also a $29 Windows Media Center app). Currently the pricing is set at $149, and while streaming to another device in the home and simple DVR function are free to use, adding a guide and allowing streaming to up to 5 devices over the internet will require another $4.99 per month. If you're interested, check out the video after the break and keep a spot near your coax line open.

  • Mac app localization now easier with Tethras

    by 
    Michael Rose
    Michael Rose
    10.21.2011

    For many independent or smaller-scale Mac developers, the promise and profits of international distribution for their apps is obscured behind a very practical challenge: internationalizing their projects, which can take months and plenty of money/resources as all the interface items are translated to the target language. Starting today, that's going to become a bit simpler. The Tethras mobile application localization service, which supported iOS along with other major mobile platforms, is extending full support to localizing OS X applications as well. Developers will be able to chat with the Tethras team at the MacTech conference in San Francisco on November 2, as we did back at WWDC this year. [TUAW is a media sponsor of the MacTech conference. –Ed.] With support for over 40 different languages, the Tethras service uses skilled human translators to help convert all the application assets from the source locale to the required alternatives. For devs looking to target the Mac App Store for distribution, the more languages and localizations they have in their apps, the more potential customers they can address. Tethras CEO & co-founder Brian Farrell is understandably enthusiastic about the opportunity for Mac developers to take advantage of expanded markets. "To truly create a better, more individualized experience for the user, each piece of a Mac app translation, from the icon to the written text, needs to be catered to the specific targeted market. A complete localization will lead to increases in downloads and revenue." Tethras is pioneering what it calls Localization as a Service (LaaS) -- the idea is that the cloud-based localization tools allow translators and developers to preview what a translation will look like within the app itself. Hosting the localization resources in the cloud also means fewer management hassles for developers and product managers as they try to maintain multiple localizations. You can see a brief video walkthrough of Tethras below.

  • Daily Update for September 23, 2011

    by 
    Steve Sande
    Steve Sande
    09.23.2011

    It's the TUAW Daily Update, your source for Apple news in a convenient audio format. You'll get all the top Apple stories of the day in three to five minutes, which is perfect for a quick review of what's happening in the Apple world. You can listen to today's Apple stories by clicking the inline player (requires Flash) or the non-Flash link below. To subscribe to the podcast for listening through iTunes, click here. No Flash? Click here to listen.

  • Support for quad-core ARM CPU shows up in Apple's Xcode

    by 
    Steve Sande
    Steve Sande
    09.23.2011

    The default compiler in Apple's Xcode developer tools is the LLVM-based Clang. Ars Technica reports that they received a heads-up from a developer who works on low-level ARM assembly coding that the latest version of Clang in Xcode adds support for a quad-core, ARM-based processor from Marvell -- the Armada XP. Ars confirmed that the source code for portions of Clang includes definitions (highlighted in the source code listing shown above) for an architecture type of "armv7k" and a CPU type of "pj4b." According to Ars, PJ4B is a specialized CPU design used in the Armada XP embedded processors. So, what does this all mean? The most likely interpretation is that Apple is using the Marvell chip in prototype iOS and MacBook Air devices. As Ars notes, a prototype logic board powered by the Armada XP would let Apple software engineers experiment on optimization of the two operating systems while the hardware design team finishes work on a future quad-core ARM design. Is this the A6, successor to the existing A5 processor? Most feel that the A6 is just a smaller and more efficient dual-core processor, but Ars comments that the smaller design would allow Apple to add more cores if necessary.

  • DimScreen simply dims your screen

    by 
    TJ Luoma
    TJ Luoma
    09.19.2011

    Once upon a time, I had an application which would dim the screen of my Mac down to 0, and then exit. Somewhere along the way I seem to have lost the app and can no longer find it. Yes, I know I could just hold F1 and do the same thing manually, but I liked having an app that just did it for me. So I did what any self-respecting geek would do: I wrote a shell script. Others did the heavy lifting Let me be clear that my little shell script wrapped in Automator was only a tiny piece of this puzzle. First I'm going to tell you who did all the heavy lifting, and then you can decide how you want to put the pieces together for yourself. (I highly recommend reading to the end before you do anything.) Nicholas Riley wrote a C program called brightness which I found via Matt "Danger" West's website, which I found via Google. Matt includes the source code on his page, or you can download the original 'brightness.c' here and then you can compile it (according to Matt's instructions) using this line: gcc -std=c99 -o brightness brightness.c -framework IOKit -framework ApplicationServices Of course that assumes that you have Xcode installed. If you don't, you can either download and install Xcode (warning: it's 3 GB to download and I think it's somewhere between 7-10 GB when installed). If all of that seems like a lot of hassle, Matt also made a pre-compiled binary available for you to download. Here's what I did I wrote a shell script (dimscreen.zsh) which looks for brightness at $HOME/bin/brightness. If it does not find it there, it will attempt to download it "automagically" from my personal website and then install it to $HOME/bin/brightness. Once brightness is installed, it will dim the screen to 0 and then launch your screensaver. Why does it launch your screensaver? Because otherwise when you went to use your Mac, you might have forgotten that you set the brightness to 0. If you move the mouse or type, you won't see anything. However if the screensaver is on, one of two things will happen: If you have enabled the preference which requires a password to be entered after your screensaver is turned on, you will see that prompt. (Mac OS X is smart enough to automatically turn the screen brightness up a little for you to see that you need to enter your password.) If you do not require a password to be entered after your screensaver is turned on, my script will turn the brightness up as little as possible after the screensaver exits. That should keep you from getting blinded if you are working at night. Then you can adjust the brightness to whatever level you want. I took dimscreen.zsh and made it into an app ("Dim Screen.app") using Automator. I put dimscreen.zsh and the 'Dim Screen.app' and the 'brightness' command (and the source code) all into one nice neat package and put it on my Dropbox as DimScreen. "How do I use this?" 1) If you are the trusting type (or just impatient), download DimScreen, double click it to 'unarchive' it, and then move the 'Dim Screen.app' to /Applications/ (or wherever you keep your apps) and run it. The first time you run it, make sure that you are online so that it can download the brightness utility. (It will only do that once.) 2) If you are trusting to a point but don't want the app to download anything automatically, make a directory called 'bin' in your home directory (that's the one which has the 'Desktop' and 'Documents' and 'Downloads' directories in it). Then double-click the DimScreen.tar.bz2 file, and move the 'brightness' file to the ~/bin directryory you just created. 3) If you pride yourself on your distrust, then by all means, download the source code from the links provided above, compile the 'brightness' command on your own, and move it to ~/bin/ (where ~ is your Home directory). (If you are someone who likes the Terminal.app, you might want to put the dimscreen.zsh script into your $PATH as well, so you can launch it from the command line.) Once you have it installed, launch it via whatever app launcher you prefer. If you want to make it a "one click launch" you might consider Apptivate, a handy little launcher I reviewed previously. There are other ways to do it, of course, but Apptivate is still my preferred "I want to press this key (or "this key sequence") to run this Application/Script/etc" solution. P.S. Yes, I know about Control + Shift + Eject I am sure that some Mac keyboard aficionado will not have been able to wait until the end of the article, and is already writing a comment to tell me that if I press Control + Shift + Eject, then the Mac's screen will turn off. I know. The problem is, I never remember if it's Control or Command, and do I have to hold down the fn key or not. Plus it's really not the same thing, I don't just want it off, I want it dimmed all the way down. I still wanted an (even) easier way. I'm used to triggering all sorts of actions via LaunchBar and wanted to be able to dim my screen that way too. When I read on Apple Stack Exchange about someone who couldn't get that keyboard shortcut to work, I went looking for that old app (mentioned at the beginning of this article) and when I couldn't find it, I decided to just roll my own. Are there other ways of doing this? You bet. If you have a preferred solution, feel free to let us know in the comments.