MenuNote

Copyright © 2003, 2004 Dave Bayer. Subject to the terms and conditions of the MIT License.

MenuNote is a sample Mac OS X Cocoa application providing a customizable menu bar clock which can display a local time different from the Macintosh system time. This can be useful when traveling, for coping with applications that don't handle time zones gracefully: Pick a home time zone for the Mac, and stick to it. Adjust the time displayed in the menu bar to reflect the current time zone, varying either by geographic or personal convention.

For example, changing time zones causes the application Retrospect to perform a full backup; it believes that all files have been modified. I use MenuNote as a work-around.

This project was based on the tutorial Recent Tunes NSStatusItem. The code for MenuNote could easily be modified to display other information in the menu bar, such as the currently assigned IP address.

This is the version of January 13, 2004. The application is available as MenuNote.sit; it is compiled for OS X 10.3. The web site for MenuNote is www.math.columbia.edu/~bayer/OSX/MenuNote/

This documentation was created using annote.


Usage

To adjust MenuNote's format, open the Preferences... menu item. The Time Format: field accepts an arbitrary string, and translates escape codes using Cocoa's date format syntax, as described in Date Formatters:

%%a '%' character
%aabbreviated weekday name
%Afull weekday name
%babbreviated month name
%Bfull month name
%cshorthand for %X %x, the locale format for date and time
%dday of the month as a decimal number (01-31)
%esame as %d but does not print the leading 0 for days 1 through 9
%Fmilliseconds as a decimal number (000-999)
%Hhour based on a 24-hour clock as a decimal number (00-23)
%Ihour based on a 12-hour clock as a decimal number (01-12)
%jday of the year as a decimal number (001-366)
%mmonth as a decimal number (01-12)
%Mminute as a decimal number (00-59)
%pAM/PM designation for the locale
%Ssecond as a decimal number (00-59)
%wweekday as a decimal number (0-6), where Sunday is 0
%xdate using the date representation for the locale
%Xtime using the time representation for the locale
%yyear without century (00-99)
%Yyear with century (such as 1990)
%Ztime zone name (such as Pacific Daylight Time)
%ztime zone offset in hours and minutes from GMT (HHMM)

In addition, there is rudimentary support for the following extensions:

%Tcumulative hours, excluding display sleep
%Ucumulative minutes, excluding display sleep
%Vcumulative seconds, excluding display sleep

The default format is %a %d %b %I:%M, which produces output of the form Mon 12 Jan 2:41


Known issues


Source code

The source code is bundled with the application as MenuNote.tar.gz

MenuNoteController

PreferenceController

main


Setting up an XCode project

All source code for MenuNote is organized within a directory named source. The XCode project file MenuNote.xcode should be ready to use. To start over, e.g. with a new release of the development tools, or to mimic this setup with a different project, the following directions are how to create a new project in XCode 1.1 that uses source:

  1. In XCode, create a new project called MenuNote in XCode, of type Cocoa Application.
  2. Delete the Classes, Other Sources, and Resources groups, choosing Delete References & Files.
  3. In the Finder, copy the source directory source for MenuNote into the project directory.
  4. Back in XCode, add the source directory to the project using the Add Files... item of the Project menu, choosing Recursively create groups for any added folders. After adding these files, leave the Add to Target status checked only for files with extensions .h, .m, .nib, and .strings, to avoid spuriously copying the other files to the built application.
  5. Using the Inspector's Build pane for target MenuNote, change the Prefix Header path to source/Etc/MenuNote_Prefix.pch and change the Info.plist File path to source/Etc/Info.plist
  6. Using the Inspector's Properties pane for target MenuNote, change the Identifier entry to com.syzygies.MenuNote.
  7. Build and run.
  8. For more stringent compilation warnings, in the Inspector's Build pane for target MenuNote, change -Wmost in Other Warning Flags to
    -Wall -W -Wno-unused-parameter -Wnewline-eof -Werror
    
    From OpenGL.org Discussion & Help Forums: -Wall is warnings you always want because they're always errors; -W is warnings you almost always want because they're almost always errors; -Wno-unused-parameter turns off warnings for unused parameters to functions, which -W turns on; -Wnewline-eof is an Apple-only flag which restores GCC's default of warning if your source file doesn't end with a newline. This is for compatibility with GCC on other platforms; -Werror makes all warnings into errors so you can't ignore them.
  9. To update the html documentation and create a tar archive with each build, create a New Shell Script Build Phase for target MenuNote, consisting of the lines
    source/Scripts/annote.sh
    source/Scripts/tar.sh
    source/Scripts/help.sh
    
    annote.sh assumes that annote has been installed as ~/bin/annote. (Nothing I've tried so far convinces XCode to use my PATH variable.)
  10. For portability, turn off instruction scheduling for a specific architecture; it doesn't seem to work as claimed on other architectures.
  11. To mirror desired components into a separate html directory in preparation for uploading to a web site, save the following AppleScript as an Application:
    tell application "DropStuff"
        activate
        stuff alias "User:Users:me:Local:Code:MenuNote:build:MenuNote.app:" with format StuffIt5
        quit
    end tell
    do shell script "/Volumes/User/Users/me/Local/Code/MenuNote/source/Scripts/install.sh"