Category Archives: Yosemite

how to track your clones

screen-shot-2016-12-22-at-16-03-53



Last week I was asked whether I could produce a script that would keep track of Carbon Copy Cloner backup tasks so that a user could tell which of many, multiple backups of the same source disks were the most recent.

Of course, CCC has its own Task History and Disk Center functions to provide information, but these turn out to be insufficient in common scenarios. To see why, let’s consider a hypothetical task set-up and recovery situation.

In this situation, let’s suppose I’m keeping 2-hourly, daily and weekly clones of my mac’s internal disk. While I’m logged in to my mac, I can of course check CCC’s Task History to see when the last back up was, the destination, and whether it was successful or not.



screen-shot-2016-12-22-at-17-49-14



However, suppose the internal disk fails – just the situation for which I keep my CCC backups on a regular schedule. Which disk contains my latest backup? The information from CCC’s history task is on the failed internal disk, so it is not now available to me. Of course, each backup contains CCC’s earlier History too, but there’s several problems here. First, these cloned task histories do not contain the history from the *last* task (that’s only written to the source disk after the last backup completes). Second, to compare them, I’d have to boot each clone individually – a time-consuming and not terribly convenient process. Third, CCC’s ‘Disk Center’ only provides backup information about connected disks if the current startup disk was used to run the backup task. Thus, if I backup Disk B from Disk C, that information won’t be available to me when I startup my mac with Disk A.

Before I discuss the solution to this, let me just complicate the scenario further. I have two other macs – two 13″ MacBook Pros that have been going strong since 2009 – each of which I backup to individual clones. There’s no way for me to see all the backup dates from all my macs with CCC. Further, we don’t need to consider only disk failure as a reason to need comparative backup history. Since some files are shared or swapped across my three macs, there’s no way to find out from CCC’s Task History or Disk Center when the latest backup of any particular one of those files was made, or on which backup disk I can find it. For example, the connected disk ‘MBP Z Clone’ is a scheduled task on my MBP, but looking at this disk when connected to my iMac gives me no information about its backup history:



screen-shot-2016-12-22-at-17-50-20


Fortunately, CCC has two features which make our problems solvable. First, each source disk keeps detailed logs of the backups it has run (from which the Task History and Disk Center info is constructed); secondly, CCC allows us to run a shell script after each task has completed.

These two little features are going to allow us to build a shell script that will write a special log file to the destination after each task completes, and then retrieve it and compare it against both the current source and other disks. That means we’ll be able to get CCC backup data from any disk we connect to any mac, since the data will be stored on the destination disk itself thanks to our shell script (for the technically minded: to avoid permissions problems, the script writes to /Users/Shared/ if it’s a bootable clone, or to the root of a disk that isn’t).



screen-shot-2016-12-22-at-17-54-53


That’s the outline of the problem and the solution. What started out as a simple AppleScripting task soon blossomed into a full-blown app. Although much of the background work I’ve outlined above is achievable via AppleScript, displaying the data effectively is rather cludgy, even if one uses some of the excellent scripting libraries like Shane Stanley’s ‘Myriad Tables’ to improve on the stock AppleScript offerings.

Accordingly, after about a week or so of wrestling with an acceptable solution, I finally came up with the Disk Inspector.app to solve all these problems in one go and add a few niceties on top. 😉

Whatismore, since it’s Christmas :D, I’m publishing this as a free utility on my software site, Sqwarq.com. Check out Disk Inspector’s support and download page here: https://sqwarq.com/disk-inspector



Here’s a quick overview of the main features:

1. See dates of all connected disks that have been backed up via CCC*
2. See the latest backup and (if available) Time Machine backup for the current source disk
3. See the OS Version and Build Number on connected, bootable drives
4. Open any disk’s root folder in the Finder by double-clicking its name in DI’s main view
5. See an estimate of the total and available space on each disk (rounded to the nearest GB)
6. Save all the data to a log file for easy record keeping of your backups

* after completing Disk Inspector’s set up procedure


Usage:

For full instructions refer to the Support page, but the basic idea is that on first launch, you run the ‘Set Up’ wizard to configure your tasks in Carbon Copy Cloner. Disk Inspector’s ‘Set Up’ wizard walks you through 5 simple steps to accomplish all this.



screen-shot-2016-12-22-at-17-53-54


Once you’ve completed the set up procedure and each of your scheduled CCC tasks has run, you’ll start to see information for each backup disk in Disk Inspector’s main view on any mac (or on the same mac booted from a different drive) that you subsequently connect those disks to.

Disk Inspector runs on 10.10 and higher.

Enjoy, and Happy holidays to all! 😀

Script Debugger 6: the complete review

SD Shot 2



