Wednesday, November 23, 2011

Eliminate Fast User Switching by Using an Applescript to Toggle Preferences

Alexia was a PC. I'm a Mac. However, when moving into our house after getting married, her PC bit the dust. So, eager to spread the gospel of Apple, I transferred her stuff over to my Macbook Pro.

However, as productive as Hot Corners can be when you are familiar with them (me), they can be equally frustrating to someone who is not familiar with them, nor has any intention of becoming so (Alexia). I like to tap to click sometimes, she doesn't. I have switched over to the natural scrolling of Lion, she is still using the unnatural(?) scrolling of Snow Leopard.

So, to make it work, I set up different profiles. While these allowed us to keep our individualized settings, it also had its drawbacks. Fast user switching is still not fast enough. You have to click on the name, select your name, type your password, and then wait for the cube to rotate to your profile. It was also a pain when restarting, because you were prompted for your password to confirm that the other user's programs would be terminated (also a problem if they had something open they didn't save). I also had a background program that would often crash while switching profiles. Finally, I have yet to figure the best way to share an iTunes library (and iPhoto is even worse). Permissions would always get wonky and the iTunes library file would be locked.

So today I made all that change. I had never Applescripted before, so I relied heavily on piecing code together from here and there. The Frankenstein that I ended up with was exactly what I wanted. I have a quick application called Switch that toggles back between my "preference profile" and my lovely wife's profile simply by switching the individual preferences back and forth. Run it once, and it turns off Hot Corners, tap to click, and natural scrolling, while displaying a Growl notification that Alexia's profile is now activated. Run it again, and you're back to mine.

The Hot Corners are toggled using some code that edits the plist files. I borrowed this code from a script called Lava Corners Switch. The Growl notification code is adapted from the Growl website (which I just noticed the other day is now in the Mac App Store. I declined to buy it because... how much more can Growl be improved? It gives me messages, that's great.). The toggling of the natural scrolling is implemented with UI scripting (so you have to enable access for assistive devices) and comes from commenter fireshadow52 on I added the tap to click toggling. And finally, the method testing to see if an app is running came from CodeSnippets. Then I just grabbed a nice icon from the web and slapped it on there.

To get this running, copy the code into a new Applescript. Save it as an application and throw it on your dock. Set all your settings, and then run the application to toggle all of your Hot Corners off, and switch those other two trackpad settings. Obviously individuals will need to tweak the settings they want changed, and that will take some digging online. If you use it, let me know how it works. And if there is a better way to do any of this, feel free to enlighten me.

As a side note, it amazes me how much some people know out there. I'd like to think of myself as pretty computer savvy, especially compared to those I interact with daily, but my progress to this point can best be described as blindly stumbling for hours. The knowledge of some out there is very impressive. Anyway, I hope this helps. To me, this will be so much better than multiple logins.

-- List of properties for hot corners. Just set your hot corners and it will toggle back and forth between those settings and being disabled
property tl : 1
property tr : 1
property br : 1
property bl : 1
property runs : 0

if appIsRunning("GrowlHelperApp") then
tell application id "com.Growl.GrowlHelperApp"
-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to ¬
{"Switch Notification"}

-- Make a list of the notifications
-- that will be enabled by default.
-- Those not enabled by default can be enabled later
-- in the 'Applications' tab of the Growl preferences.
set the enabledNotificationsList to ¬
{"Switch Notification"}

-- Register our script with growl.
-- You can optionally (as here) set a default icon
-- for this script's notifications.
register as application ¬
"Switch" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application ""

-- Indicate which user or profile is now running
if runs = 1 then
notify with name ¬
"Switch Notification" title ¬
"Profile Activated:" description ¬
"User 1" application name "Switch"

notify with name ¬
"Switch Notification" title ¬
"Profile Activated:" description ¬
"User 2" application name "Switch"
end if

end tell
end if

-- Stores existing hot corners as properties for next toggle
if runs is 0 then
set tl to do shell script "defaults read wvous-tl-corner"
set tr to do shell script "defaults read wvous-tr-corner"
set bl to do shell script "defaults read wvous-bl-corner"
set br to do shell script "defaults read wvous-br-corner"

-- Disables hot corners
do shell script "defaults write wvous-tl-corner -int 1; defaults write wvous-br-corner -int 1; defaults write wvous-bl-corner -int 1; defaults write wvous-tr-corner -int 1; killall Dock"
set runs_A to 1
end if

-- Sets hot corners back to existing values
if runs is 1 then
do shell script ("defaults write wvous-tl-corner -int " & tl & "; defaults write wvous-br-corner -int " & br & "; defaults write wvous-bl-corner -int " & bl & "; defaults write wvous-tr-corner -int " & tr & "; killall Dock")
set runs_A to 0
end if

-- Initializes the trackpad preference pane
tell application "System Preferences"
set current pane to pane ""
end tell

tell application "System Events"
tell process "System Preferences"
-- Toggles between natural scrolling and unnatural(?) scrolling
click radio button "Scroll & Zoom" of tab group 1 of window "Trackpad"
click checkbox 1 of tab group 1 of window "Trackpad"
-- Toggles tap to click on
click radio button "Point & Click" of tab group 1 of window "Trackpad"
click checkbox 1 of tab group 1 of window "Trackpad"
end tell
end tell

quit application "System Preferences"

-- Keeps track of where you are at in the toggle
set runs to runs_A

-- Call to make sure growl is running
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning

Thursday, September 1, 2011

How to re-web your own Chacos

My 5 year old Chacos which I purchased for 40 bucks had seen better days. The soles were peeling off. So I sent them in and got them resoled under the warranty for free. Yipee! It was then that I realized that the webbing was fraying through. I called to see if this was covered under the warranty, but they said it most likely wasn't. They needed to see them first.

Not wanting to spend another $8 to ship them off, certainly not wanting to pay $36 bucks to have them re-webbed, and knowing that my brother had successfully re-webbed his own Chacos, I started my project.

You will need:
  • A torch, or matches, or some heat source to melt the ends of your webbing
  • About 10' 3/4" wide tubular webbing (costed me a little over a quarter a foot)
  • A medium sized needle
  • Strong thread (I had to go to Jo-Ann Fabric and Craft for upholstery thread)
  • A knife
  • Scissors
  • A few hours
Here are pictures of the beginning and the end, and then how I did it.

1. Remove the bar tack stitching that connects the main strap to the inside heel riser (the ones between your feet, not on the outside). I just replaced the main strap as my heel strap and buckle straps were fine, as I assume most are. But those seem replaceable too, you just need to take off the chaco logo.

The bar tack stitch also has a straight stitch underneath. So I took a knife and cut the side to side bar tack stitch, and then pulled the thread out with my leatherman. Be very careful that you don't cut any of the heel riser webbing. Take your time so you are just cutting stitches. After the bar tack is gone, you need to cut the straight line of stitches holding the strap in.

2. Cut the end of the webbing you just removed from the heel riser at an angle and fuse it with a torch. Cut the end of your new webbing complementary and fuse it as well.

3. Thread your needle and sew the two ends together well. You want to butt the ends together, not overlap. Make sure it is very secure. Otherwise the connection may break while it is being threaded through, and then you will need to cut through your sole to finish the repair.

To sew it together, I took 10 inches of thread, and threaded 2 inches through the eye of the needle. Don't tie a knot anywhere in the thread. Just sew 4 or 5 times through the smallest bite of webbing on a corner of one of the pieces. Once you have this anchor, just keep looping over that seam between the pieces. I went from one end to the other, and then back and anchored again like I did at the start. Then snip the pieces. You may want to double this if you aren't sure it is strong enough or if you don't have heavy duty thread (I'd recommend upholstery thread, which is 100% nylon and doesn't fray). Trim any protruding corners that may impede threading this seam through your sole.

4. Now pull, and pull hard. You need to pull your new webbing through the whole webbing pattern. You may need to find the right angle of pull so that the webbing moves and you don't tear your foot bed apart. Check your stitching after each pass so it doesn't fall apart on you.

5. Now that it is all the way through, snip off the old webbing by cutting your new webbing at a right angle right after the seam. Fuse the end. You can now cut the other end of your old webbing and disconnect it from the buckle. Note how it is attached, because you will be replicating that.

6. Sew your new webbing on the buckle like the old webbing was sewn. Again, thread the needle, pass through the same bite (as much as you can, you just want to concentrate your stitching on the smallest possible piece of webbing) several times, and do your best to replicate a bar tack stitch (what was there originally). With all the stitches in this project, I did it twice, with about two passes each. So I would anchor, go from one side to the other and back, anchor again, and trim the thread. Then I repeated the process. That way if one stitch breaks, you have a backup.

7. Now, put the sandal on your foot and adjust all the straps just like you normally would. Mark about where you should cut the other end of your new webbing, and cut it at an angle (it comes out of the heel riser at about a 45 degree angle). Fuse the end.

8. Slide the end into the heal riser, thread your needle, anchor, stitch two passes, anchor, trim. Repeat. You've finished repairing one sandal, now do the other.

9. Enjoy the re-webbing job that cost you under $10

I was pretty pleased with the result. My only complaint is that my new webbing is a little softer and floppier than my original webbing so it takes a bit more effort to put them on. The original webbing is tubular, but it looks like it may be stitched flat. It may stiffen up it time, or perhaps wax or a rosin could help it out.

Let me know if you have any questions.

Tuesday, July 19, 2011

2 Seconds

-- The amount of time it took me to pause at the trashcan and decide that feeding the chickens my leftover chicken was not right. I threw it away.

Monday, July 11, 2011


....and I got a Parrot AR Drone for our anniversary. It is pretty much awesome. Except for the fact that it is a little out of commission while I wait for repair parts:-).


I'd say two posts in one day, but technically my last post was started yesterday. Alexia and I currently have 17 chicks living in our basement bathroom. There are 5 Cuckoo Maran pullets that lay a dark brown egg, 4 Ameraucana pullets that lay blue/green eggs, and 8 Rhode Island Red (we think) roosters that were included in the box to keep the girls warm during the shipping process.

I spent my three week school break working non-stop building a chicken coop. I'll put up some pictures when it is finished. But the end goal is a 5x8 coop to keep 4 hens in for egg laying. The funny thing is we don't eat many eggs, but I guess we will learn to. You can blame this all on my wife to, she's from Portland:-). No, it has been fun. I originally wrote "really" before "fun" but took it away because it has been hard work too. But fun hard work.

Monday, May 23, 2011

What's that smell?

I just walked past someone on their smoke break (in front of the med school, but that is an irony I have gotten over by now) watching a gas leak unfolding in the street about 25 meters away.

I walked away quickly.