![]() |
Adding Date to Menubar's Time in Jaguar
Hi All,
Some months ago, someone posted the code needed to change the way the date and time show up in the menu bar. Instead of just showing the week day and time, with seconds flashing, it became possible to display the day/month/year as well. Sadly, this code does not work for Jaguar because the file is not exactly the same as before. Can you anyone review the code and post an update? http://www.macosxhints.com/article.p...11126090439402 Please advise. Thanks. -David |
Here is more information about this problem...
Before Jaguar, if we typed the following code in Terminal: cd /System/Library/CoreServices/Menu\ Extras/Clock.menu/Contents/MacOS/ sudo perl -p -i -e "s/%a /%x /" Clock The clock would change from: Thu 10:04:30 AM to: Aug 29 2002 Thu 10:04:30 AM This code doesn't work anymore though because at the end of the unix command is "MacOS/." This subdirectory no longer exists in this location. What I see inside the package is the following: Info.plist Resources (folder) version.plist Does anyone know how to adjust the unix command to take into account the new editable resources? |
I'd love to see this happen as well. The only file of interest I was able to find was /System/Library/CoreServices/Menu\ Extras/Clock.menu/Contents/Resources/English.lproj/Localizable.strings
which seems to dictate the format of the clock. The default MBC_CLOCK_FORMAT_STRING setting is "%a %time%p" which I believe means "day of week" then, of course, "time" then "am or pm." We need someone who can figure out a.) if the OS has strings built in for month, date, etc. and b.) what they are (i.e. %x, %y, whatever). 1000 points to whoever gets it first. David |
Well I experimented with that file I found, "Localizable.strings," and changing it seems to have no effect on the clock display. Anyone else have any ideas?
David |
As far as the replacements go, you can look at man 3 strftime
From what I can tell, the Perl command replaces the first occurrence of %a in the file Clock with %x. So you just need to find the Clock file. Which means that the cd command changes, but the Perl command stays the same. Of course, I don't have Jaguar to test this theory out. But, uh, if anyone wants to send me a (legal!) copy, I'll look into it. ;) |
I just use PTHClock. It's completely customizable regarding the date and time format. As noted, just refer to the strftime page to get the appropriate strings to fill in. I really like PTHClock b/c I can click on it and pull down a full mini calendar. It's free and I've had no problems running it on either 10.1.5 or 10.2. It also has configurable chimes and it can talk using the built-in speech stuff. Here's the link:
http://www.pth.com/PTHClock/ |
SpongeBob--
I agree that PTHClock is a great app and probably the easiest solution, but there are a couple reasons why I'd rather solve the problem with Clock.menu. First, PTHClock is not a menu extra. It's another process I would have to place in my already crowded Login Items, and I cannot Command-drag it, which I like to be able to do with things in the menubar. Second, there simply SHOULD be a way to view the date in the menubar without resorting to third party apps. David |
Quote:
David |
Wahoo, found it.
Look in the file /Users/<name>/Library/Preferences/.GlobalPreferences.plist It's the key NSTimeFormatString Just use the strings from strftime to format it the way you want. Don't forget that Apple uses the System Preferences config to add to that string. So, you might want to uncheck the AM/PM box, the Show Day of week box or whatever depending on the strings used. |
Super! You're the man! Thanks a lot.
David |
Thank you, Bob! I agree - you da man. : )
Now, for a non-unix guru, how should the code look to get the menu bar to look like this: Aug 29 2002 Thu 10:04:30 AM Thanks! -David |
Aug 29 2002 Thu 10 04 30 AM
%b %d %G %a %I %M %S %p Case sensitive. Space it out/punctuate it as you wish. %e is like %d, but will not show a zero before single digit dates. use "man 3 strftime" as nkuvu said at the terminal to see all the options (and to make sure I'm correct about the above). And as SpongeBob said, it might be a good idea to uncheck all the sub-options for the Menu Bar Clock in System Prefs. David |
I take it you guys know a lot more unix commands than I do, because I am still a bit lost on how to add the date to my menu bar.
Assuming I want the date to show as Aug 29 2002 Thu 9:00:34 pm, what is the command supposed to look like? Something like: cd /Users/david/Library/Preferences/.GlobalPreferences.plist sudo perl %b %d %G %a %I %M %S %p I think a file name is supposed to show up in there, but I don't know where. Thanks in advance, guys! -David |
Ah, sorry. Misunderstood the question. You have to edit the .GlobalPreferences.plist file itself. I personally don't know how to boil it down to one command (someone else might) but here's what I did:
cp ~/Library/Preferences/.GlobalPreferences.plist ~/Desktop/GlobalPreferences.plist.bak [backs up the file to the desktop. Notice the space in between "~/Library/Preferences/.GlobalPreferences.plist" and "~/Desktop/GlobalPreferences.plist.bak". Also notice the period preceeding "GlobalPreferences.plist " and the lack thereof in "GlobalPreferences.plist.bak" -- a period before the file name makes it invisible. Verify that the file is on the desktop before proceeding to make sure you're safe and sound.] pico ~/Library/Preferences/.GlobalPreferences.plist [opens the file in a command line text editor, pico] At this point, you have to locate the string for time format that SpongeBob found. Scroll down (by pressing the down arrow) to: <key>NSTimeFormatString</key> <string>%1I:%M:%S</string> then edit the "%1I:%M:%S" part using the codes I directed you to in my last post on this thread. When you're done, hit Control-O, then Enter to save. Quit and reopen the Menu Bar clock (or I guess just logging out and back in should work too). Changes should take effect. On a side note, does anyone know why there is a "1" before "I" in the default string, "%1I:%M:%S"? It's really buggin' me. Let us know how it goes, davey. David |
Quote:
David |
Ok, well it did not exactly work, but I'm a whole lot closer now than before.
When I followed the instructions before, I ended up with a time/date lines that looks like this: Aug 29 ? Thu 9:33:15 pm pm When I went to the Date and Time Pref Panel, I unchecked am/pm and then the date totally reverted back to the original display: Thu 9:33:15 pm. I tried this a second time, unchecking "Show AM/PM" and "Show the Day of Week" and this time the result looks like this: Aug 29 ? Thu 9:34:59 This time there is no am/pm at all, and the year stays a question mark. I went back to date/time pref panel and rechecked the am/pm and day of week, and now the menu bar looks like this: Thu Aug 29 ? Thu 9:35:55 pm I hope this helps in figuring this out. I am going to try to fix my clock now. -David |
Please post the string you used.
David |
Okay, I think I see the problem. Forget %G for year, use %Y. That should fix the question mark, I hope. Also, do uncheck those options in the system prefs. It will be redundant otherwise.
David |
Sure -- first I backed up the file, then I used the pico command, then I went to the string to edit and typed:
%b %d %G %a %1I:%M:%S %p Command O, exit, log out and back in. -David |
See my last post. Does that help?
David |
Hey, it appears to be working well on the menu bar. I did update the string slightly to remove one of the two spaces between am/pm and seconds:
%b %d %Y %a %1I:%M:%S%p I did notice that this code change as affected other programs in funky ways. I use a program called Weather Pop. It has an icon in the menu bar which shows the temperature and other weather-related information. It just informed me that a temperature update was performed on: Thu, Aug 29, 2002 Aug 29 2002 Thu 10:01 pm pm Oh man! Apple could have made this simpler by just sticking the full date in the DATE and Time control panel as an option. David and Bob - thank you so much for helping me out. Unless you know of any other options, I am going to stick with this for a while. -David |
Quote:
Does anyone know if there will be harmful effects associated with this method? David |
I can't say for sure, but I wouldn't think so. I wouldn't however be surprised if there were other programs like WeatherPop that displayed the date in the new format. The string that was modified is a system wide parameter, so if you dink with the format you change it for everything. Other than that, I can really see no repercussions. I also use Weatherpop, but just noticed after reading the thread that it was using the new date format I installed yesterday. Frankly, Apple could fix this simply and easily by having the clock use its' own date string which apparently it did in earlier releases rather than reference the system wide setting.
|
Take a look at file modification dates in the Finder after updating the string.
I have no idea if those might be affected, but it wouldn't hurt to look. |
They look fine, nkuvu:
Fri, May 24, 2002, 3:24 PM David |
Hey David,
How would I get the time string to look like what you just posted? Fri, May 24, 2002, 3:24 PM %a, %b %d %Y, %1I:%M:%S %p -David |
Quote:
David |
check it.
|
Quote:
I don't find this file in my library. How comes? (OSX.2.6) |
the period in front of the file name indicates that it's invisible in the finder. use the terminal if you want to manipulate the file.
|
Thanks for reply. Even its an old thread its quite interesting
However: I dont find the <key>NSTime... entry in my .GlobalPreferences.plist File How comes? Did Apple move this menubar clock entry? |
I changed the menu bar time to date & time with the system preference panel on Tiger.
|
Quote:
|
Quote:
|
it was a weird struggle however. I felt somehow 'dirty' doing it.
|
| All times are GMT -5. The time now is 05:00 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.