It feels like cheating. When you’ve spent pretty much your entire AppleScripting life behind the wheel of Apple’s austere Script Editor application, taking Script Debugger 6 out for a 20-day spin feels like someone’s let you in on a secret you’re not supposed to know. Hurdles you’ve taught yourself to clear – through considerable effort, frustration and no small amount of bloody-minded tenacity – are removed before you get to them; obstacles you’ve habitually steered around or avoided have disappeared, and dark holes of AppleScript mystery appear, in the light shone on them by SD6, to be not the menacing entities you once feared but new friends that offer ways to do things faster and more effectively. The secret that Script Debugger seems to lay bare is that AppleScripting doesn’t have to be as painful as we’ve been conditioned to believe. And that does feel like a cheat. Read the full review…


how to find anything on your mac

top shot
 
With the release of FT2 2.13 comes a new SuperSearch function. You can use this to find anything on your mac or connected drives, open folders (including hidden ones) and launch apps. You can open SuperSearch quickly by holding down the shift key when you click the F2 icon in the status bar.

If you’re familiar with EasyFind and Spotlight, you can think of SuperSearch as sort of a ‘Spotlight on Steroids’ (use the ‘Faster’ option’) combined with an ‘EasyFind without the overhead’ (use the ‘Deeper’ option). SuperSearch supports using the spacebar to open Quick Look and double-clicking to reveal an item in the Finder.

For the most part, you’ll want to use the options ‘Faster’, ‘String’ and alternate between ‘Name’ (for files) or ‘Content’ (for text within files). Choose to include case sensitivity, emails and web history as needed. However, there’s a lot of different ways you can use SuperSearch. Here’s a few examples:

Find hidden files
(use ‘Deeper’, ‘Name’, ‘String’)
 
first shot

Find files by bundle identifier
(use ‘Deeper’, ‘Name’, ‘String’)
 
Screen Shot 2016-06-05 at 17.16.32

Open folders in the Finder
(just type the path and hit return; use ~/ to target the home folder; the options are not relevant)
 
second shot
 
Search for text in files
(use ‘Faster’, ‘Content’, ‘String’ for speed, or use ‘Deeper’ if you want to target a particular drive or directory, or if you want to search for content within hidden files and packages, too).

When you use ‘Deeper’ to search for content, the item name includes a hit count of the number of occurrences of the search term in that file:
 
shot three

