<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Energy Aware</title>
	<atom:link href="http://www.dssw.co.uk/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dssw.co.uk/blog</link>
	<description>An insight into DssW, energy saving, and business</description>
	<lastBuildDate>Mon, 14 May 2012 11:15:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Sending Requests with the Power Manager SDK</title>
		<link>http://www.dssw.co.uk/blog/2012/05/14/sending-requests-with-the-power-manager-sdk/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sending-requests-with-the-power-manager-sdk</link>
		<comments>http://www.dssw.co.uk/blog/2012/05/14/sending-requests-with-the-power-manager-sdk/#comments</comments>
		<pubDate>Mon, 14 May 2012 11:15:20 +0000</pubDate>
		<dc:creator>Graham Miln</dc:creator>
				<category><![CDATA[PM4]]></category>
		<category><![CDATA[Power Manager]]></category>
		<category><![CDATA[Recipe]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://www.dssw.co.uk/blog/?p=1667</guid>
		<description><![CDATA[You can create tools and utilities that interact with Power Manager. Your software can send Power Manager requests asking for events to be performed, variables to be set, and schedules to be changed. <a href="http://www.dssw.co.uk/blog/2012/05/14/sending-requests-with-the-power-manager-sdk/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You can create tools and utilities that interact with <a href="http://www.dssw.co.uk/powermanager/standard/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=sdk-how-to" title="Power Manager - energy saving software">Power Manager</a>. Your software can send Power Manager requests asking for events to be performed, variables to be set, and schedules to be changed.</p>
<p>Previously, we have seen how to <a href="http://www.dssw.co.uk/blog/2012/05/04/observing-with-the-power-manager-sdk/" title="Observing with the Power Manager SDK">observe</a> and <a href="http://www.dssw.co.uk/blog/2012/05/09/binding-with-the-power-manager-sdk/" title="Binding with the Power Manager SDK">bind</a> to the Power Manager engine. These techniques are essential for monitoring and learning about what the energy saving engine is doing.</p>
<p>Let&#8217;s now focus on how to ask the engine to change its state on our behalf. We are going to create a button in Objective-C/Cocoa and have that button stop the scheduler.</p>
<p>The request we are going to use is <strong>scheduler.setenabled</strong>. This request takes a parameter called <strong>enabled</strong>. Our button will send the request with a single parameter set to <strong>NO</strong>.</p>
<h3>Sending a Request to Power Manager</h3>
<ol>
<li>Create a new Cocoa Application project in Xcode.
<div id="attachment_1669" class="wp-caption aligncenter" style="width: 654px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/1-power-manager-create-project-in-xcode.jpg" alt="Create a new Cocoa Application project in Xcode." title="Create a new Cocoa Application project in Xcode." width="644" height="442" class="size-full wp-image-1669" /><p class="wp-caption-text">Create a new Cocoa Application project in Xcode.</p></div>
<p><div id="attachment_1670" class="wp-caption aligncenter" style="width: 654px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/2-power-manager-configure-xcode-project.jpg" alt="Set up the new Cocoa application." title="Set up the new Cocoa application." width="644" height="442" class="size-full wp-image-1670" /><p class="wp-caption-text">Set up the new Cocoa application.</p></div>
</li>
<li><a href="http://www.dssw.co.uk/blog/2012/05/02/connecting-with-the-power-manager-sdk/" title="Connecting with the Power Manager SDK">Add the PowerManager.framework</a>.</li>
<li>Copy and paste the following into your application delegate header (h):
<pre class="objc">#import &lt;Cocoa/Cocoa.h&gt;
#import &lt;PowerManager/PowerManager.h&gt;

@interface DSSWExampleAppDelegate : NSObject &lt;NSApplicationDelegate&gt; {
    DSSWPMConnection *connection;
}
@property (assign) IBOutlet NSWindow *window;
@property (retain) DSSWPMConnection *connection;

- (IBAction)requestSchedulerStop:(id)inSender;

@end</pre>
</li>
<li>Copy and paste the following into your application delegate body (m):
<pre class="objc">#import "DSSWExampleAppDelegate.h"

@interface DSSWExampleAppDelegate (PowerManager)
- (void)connection:(DSSWPMConnection*)connection didRespond:(DSSWPMResponse*)response;
@end

@implementation DSSWExampleAppDelegate
@synthesize window = _window;
@synthesize connection;

- (void)dealloc
{
    self.connection = nil;
    [super dealloc];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    self.connection = [DSSWPMConnection connection];
    self.connection.keepAlive = YES;
    self.connection.autoReconnect = YES;
}

- (IBAction)requestSchedulerStop:(id)inSender
{
    // Create a request
    DSSWPMRequest* schedulerSetRequest = [DSSWPMRequest requestWithRequest:kPMRPCSchedulerSetEnabled value:[NSNumber numberWithBool:NO] forParameter:kPMRPCParameterEnabled];

    // Send the request
    BOOL validSend = [self.connection send:schedulerSetRequest withTarget:self selector:@selector(connection:didRespond:)];
    NSAssert(validSend,@"Send failed");
}

@end

@implementation DSSWExampleAppDelegate (PowerManager)

- (void)connection:(DSSWPMConnection*)connection didRespond:(DSSWPMResponse*)response
{
    // Add your code to deal with errors or problems
    NSLog(@"Send replied: %d",(int)response.status);
}

@end</pre>
</li>
<li>View the <strong>MainMenu.xib</strong> file and add a button.</li>
<li>Connect the new button&#8217;s action with the <strong>requestSchedulerStop:</strong> method of the application delegate.
<p><div id="attachment_1671" class="wp-caption aligncenter" style="width: 461px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/3-power-manager-set-button-action-in-xcode.jpg" alt="Connect the button to the requestSchedulerStop method." title="Connect the button to the requestSchedulerStop method." width="451" height="413" class="size-full wp-image-1671" /><p class="wp-caption-text">Connect the button to the requestSchedulerStop method.</p></div>
</li>
<li>Build and run the application.</li>
</ol>
<p>With the application running, open Power Manager so you can see the effect of your request. Click on the button and immediately Power Manager&#8217;s scheduler will stop.</p>
<p>You can click the button as many times as you like. Each request will be sent and successfully acknowledged. If Power Manager&#8217;s scheduler already stopped, nothing will change.</p>
<div id="attachment_1672" class="wp-caption aligncenter" style="width: 333px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/4-power-manager-request-stop-scheduler.jpg" alt="Simple but functional application to stop Power Manager&#039;s scheduler." title="Simple but functional application to stop Power Manager&#039;s scheduler." width="323" height="206" class="size-full wp-image-1672" /><p class="wp-caption-text">Simple but functional application to stop Power Manager&#039;s scheduler.</p></div>
<h3>Walking Through the Code</h3>
<p>The code in this application is fairly simple despite dealing with interprocess communication and asynchronous requests. Let&#8217;s look at what happens when you launch your application and when you press the button.</p>
<h4>Launching the Application</h4>
<p>On launch, the application delegate creates a new connection to Power Manager. The connection is made with a local copy of Power Manager running on your Mac.</p>
<pre class="objc">self.connection = [DSSWPMConnection connection];
self.connection.keepAlive = YES;
self.connection.autoReconnect = YES;</pre>
<p>Note that the connection is automatically <strong>retained</strong> by the application delegate. This behaviour is declared as part of the <strong>@property</strong> line in the class&#8217;s interface.</p>
<p>The connection is configured to <strong>keep alive</strong> and <strong>automatically reconnect</strong>. These two settings are optional but useful.</p>
<p>The <strong>keepAlive</strong> setting ensures idle connections are not disconnected by Power Manager. Connections may still be disconnected but our application asks nicely to stay connected for as long as possible.</p>
<p>The <strong>autoReconnect</strong> setting tells the <strong>connection</strong> object to automatically establish a new connection to Power Manager should we get disconnected.</p>
<p>These three lines complete the set up of the connection to Power Manager. There is nothing more you need to do to manage the connection.</p>
<h4>Clicking the Button</h4>
<p>When you click the button, the method <strong>requestSchedulerStop:</strong> is called.</p>
<p>This short method does two things. It creates a request using DSSWPMRequest. It sends the request using the connection created at launch.</p>
<p>The sending of the request returns a boolean value. This value tells you if the request has been sent, or at least queued up for sending, successfully. Most of the time the returned boolean value will be positive (YES). A negative return value (NO) indicates a problem with the connection.</p>
<p>The return value has nothing to do with the state of your actual request.</p>
<p>When the <strong>requestSchedulerStop:</strong> method is finished, you have created and sent your request but you do not know if it succeed or not.</p>
<p>The request requires a moment to be sent through the connection to Power Manager, acted upon within Power Manager, and then a reply sent back from Power Manager to your application. The time it takes for this to happen is unknown; you could be talking to a computer on the other side of the world which would take much longer than requesting changes on your local Mac.</p>
<p>So how does the reply come back to your application? When the request was sent, a target and method were provided to the connection. It is through this pair, that you learn the fate of the request.</p>
<p>The connection will call the method you provided when a reply comes back. In our case, the method is <strong>connection:didRespond:</strong>. Within this method you can determine the outcome of the request and deal with any information returned.</p>
<p>There are numerous requests available. You have complete access to <a href="http://www.dssw.co.uk/powermanager/developer/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=sdk-how-to" title="Power Manager Software Development Kit (SDK)">Power Manager&#8217;s energy saving engine</a> through the Application Programming Interface (API).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dssw.co.uk/blog/2012/05/14/sending-requests-with-the-power-manager-sdk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binding with the Power Manager SDK</title>
		<link>http://www.dssw.co.uk/blog/2012/05/09/binding-with-the-power-manager-sdk/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=binding-with-the-power-manager-sdk</link>
		<comments>http://www.dssw.co.uk/blog/2012/05/09/binding-with-the-power-manager-sdk/#comments</comments>
		<pubDate>Wed, 09 May 2012 08:10:09 +0000</pubDate>
		<dc:creator>Graham Miln</dc:creator>
				<category><![CDATA[PM4]]></category>
		<category><![CDATA[Power Manager]]></category>
		<category><![CDATA[Recipe]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://www.dssw.co.uk/blog/?p=1657</guid>
		<description><![CDATA[Binding makes it easy to track changes in the Power Manager engine. Binding is part of Objective-C/Cocoa's Key Value Observation (KVO) methodology, and Power Manager SDK provides full support for this sophisticated ability. <a href="http://www.dssw.co.uk/blog/2012/05/09/binding-with-the-power-manager-sdk/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Binding makes it easy to track changes in the Power Manager engine. Binding is part of Objective-C/Cocoa&#8217;s Key Value Observation (KVO) methodology, and <a href="http://www.dssw.co.uk/powermanager/developer/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=sdk-how-to" title="Power Manager Software Development Kit (SDK)">Power Manager SDK</a> provides full support for this sophisticated ability.</p>
<p>Previously we walked through <a href="http://www.dssw.co.uk/blog/2012/05/04/observing-with-the-power-manager-sdk/" title="Observing with the Power Manager SDK">how to bind a piece of user interface to Power Manager</a>. This time we will write a small tool that binds programmatically and runs without a graphical interface.</p>
<p>This recipe will highlight just how seamlessly you can integrate with Power Manager&#8217;s engine. All the networking, notifications, and requests are handled for you, all thanks to <strong>DSSWPMObserver</strong>.</p>
<h3>Binding to the Events</h3>
<p>We are going to create a small tool that binds an array to Power Manager&#8217;s events. The events we want to bind to those returned by the <strong>eventstore.events</strong> variable.</p>
<p>The resulting tool will have an NSArray of NSDictionaries managed and kept in sync with Power Manager&#8217;s events. As changes occur in Power Manager&#8217;s events, those changes will be instantly and automatically reflected in the tool.</p>
<ol>
<li>Create a new <code>command line </code>project in Xcode 4.<br />
<div id="attachment_1658" class="wp-caption aligncenter" style="width: 654px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/1-power-manager-xcode-command-line-project.jpg" alt="Create a new command line project in Xcode." title="Create a new command line project in Xcode." width="644" height="442" class="size-full wp-image-1658" /><p class="wp-caption-text">Create a new command line project in Xcode.</p></div>
</li>
<li>Select the <code>Foundation</code> type of project; this includes the Foundation framework.
<p><div id="attachment_1659" class="wp-caption aligncenter" style="width: 654px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/2-power-manager-xcode-command-line-options.jpg" alt="Select the Foundation type of project." title="Select the Foundation type of project." width="644" height="442" class="size-full wp-image-1659" /><p class="wp-caption-text">Select the Foundation type of project.</p></div>
</li>
<li><a href="http://www.dssw.co.uk/blog/2012/05/02/connecting-with-the-power-manager-sdk/" title="Connecting with the Power Manager SDK">Add the <strong>PowerManager.framework</strong> to your project</a>.</li>
<li>Copy and paste the following code into your <strong>main.m</strong> file:
<pre class="objc">
#import &lt;Cocoa/Cocoa.h&gt;
#import &lt;PowerManager/PowerManager.h&gt;

@interface Bound : NSObject {
    NSArray* events;
}
@property (retain) DSSWPMConnection* connection;
@property (retain) DSSWPMObserver* observer;
@property (retain) NSArray* events;
@end

@implementation Bound
@synthesize connection;
@synthesize observer;

- (id)init
{
    if (self = [super init])
    {
        self.connection = DSSWPMConnection.connection;
        self.connection.keepAlive = YES; // Stop idle connections disconnecting
        self.connection.autoReconnect = YES; // Reconnect if connection dropped

        self.observer = [[[DSSWPMObserver alloc] initWithConnection:connection] autorelease];

        // Bind the events in this object to Power Manager's eventstore.events
        [self bind:@"events" toObject:self.observer withKeyPath:(NSString*)kPMRPCEventStoreEvents options:nil];
    }
    return self;
}

- (void)dealloc
{
    [self unbind:@"events"];
    self.events = nil;
    self.observer = nil;
    self.connection = nil;
    [super dealloc];
}

- (NSArray*)events
{
    return [[events retain] autorelease];
}

- (void)setEvents:(NSArray *)inEvents
{
    if (inEvents != events)
    {
        [events release];
        events = [inEvents retain];

        // Print a list of the event names
        NSLog(@"setEvents called with %d events:",(int)events.count);
        for(NSDictionary* event in events)
        {
            NSLog(@"- %@",[event objectForKey:(NSString*)kPMEventName]);
        }
    }
}

@end

int main(int argc, const char * argv[])
{
    @autoreleasepool {
        Bound* bound = [[Bound alloc] init];

        // Run until terminated
        [[NSRunLoop mainRunLoop] run];

        [bound release];
    }
    return 0;
}</pre>
</li>
<li>Build and run the project.</li>
</ol>
<p>With the tool running add, edit, and remove events from Power Manager. The tool will automatically print an updated list of events with each change.</p>
<div id="attachment_1660" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/3-power-manager-command-line-events-tool.jpg" alt="The command line tool prints the names of your Power Manager events." title="The command line tool prints the names of your Power Manager events." width="593" height="509" class="size-full wp-image-1660" /><p class="wp-caption-text">The command line tool prints the names of your Power Manager events.</p></div>
<p>This code works by setting up an association between your local <strong>bound</strong> object with the corresponding <strong>eventstore.events</strong> variable being managed by Power Manager. The DSSWPMObserver object is responsible for performing the steps required to make this happen.</p>
<p>You can use this technique to bind to any variable provided by the <a href="http://www.dssw.co.uk/powermanager/developer/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=sdk-how-to" title="Power Manager Software Development Kit (SDK)">Power Manager SDK</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dssw.co.uk/blog/2012/05/09/binding-with-the-power-manager-sdk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Observing with the Power Manager SDK</title>
		<link>http://www.dssw.co.uk/blog/2012/05/04/observing-with-the-power-manager-sdk/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=observing-with-the-power-manager-sdk</link>
		<comments>http://www.dssw.co.uk/blog/2012/05/04/observing-with-the-power-manager-sdk/#comments</comments>
		<pubDate>Fri, 04 May 2012 10:29:08 +0000</pubDate>
		<dc:creator>Graham Miln</dc:creator>
				<category><![CDATA[PM4]]></category>
		<category><![CDATA[Power Manager]]></category>
		<category><![CDATA[Recipe]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[software development kit]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.dssw.co.uk/blog/?p=1643</guid>
		<description><![CDATA[How can you create an interface that always shows the latest information, but does not require a refresh button? For Objective-C developers the answer is to set up code to observe changes. <a href="http://www.dssw.co.uk/blog/2012/05/04/observing-with-the-power-manager-sdk/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>How can you create an interface that always shows the latest information, but does not require a refresh button? For Objective-C developers the answer is to set up code to observe changes.</p>
<p>The <a href="http://www.dssw.co.uk/powermanager/developer/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=sdk-how-to" title="Power Manager Software Development Kit">Power Manager SDK</a> includes the <strong>DSSWPMObserver</strong> object. This Objective-C/Cocoa object is wonderful because it makes writing responsive energy saving tools easy.</p>
<p>The process of observing changes is called Key Value Observation (KVO). Understanding and using KVO is a core feature of developing in Objective-C/Cocoa on the Mac and on iOS.</p>
<p>Typically KVO is used within an application. For Power Manager, we have extended KVO to work with any Power Manager connection, including those connected over a network. The same code that observes a change in Power Manager events on your Mac will work for observing changes in events on a remote Mac located on the other side of the planet. The networking is dealt with for you.</p>
<p>Let&#8217;s jump into how to use Power Manager SDK&#8217;s Key Value Observation support. We will do this by extending the <a href="http://www.dssw.co.uk/blog/2012/05/02/connecting-with-the-power-manager-sdk/" title="Connecting with the Power Manager SDK">connecting recipe&#8217;s Xcode project</a>.</p>
<p>This example will require no new code. The observation binding will be done entirely using Xcode&#8217;s user interface tools.</p>
<h3>Binding to Power Manager</h3>
<p>Follow the steps in the <a href="http://www.dssw.co.uk/blog/2012/05/02/connecting-with-the-power-manager-sdk/" title="Connecting with the Power Manager SDK">connecting recipe</a> to create a Power Manager aware project.</p>
<p>Your Objective-C Xcode project has a Power Manager connection and observer created in the application delegate. We are going to bind a label in the user interface to this observer.</p>
<ol>
<li>Select the <strong>MainMenu.xib</strong> in Xcode.</li>
<li>Click on the <strong>Window</strong> object within the xib.</li>
<li>Add a new label to the window.</li>
<li>Bind the label&#8217;s value to the application delegate object:
<ul>
<li>Bind To: <strong>Test App Delegate</strong></li>
<li>Model Key Path: <strong>self.observer.scheduler.enabled</strong></li>
</ul>
<div id="attachment_1644" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/1-power-manager-sdk-bind-to-observe-kvo.jpg" alt="Bind the label to the application delegate obsever." title="Bind the label to the application delegate obsever." width="593" height="302" class="size-full wp-image-1644" /><p class="wp-caption-text">Bind the label to the application delegate obsever.</p></div>
<p><div id="attachment_1645" class="wp-caption aligncenter" style="width: 256px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/2-power-manager-sdk-kvo-xcode-panel.jpg" alt="Add the KVO path of the value you want to observe." title="Add the KVO path of the value you want to observe." width="246" height="364" class="size-full wp-image-1645" /><p class="wp-caption-text">Add the KVO path of the value you want to observe.</p></div>
	</li>
<li>Build and run the project.</li>
</ol>
<p>The running application will show a window with either a <strong>1</strong> or a <strong>0</strong> for the label. It may not immediately seem exciting, but try starting and stopping Power Manager.</p>
<div id="attachment_1647" class="wp-caption aligncenter" style="width: 221px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/3-power-manager-sdk-test-app-bound.jpg" alt="The test application updates instantly as Power Manager changes." title="The test application updates instantly as Power Manager changes." width="211" height="92" class="size-full wp-image-1647" /><p class="wp-caption-text">The test application updates instantly as Power Manager changes.</p></div>
<p>Your label will change to <strong>1</strong> when Power Manager is running, and <strong>0</strong> when Power Manager is stopped. This happens automatically and instantly thanks to the observation you created.</p>
<p>Try changing the <strong>Model Key Path</strong> to one of the following:</p>
<ul>
<li><code>self.observer.build.version</code></li>
<li><code>self.observer.client.computername</code></li>
<li><code>self.observer.eventstore.events</code></li>
</ul>
<p>Every variable in the <a href="http://www.dssw.co.uk/powermanager/developer/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=sdk-how-to" title="Extending Power Manager">Power Manager Application Programmer Interface</a> (API) can be bound to and observed.</p>
<p>Thanks to the <strong>DSSWPMObserver</strong> object you can use Objective-C/Cocoa&#8217;s KVO mechanism to build responsive interfaces with very little code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dssw.co.uk/blog/2012/05/04/observing-with-the-power-manager-sdk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting with the Power Manager SDK</title>
		<link>http://www.dssw.co.uk/blog/2012/05/02/connecting-with-the-power-manager-sdk/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=connecting-with-the-power-manager-sdk</link>
		<comments>http://www.dssw.co.uk/blog/2012/05/02/connecting-with-the-power-manager-sdk/#comments</comments>
		<pubDate>Wed, 02 May 2012 08:02:36 +0000</pubDate>
		<dc:creator>Graham Miln</dc:creator>
				<category><![CDATA[PM4]]></category>
		<category><![CDATA[Power Manager]]></category>
		<category><![CDATA[Recipe]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[software development kit]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.dssw.co.uk/blog/?p=1635</guid>
		<description><![CDATA[You can create tools and utilities that talk directly to Power Manager using the Software Development Kit (SDK). Connecting to Power Manager from your software is easy and requires only a few lines of code. <a href="http://www.dssw.co.uk/blog/2012/05/02/connecting-with-the-power-manager-sdk/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You can create tools and utilities that talk directly to <a href="http://www.dssw.co.uk/powermanager/developer/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=sdk-how-to" title="Power Manager's Software Development Kit (SDK)">Power Manager using the Software Development Kit</a> (SDK). Connecting to Power Manager from your software is easy and requires only a few lines of code.</p>
<p>The Power Manager SDK is included as standard with Power Manager. There are no additional tools, software, or licences to deal with in order to start using the Power Manager SDK.</p>
<p>Let&#8217;s walk through the steps needed to create a connection from your program to Power Manager. We are going to use Xcode 4 and Objective-C/Cocoa for this example.</p>
<h3>Create an Xcode Project</h3>
<p>We need a project to add Power Manager support to. I recommend starting a small test project to experiment with first. You can later add Power Manager to existing projects.</p>
<ol>
<li>Create a new project with <strong>Xcode</strong>: <strong>File</strong> > <strong>New</strong> > <strong>Project…</strong></li>
<li>Select the <strong>Cocoa Application</strong> project template.</li>
<li>Work through Xcode&#8217;s project creation steps.</li>
</ol>
<h3>Add the Power Manager Framework</h3>
<p>We need to add the <code>PowerManager.framework</code> to our Xcode project. This framework includes everything you need to connect with Power Manager.</p>
<ol>
<li>Navigate to the project&#8217;s <strong>Build Phases</strong> in Xcode.
<p><div id="attachment_1637" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/1-power-manager-xcode-build-phases.jpg" alt="Within Xcode, navigate to your project&#039;s Build Phases." title="Within Xcode, navigate to your project&#039;s Build Phases." width="593" height="458" class="size-full wp-image-1637" /><p class="wp-caption-text">Within Xcode, navigate to your project&#039;s Build Phases.</p></div>
</li>
<li>In the <strong>Link Binary With Libraries</strong> phase, click <strong>+</strong> to add a library.
<p><div id="attachment_1638" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/2-power-manager-xcode-add-framework.jpg" alt="Add the framework called PowerManager.framework" title="Add the framework called PowerManager.framework" width="593" height="458" class="size-full wp-image-1638" /><p class="wp-caption-text">Add the framework called PowerManager.framework</p></div>
</li>
<li><strong>Add</strong> the <strong>PowerManager.framework</strong>.
<p><div id="attachment_1639" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/05/3-power-manager-xcode-frameworked-added.jpg" alt="The Power Manager framework should now be listed and linked during builds." title="The Power Manager framework should now be listed and linked during builds." width="593" height="458" class="size-full wp-image-1639" /><p class="wp-caption-text">The Power Manager framework should now be listed and linked during builds.</p></div></li>
</ol>
<p>If the <code>PowerManager.framework</code> is not listed, look for the framework in the folder <code>/Library/Frameworks/</code>. If the framework is missing, <a href="http://www.dssw.co.uk/powermanager/standard/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=sdk-how-to" title="Power Manager">install Power Manager on your Mac</a>.</p>
<h3>Create a Connection</h3>
<p>With the framework added to your project, you can now connect to Power Manager.</p>
<p>For this experiment, let&#8217;s add a Power Manager connection to the project&#8217;s <code>application delegate</code>. This is an object created when the application is launched. The files for this object should have been created by Xcode for you.</p>
<p>Look for a pair of files ending with <strong>AppDelegate</strong>; in my case, the file name is <strong>DSSWTestAppDelegate</strong>.</p>
<p>We are going to add a few bits and pieces to both the header (.h) and body (.m) files. Let&#8217;s look at the finished <strong>DSSWTestAppDelegate.h</strong> first:</p>
<pre class="objc">#import &lt;Cocoa/Cocoa.h&gt;
#import &lt;PowerManager/PowerManager.h&gt;

@interface DSSWTestAppDelegate : NSObject &lt;NSApplicationDelegate&gt;

@property (assign) IBOutlet NSWindow *window;
@property (retain) DSSWPMConnection *connection;
@property (retain) DSSWPMObserver *observer;

@end</pre>
<p>In the header file:</p>
<ul>
<li>I have added an import to open up access to the contents of  PowerManager.framework.</li>
<li>I have added declarations for two new properties; a connection and an observer.</li>
</ul>
<p>Let&#8217;s look at the finished <strong>DSSWTestAppDelegate.m</strong> next:</p>
<pre class="objc">#import "DSSWTestAppDelegate.h"

@implementation DSSWTestAppDelegate

@synthesize window = _window;
@synthesize connection;
@synthesize observer;

- (void)dealloc
{
    self.observer = nil;
    self.connection = nil;
    [super dealloc];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    self.connection = DSSWPMConnection.connection;
    self.connection.keepAlive = YES;
    self.connection.autoReconnect = YES;
    self.observer = [[[DSSWPMObserver alloc] initWithConnection:self.connection] autorelease];
}

@end</pre>
<p>In the body file:</p>
<ul>
<li>I have added synthesize entries for the connection and observer.</li>
<li>I instigate the connection and observer when the application launches.</li>
<li>I nullify the connection and observer when the application delegate is deallocated.</li>
</ul>
<p>This small body of code is all you need in order to set up and maintain a connection to Power Manager running on your Mac.</p>
<p>Next learn <a href="http://www.dssw.co.uk/blog/2012/05/04/observing-with-the-power-manager-sdk/" title="Observing with the Power Manager SDK">how to observe changes in Power Manager</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dssw.co.uk/blog/2012/05/02/connecting-with-the-power-manager-sdk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Set the Volume When Logging In</title>
		<link>http://www.dssw.co.uk/blog/2012/04/26/how-to-set-the-volume-when-logging-in/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-set-the-volume-when-logging-in</link>
		<comments>http://www.dssw.co.uk/blog/2012/04/26/how-to-set-the-volume-when-logging-in/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 08:58:08 +0000</pubDate>
		<dc:creator>Graham Miln</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[PM4]]></category>
		<category><![CDATA[Power Manager]]></category>
		<category><![CDATA[Recipe]]></category>

		<guid isPermaLink="false">http://www.dssw.co.uk/blog/?p=1616</guid>
		<description><![CDATA[Chances are, at one time or another, you have raised the volume on your Mac and forgotten to quieten it afterwards. That next alert, bleep, or song played at full volume was unwelcome at best. <a href="http://www.dssw.co.uk/blog/2012/04/26/how-to-set-the-volume-when-logging-in/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Chances are, at one time or another, you have raised the volume on your Mac and forgotten to quieten it afterwards. That next alert, bleep, or song played at full volume was unwelcome at best.</p>
<p>In a busy environment, such as a lab or business, being able to ensure the Mac&#8217;s volume is set at a reasonable level when a user logs in is essential.</p>
<p>You can programmatically change a Mac&#8217;s system volume through AppleScript. We are going to use this ability to create an event in <a href="http://www.dssw.co.uk/powermanager/standard/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=how-to" title="Power Manager">Power Manager</a>. The event will be triggered when a user logs in, and will perform a small volume setting AppleScript.</p>
<p>Let&#8217;s walk through how to create a log in triggered AppleScript.</p>
<p><iframe src="http://youtube.com/embed/xx1E0JQ2tuA?rel=0" frameborder="0" width="640" height="390"></iframe></p>
<h3>Create a Run AppleScript at Log In Event</h3>
<p>We are going to divide this recipe into two sections. The first will use the Schedule Assistant to <a href="http://www.dssw.co.uk/blog/2010/07/26/how-to-schedule-an-applescript-on-mac-os-x/" title="How to Schedule an AppleScript on Mac OS X">create a daily AppleScript event</a>, and finally we will modify this event by adding a log in trigger.</p>
<h4>Create a Daily AppleScript Event</h4>
<ol>
<li>Launch <strong>System Preferences</strong> and select <strong>Power Manager</strong>.</li>
<li>Click <strong>Add…</strong> to create a new event.
<p><div id="attachment_1618" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/0-power-manager-click-add.jpg" alt="Click the Add button to create a new Power Manager event." title="Click the Add button to create a new Power Manager event." width="593" height="385" class="size-full wp-image-1618" /><p class="wp-caption-text">Click the Add button to create a new Power Manager event.</p></div>
</li>
<li>Choose the template <strong>Run a script daily</strong>.
<p><div id="attachment_1619" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/1-power-manager-select-run-a-script-daily.jpg" alt="Choose the Run script daily task." title="Choose the Run script daily task." width="593" height="431" class="size-full wp-image-1619" /><p class="wp-caption-text">Choose the Run script daily task.</p></div>
</li>
<li>Click <strong>Continue</strong> to the <strong>Script</strong> step.</li>
<li>
<p>Copy and paste the following into the <strong>Script to run</strong> text box:</p>
<pre class="applescript">#!/bin/sh

osascript -e "set Volume 3"</pre>
<p>The volume can be set to a number between <code>0</code> (silent) and <code>10</code> (loudest).</p>
<div id="attachment_1620" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/2-power-manager-paste-in-the-applescript.jpg" alt="Copy and paste in the set volume AppleScript." title="Copy and paste in the set volume AppleScript." width="593" height="431" class="size-full wp-image-1620" /><p class="wp-caption-text">Copy and paste in the set volume AppleScript.</p></div>
</li>
<li>Click <strong>Continue</strong> until you reach the <strong>Why</strong> step. There is nothing to change in the <strong>When</strong> and <strong>Constraints</strong> steps.</li>
<li>Give the event a title and add a note about the purpose of the event in the <strong>Why</strong> step.
<p><div id="attachment_1621" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/3-power-manager-name-the-event.jpg" alt="Give your new event a name and add notes about its purpose." title="Give your new event a name and add notes about its purpose." width="593" height="431" class="size-full wp-image-1621" /><p class="wp-caption-text">Give your new event a name and add notes about its purpose.</p></div>
</li>
<li>Click <strong>Continue</strong> and then <strong>Add</strong> to create the new event.
<div id="attachment_1622" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/4-power-manager-confirm-the-event.jpg" alt="Click Add to confirm and create the new Power Manager event." title="Click Add to confirm and create the new Power Manager event." width="593" height="431" class="size-full wp-image-1622" /><p class="wp-caption-text">Click Add to confirm and create the new Power Manager event.</p></div>
<p><div id="attachment_1623" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/5-power-manager-new-event-created.jpg" alt="An event to set the volume once a day has been created." title="An event to set the volume once a day has been created." width="593" height="385" class="size-full wp-image-1623" /><p class="wp-caption-text">An event to set the volume once a day has been created.</p></div>
</li>
</ol>
<p>An event containing the volume setting AppleScript has now been created. This event is set to trigger once a day.</p>
<h4>Add a Log In Trigger to the Event</h4>
<p>We need to modify the event to trigger when a user logs in, instead of performing once a day. To do this, we are going to use the <a href="http://www.dssw.co.uk/powermanager/features/editor/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=how-to" title="Power Manager Event Editor">event editor</a>.</p>
<ol>
<li>Open the event in the event editor; hold down the <strong>Option</strong> and double-click on your event.
<p><div id="attachment_1624" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/6-power-manager-open-with-event-editor.jpg" alt="Double-click the event with the Option key held down." title="Double-click the event with the Option key held down." width="593" height="462" class="size-full wp-image-1624" /><p class="wp-caption-text">Double-click the event with the Option key held down.</p></div>
</li>
<li>Delete the daily trigger; select the Trigger&#8217;s <strong>Action cog</strong> > <strong>Delete…</strong>.
<div id="attachment_1625" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/7-power-manager-delete-the-daily-trigger.jpg" alt="Delete the existing Daily Trigger using the Action pop-up menu." title="Delete the existing Daily Trigger using the Action pop-up menu." width="593" height="462" class="size-full wp-image-1625" /><p class="wp-caption-text">Delete the existing Daily Trigger using the Action pop-up menu.</p></div>
<p><div id="attachment_1626" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/8-power-manager-trigger-deleted.jpg" alt="The event after the Daily Trigger has been deleted." title="The event after the Daily Trigger has been deleted." width="593" height="462" class="size-full wp-image-1626" /><p class="wp-caption-text">The event after the Daily Trigger has been deleted.</p></div>
</li>
<li>Add a log in trigger; select <strong>Add a trigger</strong> > <strong>Log In</strong>.
<p><div id="attachment_1627" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/9-power-manager-add-a-log-in-trigger.jpg" alt="Add a Log In trigger using the Add a trigger pop-up menu." title="Add a Log In trigger using the Add a trigger pop-up menu." width="593" height="462" class="size-full wp-image-1627" /><p class="wp-caption-text">Add a Log In trigger using the Add a trigger pop-up menu.</p></div>
</li>
<li>Click <strong>Save</strong> to save the changes to the event.
<div id="attachment_1628" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/10-power-manager-log-in-trigger-added.jpg" alt="Set volume event with the Log In trigger added." title="Set volume event with the Log In trigger added." width="593" height="462" class="size-full wp-image-1628" /><p class="wp-caption-text">Set volume event with the Log In trigger added.</p></div>
<p><div id="attachment_1629" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/11-power-manager-volume-event-created.jpg" alt="The new set volume Power Manager event is ready." title="The new set volume Power Manager event is ready." width="593" height="385" class="size-full wp-image-1629" /><p class="wp-caption-text">The new set volume Power Manager event is ready.</p></div>
</li>
</ol>
<p>Your new Power Manager event to set the volume is now ready and will perform each time a user logs in.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dssw.co.uk/blog/2012/04/26/how-to-set-the-volume-when-logging-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shutting Down Your Mac Safely</title>
		<link>http://www.dssw.co.uk/blog/2012/04/16/shutting-down-your-mac-safely/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=shutting-down-your-mac-safely</link>
		<comments>http://www.dssw.co.uk/blog/2012/04/16/shutting-down-your-mac-safely/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 08:54:49 +0000</pubDate>
		<dc:creator>Graham Miln</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[PM3]]></category>
		<category><![CDATA[PM4]]></category>
		<category><![CDATA[Power Manager]]></category>
		<category><![CDATA[shut down]]></category>

		<guid isPermaLink="false">http://www.dssw.co.uk/blog/?p=1607</guid>
		<description><![CDATA[A few people have recently asked how Power Manager shuts down their Mac. Let's look at the two main shut down methods available and then how Power Manager strikes a balance between these two approaches. <a href="http://www.dssw.co.uk/blog/2012/04/16/shutting-down-your-mac-safely/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A few people have recently asked how Power Manager shuts down their Mac. Let&#8217;s look at the two main shut down methods available and then how Power Manager strikes a balance between these two approaches.</p>
<p>Many of the problems with automatically shutting down your computer come from poorly behaved applications or from applications stalling while they wait for some form of interaction.</p>
<p>There are two basic approaches to automatically shutting down your Mac. The first is to issue a shut down AppleEvent. The second method is to use the command line tool <code>shutdown</code>.</p>
<p>Of these two methods, Apple recommends the first. In <a href="http://developer.apple.com/library/mac/#qa/qa1134/" title="Programmatically causing restart, shutdown and/or logout">Q&#038;A1134</a>, Apple Developer Technical Support (DTS) recommend asking the System process to shut down through the kAEShutDown AppleEvent. This method mirrors what happens when you select Shut Down from the Finder&#8217;s Apple menu. </p>
<h3>Shut Down with kAEShutDown</h3>
<p>Sending an AppleEvent to the System process requesting a shut down should completely power down your Mac. If all is well, your Mac will shut down in an orderly manner.</p>
<p>Problems arise with applications that need some interaction when they quit. Unsaved changes and running tasks that need to be stopped often end in dialog boxes asking where to save documents and &#8220;are you sure&#8221; alerts. These alerts will typically stop the shut down; in most cases leaving your Mac sitting with some applications quit and others still running.</p>
<p>With Mac OS X 10.7, aka Lion, Apple is moving towards an operating system design that can deal with applications seamlessly quitting and relaunching without user interaction. The design is not yet perfect and does not deal with every contingency but it is a step forward.</p>
<p>It is at this stage that problematic applications prompt people to look at the second shut down method. The second method is shutting down using the command line tool <code>shutdown</code>.</p>
<h3>shutdown -h now</h3>
<p><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/shutdown.8.html" title="Manual for the shutdown command on Mac OS X"><code>shutdown</code></a> is a blunt tool that will in most cases shut down your Mac. It works at a layer below the Mac&#8217;s user interface and is roughly the equivalent of force quitting everything.</p>
<p>With <code>shutdown</code>, Mac applications that would have quit nicely are not given the chance. In most cases using <code>shutdown</code> should be fine but care needs to be taken about denying applications of the opportunity to quit nicely.</p>
<h3>Power Manager</h3>
<p>Power Manager has evolved to do its very best to shut down your Mac in a Mac friendly way. Power Manager will force quit applications that threaten to block the automated shut down, but the force quit is only used after the application has been issued a friendly quit request.</p>
<p>Let&#8217;s walk through what happens when you ask Power Manager to shut down your Mac.</p>
<p>Power Manager is multiple user savvy and first deals with the logged in users. The following steps happen within each logged in user&#8217;s session:</p>
<ol>
<li>Running applications are sent a quit request.</li>
<li>Running applications are given time to quit.</li>
<li>If an application has not quit in time, the application is force quit.</li>
<li>With all the applications quit, the user is logged out.</li>
</ol>
<p>Once all the users are logged out, Power Manager then asks Mac OS X to shut down. You can watch this sequence play out in the transcripts of the Mac&#8217;s <code>system.log</code> file.</p>
<p>Power Manager&#8217;s shut down process is reliable, predictable, and Mac friendly.</p>
<h4>System Folder Applications</h4>
<p>There is one exception where Power Manager will not shut down your Mac. Power Manager will not force quit an application that lives within the <code>/System</code> folder. The contents of this folder are managed by Apple.</p>
<p>If an application within the System folder wants to stop your Mac shutting down, we decided it should be respected. Apple&#8217;s applications should be ideal Mac citizens and quit properly when requested; if they do not, then it hints at underlying problems that need to be addressed rather than masked.</p>
<h3>A Fine Balance</h3>
<p>Automatically shutting down your Mac is possible. Shutting down safely and predictably just takes some effort to get right.</p>
<p><a href="http://www.dssw.co.uk/powermanager/standard/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=design" title="Power Manager">Power Manager</a>&#8216;s approach is to allow Mac OS X to handle as much as possible. Where needed, Power Manager applies a light touch to make sure that applications that might cause problems are dealt with first.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dssw.co.uk/blog/2012/04/16/shutting-down-your-mac-safely/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Shut Down Your Mac After Inactivity</title>
		<link>http://www.dssw.co.uk/blog/2012/04/02/how-to-shut-down-your-mac-after-inactivity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-shut-down-your-mac-after-inactivity</link>
		<comments>http://www.dssw.co.uk/blog/2012/04/02/how-to-shut-down-your-mac-after-inactivity/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 09:13:49 +0000</pubDate>
		<dc:creator>Graham Miln</dc:creator>
				<category><![CDATA[PM4]]></category>
		<category><![CDATA[Power Manager]]></category>
		<category><![CDATA[Recipe]]></category>
		<category><![CDATA[inactivity]]></category>
		<category><![CDATA[shut down]]></category>

		<guid isPermaLink="false">http://www.dssw.co.uk/blog/?p=1593</guid>
		<description><![CDATA[You can make your Mac automatically shut down after a period of inactivity. This ability is not included as standard in Mac OS X; to do this you will need to use Power Manager.
 <a href="http://www.dssw.co.uk/blog/2012/04/02/how-to-shut-down-your-mac-after-inactivity/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You can make your Mac automatically shut down after a period of inactivity. This ability is not included as standard in Mac OS X; to do this you will need to use <a href="http://www.dssw.co.uk/powermanager/standard/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=how-to" title="Power Manager">Power Manager</a>.</p>
<p>Power Manager includes a built-in task that will make your Mac shut down safely after a period of inactivity. Let&#8217;s walk through how to create this task.</p>
<p><iframe src="http://youtube.com/embed/Et3eDgHyxxk?rel=0" frameborder="0" width="640" height="390"></iframe></p>
<h3>Create a Shut Down After Inactivity Event</h3>
<ol>
<li>Launch <strong>System Preferences</strong> and select <strong>Power Manager</strong>.</li>
<li>Click <strong>Add…</strong> to create a new event.
<p><div id="attachment_1594" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/0-power-manager-add-an-event.jpg" alt="Click Add to start creating the shut down event in Power Manager" title="Click Add to start creating the shut down event in Power Manager" width="593" height="385" class="size-full wp-image-1594" /><p class="wp-caption-text">Click Add to start creating the shut down event in Power Manager</p></div>
</li>
<li>Choose the template <strong>Power off after inactivity</strong>.
<p><div id="attachment_1595" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/1-power-manager-select-power-off-after-inactivity-task.jpg" alt="Select the &quot;Power off after inactivity&quot; task for your new event" title="Select the &quot;Power off after inactivity&quot; task for your new event" width="593" height="431" class="size-full wp-image-1595" /><p class="wp-caption-text">Select the &quot;Power off after inactivity&quot; task for your new event</p></div>
</li>
<li>Click <strong>Continue</strong> to the <strong>What and When</strong> step.</li>
<li>By default, the event will Sleep after 15 minutes. Adjust the action to <strong>Shut Down</strong> and the required period of inactivity to match your needs.
<p><div id="attachment_1596" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/2-power-manager-adjust-action-and-duration.jpg" alt="Adjust the event&#039;s action and inactivity duration." title="Adjust the event&#039;s action and inactivity duration." width="593" height="431" class="size-full wp-image-1596" /><p class="wp-caption-text">Adjust the event&#039;s action and inactivity duration.</p></div>
</li>
<li><strong>Continue</strong> through the remaining steps until your event is created.
<div id="attachment_1597" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/3-power-manager-continue-past-time-constraints.jpg" alt="Continue through the Time Constraints" title="Continue through the Time Constraints" width="593" height="431" class="size-full wp-image-1597" /><p class="wp-caption-text">Continue through the Time Constraints</p></div>
<div id="attachment_1598" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/4-power-manager-continue-past-interactive-constraints.jpg" alt="Continue through the Interactive Constraints" title="Continue through the Interactive Constraints" width="593" height="431" class="size-full wp-image-1598" /><p class="wp-caption-text">Continue through the Interactive Constraints</p></div>
<div id="attachment_1599" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/5-power-manager-describe-your-event.jpg" alt="Use the Why step to name and describe your new event" title="Use the Why step to name and describe your new event" width="593" height="431" class="size-full wp-image-1599" /><p class="wp-caption-text">Use the Why step to name and describe your new event</p></div>
<p><div id="attachment_1600" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/6-power-manager-confirm-your-event.jpg" alt="Finally confirm your new Power Manager event" title="Finally confirm your new Power Manager event" width="593" height="431" class="size-full wp-image-1600" /><p class="wp-caption-text">Finally confirm your new Power Manager event</p></div>
</li>
</ol>
<p>Having followed the steps above, you will have created a new event in Power Manager. This event will start working immediately and will shut down your Mac after a period of inactivity.</p>
<div id="attachment_1601" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/04/7-power-manager-shut-down-event-schedule.jpg" alt="Your new shut down after inactivity event is ready and scheduled" title="Your new shut down after inactivity event is ready and scheduled" width="593" height="385" class="size-full wp-image-1601" /><p class="wp-caption-text">Your new shut down after inactivity event is ready and scheduled</p></div>
<p>Remember that unsaved changes may be lost if you let your Mac shut down automatically. Always save changes before leaving your Mac unattended.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dssw.co.uk/blog/2012/04/02/how-to-shut-down-your-mac-after-inactivity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scheduling a Mac to Shut Down</title>
		<link>http://www.dssw.co.uk/blog/2012/03/22/scheduling-a-mac-to-shut-down/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=scheduling-a-mac-to-shut-down</link>
		<comments>http://www.dssw.co.uk/blog/2012/03/22/scheduling-a-mac-to-shut-down/#comments</comments>
		<pubDate>Thu, 22 Mar 2012 10:22:09 +0000</pubDate>
		<dc:creator>Graham Miln</dc:creator>
				<category><![CDATA[Energy saving]]></category>
		<category><![CDATA[Power Manager]]></category>
		<category><![CDATA[energy saver]]></category>
		<category><![CDATA[pmset]]></category>

		<guid isPermaLink="false">http://www.dssw.co.uk/blog/?p=1586</guid>
		<description><![CDATA[Mac OS X includes the ability to put a Mac to sleep at a scheduled time. You can also schedule your Mac to shut down or restart at a specific time on certain days of the week. <a href="http://www.dssw.co.uk/blog/2012/03/22/scheduling-a-mac-to-shut-down/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Mac OS X includes the ability to put a Mac to sleep at a scheduled time. You can also schedule your Mac to shut down or restart at a specific time on certain days of the week.</p>
<p>This ability is included as standard with Mac OS X. It has limitations but for many this will be enough to start saving energy.</p>
<p>Let&#8217;s walk through how to schedule your Mac to sleep, shut down, or restart at a specific time.</p>
<h3>Energy Saver&#8217;s Schedule</h3>
<ol>
<li>Launch <strong>System Preferences</strong> > <strong>Energy Saver</strong><br />
<div id="attachment_1587" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/0-mac-energy-saver.jpg" alt="Open Energy Saver in Mac OS X&#039;s System Preferences" title="Open Energy Saver in Mac OS X&#039;s System Preferences" width="593" height="452" class="size-full wp-image-1587" /><p class="wp-caption-text">Open Energy Saver in Mac OS X&#039;s System Preferences</p></div>
</li>
<li>Click on the <strong>Schedule…</strong> button in the lower-right.
<p><div id="attachment_1588" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/1-energy-saver-schedule.jpg" alt="Energy Saver&#039;s Schedule options" title="Energy Saver&#039;s Schedule options" width="593" height="452" class="size-full wp-image-1588" /><p class="wp-caption-text">Energy Saver&#039;s Schedule options</p></div>
</li>
<li>Enable the check box next to <strong>Sleep</strong> to activate the ability.</li>
<li>
<p>Use the pop-up menus and time to set up your event.</p>
<p>The action menu includes:</p>
<ul>
<li>Sleep</li>
<li>Shut Down</li>
<li>Restart</li>
</ul>
<div id="attachment_1589" class="wp-caption aligncenter" style="width: 415px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/2-energy-saver-schedule-options.jpg" alt="Energy Saver can sleep, shut down, and restart the Mac" title="Energy Saver can sleep, shut down, and restart the Mac" width="405" height="168" class="size-full wp-image-1589" /><p class="wp-caption-text">Energy Saver can sleep, shut down, and restart the Mac</p></div>
<p>The days menu includes:</p>
<ul>
<li>Weekdays</li>
<li>Weekends</li>
<li>Every Day</li>
<li>Monday</li>
<li>Tuesday</li>
<li>Wednesday</li>
<li>Thursday</li>
<li>Friday</li>
<li>Saturday</li>
<li>Sunday</li>
<p><div id="attachment_1590" class="wp-caption aligncenter" style="width: 415px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/3-energy-saver-days.jpg" alt="Energy Saver offers a limited range of days" title="Energy Saver offers a limited range of days" width="405" height="207" class="size-full wp-image-1590" /><p class="wp-caption-text">Energy Saver offers a limited range of days</p></div>
</ul>
</li>
<li>Click <strong>OK</strong> to apply your energy saving event.</li>
</ol>
<p>There are limitations to what can be achieved with Energy Saver&#8217;s Schedule. The user interface only permits a restricted range of event times and days.</p>
<p>If you need more capabilities or want to expand your energy saving schedule, you can turn to the built-in command line tool <strong><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/pmset.1.html" title="User manual for pmset" rel="nofollow">pmset</a></strong>.</p>
<p><strong>pmset</strong> exposes more of Mac OS X&#8217;s capabilities and lets you create more complex schedules. Schedules are still limited in scope, but it offers more than the Energy Saver.</p>
<p>If you need more control and capabilities, try our energy saving <a href="http://www.dssw.co.uk/powermanager/standard/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=how-to" title="Power Manager - energy saving for Mac">Power Manager</a> software.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dssw.co.uk/blog/2012/03/22/scheduling-a-mac-to-shut-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Run a Shell Script When Logging Out</title>
		<link>http://www.dssw.co.uk/blog/2012/03/09/how-to-run-a-shell-script-when-logging-out/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-run-a-shell-script-when-logging-out</link>
		<comments>http://www.dssw.co.uk/blog/2012/03/09/how-to-run-a-shell-script-when-logging-out/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 16:18:47 +0000</pubDate>
		<dc:creator>Graham Miln</dc:creator>
				<category><![CDATA[PM4]]></category>
		<category><![CDATA[Power Manager]]></category>
		<category><![CDATA[Recipe]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://www.dssw.co.uk/blog/?p=1563</guid>
		<description><![CDATA[Let's walk through how to schedule a shell script to run after a user logs out of Mac OS X. Our shell script is going to be very simple but you can make yours as complex as needs be. <a href="http://www.dssw.co.uk/blog/2012/03/09/how-to-run-a-shell-script-when-logging-out/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As a Mac administrator it can be useful to be run a shell script each time a user logs out. This allows a script to clean up temporary files, back up changes, and restore sane defaults for the next user.</p>
<p>Let&#8217;s walk through how to schedule a shell script to run after a user logs out of Mac OS X. Our shell script is going to be very simple but you can make yours as complex as needs be.</p>
<p>We are going to start by using the <a href="http://www.dssw.co.uk/powermanager/features/assistant/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=how-to">Schedule Assistant</a> built into Power Manager and then we are going to customise the event using the <a title="Power Manager's Schedule Assistant" href="http://www.dssw.co.uk/powermanager/features/editor/index.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=how-to">Event Editor</a>.</p>
<h3>Scheduling a Log Out Shell Script</h3>
<ol>
<li>Launch <strong>System Preferences</strong> and select <strong>Power Manager</strong>.</li>
<li>Click <strong>Add…</strong> to create a new event.
<p><div id="attachment_1565" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/1-launch-power-manager-and-click-add.jpg" alt="Launch Power Manager and click the Add button" title="Launch Power Manager and click the Add button" width="593" height="385" class="size-full wp-image-1565" /><p class="wp-caption-text">Launch Power Manager and click the Add button</p></div>
</li>
<li>Choose the template <strong>Run a script</strong>.
<p><div id="attachment_1566" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/2-select-the-run-a-script-task.jpg" alt="Select the Run a Script task in the Schedule Assistant" title="Select the Run a Script task in the Schedule Assistant" width="593" height="431" class="size-full wp-image-1566" /><p class="wp-caption-text">Select the Run a Script task in the Schedule Assistant</p></div>
</li>
<li>Click <strong>Continue</strong> to the <strong>Script</strong> step.</li>
<li>
<p>Copy and paste your shell script into the <strong>Script</strong> step.</p>
<pre class="shell">#!/bin/sh

touch /tmp/lastlogout.txt</pre>
<p>The shell script can be run as the root user, as a normal user, or even as whoever is currently logged in at the time. For this script, we have set the <strong>Environment</strong> to <strong>Super User (root)</strong>.</p>
<div id="attachment_1567" class="wp-caption aligncenter" style="width: 603px"><a href="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/3-copy-and-paste-in-your-shell-script.jpg"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/3-copy-and-paste-in-your-shell-script.jpg" alt="Copy and paste in your shell script" title="Copy and paste in your shell script" width="593" height="431" class="size-full wp-image-1567" /></a><p class="wp-caption-text">Copy and paste in your shell script</p></div>
</li>
<li>Click <strong>Continue</strong> to the <strong>When</strong> step.</li>
<li>Adjust the time and date to the distant future; this trigger will be replaced in a later step.
<p><div id="attachment_1568" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/4-select-a-date-in-the-future.jpg" alt="Change the date to a time in the future" title="Change the date to a time in the future" width="593" height="431" class="size-full wp-image-1568" /><p class="wp-caption-text">Change the date to a time in the future</p></div>
</li>
<li>
<p><strong>Continue</strong> through the remaining steps until your event is created.</p>
<div id="attachment_1569" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/5-continue-passed-the-constraints.jpg" alt="Continue passed the Constraints step" title="Continue passed the Constraints step" width="593" height="431" class="size-full wp-image-1569" /><p class="wp-caption-text">Continue passed the Constraints step</p></div>
<div id="attachment_1570" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/6-name-and-describe-your-power-manager-event.jpg" alt="Name and description your Power Manager event" title="Name and description your Power Manager event" width="593" height="431" class="size-full wp-image-1570" /><p class="wp-caption-text">Name and description your Power Manager event</p></div>
<div id="attachment_1571" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/7-confirm-the-event.jpg" alt="Confirm the event and click Add" title="Confirm the event and click Add" width="593" height="431" class="size-full wp-image-1571" /><p class="wp-caption-text">Confirm the event and click Add</p></div>
<p>With these steps completed, you will have a basic Power Manager event queued up. This event includes your shell script but is not yet triggered after log out.</p>
<div id="attachment_1572" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/8-hold-option-and-double-click-the-event.jpg" alt="The event has been created but is not yet finished" title="The event has been created but is not yet finished" width="593" height="385" class="size-full wp-image-1572" /><p class="wp-caption-text">The event has been created but is not yet finished</p></div>
<p>Let&#8217;s customise this event using the Event Editor. We want to replace the <a href="http://www.dssw.co.uk/powermanager/guide/v4/developer/pme.structure.triggeronce.html?utm_source=dssw&#038;utm_medium=blog&#038;utm_campaign=how-to" title="Power Manager Developer: trigger once">Date and Time based trigger</a> with a <a href="http://www.dssw.co.uk/powermanager/guide/v4/developer/pme.structure.triggerlogout.html" title="Power Manager Developer - log out trigger">Log Out trigger</a>.</p>
</li>
<li>Hold down the <strong>Option</strong> key on the keyboard and double-click on your event; the Event Editor will now appear.
<p><div id="attachment_1573" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/9-power-managers-event-editor.jpg" alt="Your event in Power Manager&#039;s Event Editor" title="Your event in Power Manager&#039;s Event Editor" width="593" height="462" class="size-full wp-image-1573" /><p class="wp-caption-text">Your event in Power Manager&#039;s Event Editor</p></div>
</li>
<li>Delete the existing Date and Time trigger; use the <strong>Action cog</strong> and select <strong>Delete…</strong>.
<div id="attachment_1574" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/10-delete-the-date-and-time-trigger.jpg" alt="Delete the date and time trigger from the event" title="Delete the date and time trigger from the event" width="593" height="462" class="size-full wp-image-1574" /><p class="wp-caption-text">Delete the date and time trigger from the event</p></div>
<p><div id="attachment_1575" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/11-the-event-with-the-trigger-deleted.jpg" alt="The event with the date and time triggered deleted" title="The event with the date and time triggered deleted" width="593" height="462" class="size-full wp-image-1575" /><p class="wp-caption-text">The event with the date and time triggered deleted</p></div>
</li>
<li>Add a new Log Out trigger; use the <strong>Add a trigger</strong> pop-up menu and select <strong>Log Out</strong>.
<p><div id="attachment_1576" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/12-add-a-log-out-trigger.jpg" alt="Add a Log Out trigger to your event" title="Add a Log Out trigger to your event" width="593" height="462" class="size-full wp-image-1576" /><p class="wp-caption-text">Add a Log Out trigger to your event</p></div>
</li>
<li>Click <strong>Save</strong> to save your changes and finish editing the event.
<p><div id="attachment_1577" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/13-the-event-with-a-log-out-trigger.jpg" alt="Click Save to save the changes and close the Event Editor" title="Click Save to save the changes and close the Event Editor" width="593" height="462" class="size-full wp-image-1577" /><p class="wp-caption-text">Click Save to save the changes and close the Event Editor</p></div></li>
</ol>
<div id="attachment_1578" class="wp-caption aligncenter" style="width: 603px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/03/14-run-shell-script-after-log-out-event.jpg" alt="The finished event to run a shell script after log out is ready" title="The finished event to run a shell script after log out is ready" width="593" height="385" class="size-full wp-image-1578" /><p class="wp-caption-text">The finished event to run a shell script after log out is ready</p></div>
<p>Your new Power Manager event is ready and will now run every time a user logs out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dssw.co.uk/blog/2012/03/09/how-to-run-a-shell-script-when-logging-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sleep Monitor Recommended by For Mac Eyes Only</title>
		<link>http://www.dssw.co.uk/blog/2012/02/28/sleep-monitor-recommended-by-for-mac-eyes-only/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sleep-monitor-recommended-by-for-mac-eyes-only</link>
		<comments>http://www.dssw.co.uk/blog/2012/02/28/sleep-monitor-recommended-by-for-mac-eyes-only/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 15:05:15 +0000</pubDate>
		<dc:creator>Graham Miln</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Sleep Monitor]]></category>
		<category><![CDATA[SM3]]></category>
		<category><![CDATA[For Mac Eyes Only]]></category>

		<guid isPermaLink="false">http://www.dssw.co.uk/blog/?p=1557</guid>
		<description><![CDATA[Thanks to Eric Erickson, For Mac Eyes Only, for reviewing and recommending Sleep Monitor 3. <a href="http://www.dssw.co.uk/blog/2012/02/28/sleep-monitor-recommended-by-for-mac-eyes-only/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Thanks to Eric Erickson, <a href="http://www.formaceyesonly.com/" title="For Mac Eyes Only">For Mac Eyes Only</a>, for <a href="http://www.formaceyesonly.com/2012/02/24/mac-app-review-sleep-monitor/" title="Mac App Review: Sleep Monitor">reviewing and recommending Sleep Monitor 3</a>.</p>
<div id="attachment_1558" class="wp-caption aligncenter" style="width: 138px"><img src="http://www.dssw.co.uk/blog/wp-content/uploads/2012/02/For-Mac-Eyes-Only-logo.jpeg" alt="Sleep Monitor 3 recommended by For Mac Eyes Only" title="Sleep Monitor 3 recommended by For Mac Eyes Only" width="128" height="128" class="size-full wp-image-1558" /><p class="wp-caption-text">Sleep Monitor 3 recommended by For Mac Eyes Only</p></div>
<p>Eric&#8217;s review is detailed and covers <a href="http://www.dssw.co.uk/sleepmonitor/index.html?utm_source=formaceyesonly&#038;utm_medium=blog&#038;utm_campaign=formaceyesonly" title="DssW Sleep Monitor for Mac OS X">Sleep Monitor</a>&#8216;s capabilities well. I was pleased to see the AppleScript interface provided an answer for one potential short coming.</p>
<p>One aspect Eric raised was the missing ability to export your data. This is possible to do with Sleep Monitor; you can export all your gathered information using the <code>File > Export…</code> menu item. Sleep Monitor can export your data in RTF, plain text, Word, and XML formats. The plain text export is tab separated, so can be imported directly into a spreadsheet.</p>
<p>A free 30 day demonstration of <a href="http://www.dssw.co.uk/sleepmonitor/index.html?utm_source=formaceyesonly&#038;utm_medium=blog&#038;utm_campaign=formaceyesonly" title="DssW Sleep Monitor for Mac OS X">Sleep Monitor</a> is available to download and try now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dssw.co.uk/blog/2012/02/28/sleep-monitor-recommended-by-for-mac-eyes-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching using disk: basic
Object Caching 721/824 objects using disk: basic

Served from: www.dssw.co.uk @ 2012-05-17 10:40:31 -->
