PDA

View Full Version : Display Home folder size in menu bar - Xcode




deba
Jul 5, 2012, 04:53 AM
Hi,

I'm looking for a way to display the size of a users home folder within the menu bar.

I have an apple script which displays to the user the size of their home folder, but would like something a bit more polished by displaying it in the menu bar.

This my First attempts at using Xcode / Obj-c.



GorillaPaws
Jul 5, 2012, 05:41 PM
You're trying to sprint before you learn how to crawl. In order to achieve your goal, you need to:

1. Learn Objective-C and understand the fundamentals of C.
2. Learn the basics of the Cocoa Frameworks.
3. Once you're there you're going to need to write a daemon (https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html) and use Apple's NSStatusItem (https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSStatusItem_Class/Reference/Reference.html) class.
4. If you want to ever try to sell it on the app store, you need to learn a bunch of stuff related to the sandboxing api's, and I'm not sure if they're compatible with accessing the disk to calculate the size of the hard drive anyways (I don't think they are but I could be wrong about this.).

What you want to do isn't impossible, but be prepared for a long journey. I think it might be practical to start with a more realistic, shorter-term goal.

deba
Jul 6, 2012, 06:05 AM
You're trying to sprint before you learn how to crawl. In order to achieve your goal, you need to:

1. Learn Objective-C and understand the fundamentals of C.
2. Learn the basics of the Cocoa Frameworks.
3. Once you're there you're going to need to write a daemon (https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html) and use Apple's NSStatusItem (https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSStatusItem_Class/Reference/Reference.html) class.
4. If you want to ever try to sell it on the app store, you need to learn a bunch of stuff related to the sandboxing api's, and I'm not sure if they're compatible with accessing the disk to calculate the size of the hard drive anyways (I don't think they are but I could be wrong about this.).

What you want to do isn't impossible, but be prepared for a long journey. I think it might be practical to start with a more realistic, shorter-term goal.

1. I know this
2. Learning
3. I have some example source code for NSStatusItem_Class
4. I have no intension of making an app for sale, this purely for testing

I know there is much to learn, but for now I'm just trying to get this to work, so if anyone can help, It will be much appreciated.

Red Menace
Jul 6, 2012, 09:25 AM
Unless you are just wanting to learn Objective-C, this can also be done in AppleScriptObjC, where you can use your AppleScript. You don't mention what OS or version of Xcode you are using, but AppleScriptObjC is available in 10.6+ from either Xcode or Lion's Cocoa-AppleScript template.

Either way, just putting up a status item is fairly trivial, and adding a menu isn't much more.