Launch applications
(prefix the app name with ` (that’s the key directly above the ‘tab’ key) to tell SuperSearch you want to open it rather than find it. The options are not relevant).
 
shot four

🙂
 

how to turn off Maps’ location circle

circle of vagueness



If you’re finding that the large blue location circle is obscuring your view of your current location, here’s a quick script that will allow you to toggle it on and off. You could create a Service and then a hotkey for it, or save the script as an Application and add it to your Dock. That’ll give you a one-click method for toggling the circle on and off – you can also turn it back on (but not off!), just by clicking the usual Location button in Maps’ user interface.

Location script

FastTasks 2 v2.8 released

Screen Shot 2016-03-27 at 19.09.23

 

This update sees the introduction of a major new feature, the TaskPad. If you’ve ever been frustrated by the limitations of Apple’s Notes and Reminders apps and wondered why they didn’t, well, just combine the two, then FT2’s TaskPad may be for you.

Inspired by one of my favourite free apps from the Snow Leopard era, Lighthead software’s Remember.app (still available but sadly never updated to 10.7 and beyond), the TaskPad keeps things light and simple, while having a lot of power to keep you organised and on task.

You can set due dates, add rich-text notes, as well as order and re-order via drag and drop. If you want to use the same database across more than one mac, that’s possible, too (requires an independent syncing service such as Dropbox or similar). You can also maintain more than one list database and switch between them as you need.

Since FastTasks is all about being fast, you don’t need to wade through the main menu to call up the TaskPad (though of course you can do that if you want!). Just hold down the Command key and click the F2 icon and the TaskPad will immediately appear.

Another change in this update is that the Eject Disks function will now let you eject individual disks as well as all disks. We’ve also updated the Analyser with new definitions.

The FT2 2.8 update is available to users on 10.10.5 or above. Unfortunately, FT2 no longer supports OS X Mavericks, but 10.9 users can still download the previous version (2.7) of FT2 for the time being.

 

 

 

how to enable TRIM

trimforce
Starting with 10.10.4, you can now enable Trim for 3rd party disks without resorting to 3rd party tools. Apple have included a new command line utility called trimforce.

Beware, the name was not picked acccidentally. Trimforce forces TRIM activation on all 3rd party SSDs regardless of whether they support it or not, so use at your own discretion. Generally, it should be safe to use if your disk manufacturer recommends having TRIM turned on, but only your own testing will confirm that. As always, be sure you have full and regular backups of your disks in case of data corruption.

Note that trimforce requires sudo — meaning you’ll need an admin password to do this:

sudo trimforce enable

The new command line utility doesn’t have a --status option, so if you want to check the current TRIM status from the command line, you’ll need this command:

system_profiler SPSerialATADataType | grep 'TRIM'

🙂

how to easily import images into new Photos.app

scripting Photos



So with 10.10.3 and Apple’s new Photos’s app, people have been asking how to easily import whole folder’s worth of images into it. Here’s a nice little AppleScript that’ll do it for you very easily. Just plonk the code into Script Editor and hit the run button. 🙂



Click the image below to get the code ꜜ Screen Shot 2015-04-15 at 20.08.31

Here’s the unformatted code that you can cut and paste into Script Editor, or get if from my pastebin here:

--import images from a folder into Photos.app
-- by Applehelwriter 2015 -- requires Yosemite 10.10.3

set importFolder to choose folder

set extensionsList to {"jpg", "png", "tiff"}
tell application "Finder" to set theFiles to every file of importFolder whose name extension is in extensionsList

if (count of theFiles) < 1 then
display dialog "No images selected!" buttons "OK"
else
display dialog "Create a new album with name" default answer "Imports"
set albumName to text returned of the result
set timeNow to time string of (current date)
set today to date string of (current date)
set albumName to albumName & " " & timeNow & " " & today
set imageList to {} repeat with i from 1 to number of items in theFiles
set this_item to item i of theFiles as alias
set the end of imageList to this_item
end repeat

tell application "Photos"
activate
delay 2
import imageList into (make new album named albumName) skip check duplicates yes
end tell

end if

Cocoa: how to show a popover under selected text

Screen Shot 2015-03-25 at 20.49.31

Showing a popover underneath a piece of selected text is a trick widely made use of across OSX, not least in Xcode itself, but also in many other apps. In this post we’re going to look at a simple way to achieve this effect.

1. First of all, in IB drag out a Popover and View Controller and drop them in the Document Outline area. Drag a custom view to the canvas, and hook them all up thus:

Popover’s Outlets
delegate –> App Delegate (or class that will control the Popover)

Popover View Controller’s Outlets
view –> Custom View

Click the Popover object in the Outline area, and in the Attributes Inspector, set the Behaviour to Transient.

In the appDelegate.h file, or the .h file of the class that will control your popover, include the PopoverDelegate in the @interface declaration:

@interface AppDelegate : NSObject <NSApplicationDelegate, NSPopoverDelegate>

2. Still in the header file, you need to make sure the window that the NSTextView is in has a View outlet in its header file.

@property (weak) IBOutlet NSView *aView;

For my purposes, I just have a single window in the appDelegate class, so I just created a view property by control-dragging out of the Window’s view object to the header file. You’ll need to switch to the dual-view Assistant editor to do this:

viewProperty

While you’ve got the Assistant editor open, drag out an outlet from the Popover to the .h file and name it ‘popover’. Finally, in the same way create a similar outlet for your TextView.

4. Next, go into the implementation .m file for the appDelegate (or you class). You’ll need an IBAction to trigger the showing of the popover. In my case, I have an ‘Enter’ button the user hits after making a selection attached to a method I called enterSelection:(NSButton *)sender.

In this method, I first get the rect for the user’s selection with:

NSRect rect = [_textView firstRectForCharacterRange:[_textView selectedRange] actualRange:NULL];

That will return a rect in screen coordinates for the selected text. However, I need to convert that into the window’s coordinates with:

NSRect converted = [_window convertRectFromScreen:rect];

Now we’re ready to call the popover by supplying this rect to the first parameter and the View property we created earlier to the second parameter:

[self.popover showRelativeToRect:converted ofView: _aView preferredEdge:NSMinYEdge];

And that’s it. Your popover should show underneath the selected text whenever your method gets called. If you want to see how this is done step by step in Xcode, check out the video:


 

How to track app use with OSXClock

Screen Shot 2015-03-10 at 17.45.36
OSXClock just got a major update, adding a productivity log that helps you to track how much time you spend actively using each app on your mac.

I wrote an ad-hoc AppleScript to do this sometime ago that proved pretty popular, but I wasn’t satisfied with either the code or the interface. OSXClock improves on that by tapping directly into Cocoa’s API and by offering a more attractive display.

OSXClock is currently on offer for only $2.99. Lots more exciting features are planned for future updates, so now’s a good time to get with the program, folks! 🙂

*OSXClock requires OSX Yosemite

how to sit down safely

osxclock 1

Well, Tim Cook says sitting is the new cancer…and since I don’t envisage myself in the market for an iWatch, but do need to be reminded to get up and take a break from the desk every 60 minutes, I wrote OSXClock.

I also need a clock for displaying the time on a large screen on occasion when conducting timed-based tests. In the past, I’ve used timeanddate.com for this, but it has a couple of disadvantages: first, you have to be connected to the internet; second, it doesn’t have an alarm or timer.

Hence, OSXClock was born, Applehelpwriter’s answer to the Apple Watch :p, and considerably cheaper! 😀


%d bloggers like this: