Index: unk/appswitch/appswitch/CPS.h
===================================================================
--- /trunk/appswitch/appswitch/CPS.h	(revision 591)
+++ 	(revision )
@@ -1,37 +1,0 @@
-// CPS.h
-
-#pragma once
-
-#include <ApplicationServices/ApplicationServices.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if PRAGMA_STRUCT_ALIGN
-    #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
-    #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
-    #pragma pack(2)
-#endif
-
-
-typedef ProcessSerialNumber CPSProcessSerNum;
-
-extern OSErr	CPSPostHideMostReq( CPSProcessSerNum *psn);
-
-extern OSErr	CPSPostShowAllReq( CPSProcessSerNum *psn);
-
-#if PRAGMA_STRUCT_ALIGN
-    #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
-    #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
-    #pragma pack()
-#endif
-
-#ifdef __cplusplus
-}
-#endif
Index: /trunk/appswitch/appswitch/README
===================================================================
--- /trunk/appswitch/appswitch/README	(revision 591)
+++ /trunk/appswitch/appswitch/README	(revision 592)
@@ -1,4 +1,4 @@
-appswitch 1.1 [6 November 2007]
-=============
+appswitch 1.1.1d1 [unreleased]
+===============
 
 A command-line interface to the Mac OS X process manager.
@@ -72,4 +72,7 @@
 ---------------
 
+1.1.1 - unreleased
+ - use Cocoa instead of CPS to show all/hide other applications
+   (r. 4808397)
 1.1   - 6 November 2007
  - switched to Process Manager instead of CPS where possible - slower
Index: /trunk/appswitch/appswitch/VERSION
===================================================================
--- /trunk/appswitch/appswitch/VERSION	(revision 591)
+++ /trunk/appswitch/appswitch/VERSION	(revision 592)
@@ -1,1 +1,1 @@
-1.1
+1.1.1d1
Index: /trunk/appswitch/appswitch/appswitch.xcodeproj/nicholas.mode2v3
===================================================================
--- /trunk/appswitch/appswitch/appswitch.xcodeproj/nicholas.mode2v3	(revision 591)
+++ /trunk/appswitch/appswitch/appswitch.xcodeproj/nicholas.mode2v3	(revision 592)
@@ -201,7 +201,7 @@
 			<dict>
 				<key>PBXProjectModuleGUID</key>
-				<string>E1529A500CE169F4008A50ED</string>
+				<string>E1E031F310AE06D000C8C3B6</string>
 				<key>PBXProjectModuleLabel</key>
-				<string>appswitch.1 - SCM</string>
+				<string>NSApplication.h</string>
 				<key>PBXSplitModuleInNavigatorKey</key>
 				<dict>
@@ -209,14 +209,14 @@
 					<dict>
 						<key>PBXProjectModuleGUID</key>
-						<string>E1529A510CE169F4008A50ED</string>
+						<string>E1E031F410AE06D000C8C3B6</string>
 						<key>PBXProjectModuleLabel</key>
-						<string>appswitch.1 - SCM</string>
+						<string>NSApplication.h</string>
 						<key>_historyCapacity</key>
 						<integer>0</integer>
 						<key>bookmark</key>
-						<string>E1529A5F0CE16BCF008A50ED</string>
+						<string>E1E0323F10AE0C5500C8C3B6</string>
 						<key>history</key>
 						<array>
-							<string>E1529A520CE169F4008A50ED</string>
+							<string>E1E031F510AE06D000C8C3B6</string>
 						</array>
 					</dict>
@@ -230,9 +230,9 @@
 			<dict>
 				<key>Frame</key>
-				<string>{{0, -1}, {1148, 1004}}</string>
+				<string>{{0, -1}, {687, 606}}</string>
 				<key>PBXModuleWindowStatusBarHidden2</key>
 				<true/>
 				<key>RubberWindowFrame</key>
-				<string>680 58 1148 1024 0 0 1920 1178 </string>
+				<string>15 247 687 626 0 0 1440 878 </string>
 			</dict>
 		</dict>
@@ -241,7 +241,7 @@
 			<dict>
 				<key>PBXProjectModuleGUID</key>
-				<string>E1529A3C0CE167D7008A50ED</string>
+				<string>E1E031F910AE06D000C8C3B6</string>
 				<key>PBXProjectModuleLabel</key>
-				<string>appswitch.1 - SCM</string>
+				<string>README</string>
 				<key>PBXSplitModuleInNavigatorKey</key>
 				<dict>
@@ -249,14 +249,14 @@
 					<dict>
 						<key>PBXProjectModuleGUID</key>
-						<string>E1529A3D0CE167D7008A50ED</string>
+						<string>E1E031FA10AE06D000C8C3B6</string>
 						<key>PBXProjectModuleLabel</key>
-						<string>appswitch.1 - SCM</string>
+						<string>README</string>
 						<key>_historyCapacity</key>
 						<integer>0</integer>
 						<key>bookmark</key>
-						<string>E1529A610CE16BCF008A50ED</string>
+						<string>E1E0324010AE0C5500C8C3B6</string>
 						<key>history</key>
 						<array>
-							<string>E1529A3E0CE167D7008A50ED</string>
+							<string>E1E031FB10AE06D000C8C3B6</string>
 						</array>
 					</dict>
@@ -270,9 +270,9 @@
 			<dict>
 				<key>Frame</key>
-				<string>{{0, -1}, {1148, 1004}}</string>
+				<string>{{0, -1}, {817, 854}}</string>
 				<key>PBXModuleWindowStatusBarHidden2</key>
 				<true/>
 				<key>RubberWindowFrame</key>
-				<string>48 67 1148 1024 0 0 1920 1178 </string>
+				<string>15 4 817 874 0 0 1440 878 </string>
 			</dict>
 		</dict>
@@ -287,6 +287,8 @@
 			<key>ChosenToolbarItems</key>
 			<array>
-				<string>buildOrClean</string>
-				<string>build-and-goOrGo</string>
+				<string>active-combo-popup</string>
+				<string>debugger-enable-breakpoints</string>
+				<string>build-and-go</string>
+				<string>clean</string>
 				<string>com.apple.ide.PBXToolbarStopButton</string>
 				<string>NSToolbarFlexibleSpaceItem</string>
@@ -309,4 +311,6 @@
 					<array>
 						<dict>
+							<key>BecomeActive</key>
+							<true/>
 							<key>ContentConfiguration</key>
 							<dict>
@@ -352,6 +356,4 @@
 									<array>
 										<array>
-											<integer>5</integer>
-											<integer>4</integer>
 											<integer>0</integer>
 										</array>
@@ -384,4 +386,6 @@
 									<real>27</real>
 								</array>
+								<key>RubberWindowFrame</key>
+								<string>1084 456 350 420 0 0 1440 878 </string>
 							</dict>
 							<key>Module</key>
@@ -389,6 +393,4 @@
 						</dict>
 						<dict>
-							<key>BecomeActive</key>
-							<true/>
 							<key>ContentConfiguration</key>
 							<dict>
@@ -420,5 +422,6 @@
 									<array>
 										<string>1C37FBAC04509CD000000102</string>
-										<string>E1529A4E0CE169F4008A50ED</string>
+										<string>E1E031D610AE028500C8C3B6</string>
+										<string>E1E031E310AE02AD00C8C3B6</string>
 										<string>1C37FAAC04509CD000000102</string>
 									</array>
@@ -426,4 +429,6 @@
 									<array>
 										<array>
+											<integer>3</integer>
+											<integer>2</integer>
 											<integer>1</integer>
 											<integer>0</integer>
@@ -447,6 +452,4 @@
 									<real>333</real>
 								</array>
-								<key>RubberWindowFrame</key>
-								<string>1562 755 350 420 0 0 1920 1178 </string>
 							</dict>
 							<key>Module</key>
@@ -458,5 +461,4 @@
 								<key>PBXBottomSmartGroupGIDs</key>
 								<array>
-									<string>1C08E77C0454961000C914BD</string>
 									<string>1C37FABC05509CD000000102</string>
 									<string>1C37FABC05539CD112110102</string>
@@ -529,10 +531,12 @@
 			<key>TableOfContents</key>
 			<array>
-				<string>E1529A160CE15D2F008A50ED</string>
-				<string>E1529A170CE15D2F008A50ED</string>
+				<string>E1E031DD10AE028700C8C3B6</string>
+				<string>E1E031DE10AE028700C8C3B6</string>
 				<string>1C9437FD063B20B00039CFAC</string>
 				<string>1C9437FE063B20B00039CFAC</string>
 				<string>1C9437FF063B20B00039CFAC</string>
 			</array>
+			<key>ToolbarConfigUserDefaultsMinorVersion</key>
+			<string>2</string>
 			<key>ToolbarConfiguration</key>
 			<string>xcode.toolbar.config.default.shortV3</string>
@@ -561,13 +565,15 @@
 	<key>WindowOrderList</key>
 	<array>
+		<string>E1E0322610AE0ACD00C8C3B6</string>
+		<string>1C530D57069F1CE1000CFCEE</string>
+		<string>1C335F2C07B51CD20023D4EE</string>
 		<string>1C530D52069F1CE1000CFCEE</string>
-		<string>E1AC50050CE14E3800EAF6A0</string>
-		<string>E1529A3C0CE167D7008A50ED</string>
 		<string>E14A28260CDF20F700A5BD78</string>
-		<string>E1529A500CE169F4008A50ED</string>
-		<string>/Volumes/nicholas/Documents/Development/appswitch/appswitch/appswitch.xcodeproj</string>
+		<string>E1E031F910AE06D000C8C3B6</string>
+		<string>E1E031F310AE06D000C8C3B6</string>
+		<string>/Users/nicholas/Documents/Development/appswitch/appswitch/appswitch.xcodeproj</string>
 	</array>
 	<key>WindowString</key>
-	<string>1562 755 350 420 0 0 1920 1178 </string>
+	<string>1084 456 350 420 0 0 1440 878 </string>
 	<key>WindowToolsV3</key>
 	<array>
@@ -585,6 +591,4 @@
 					<array>
 						<dict>
-							<key>BecomeActive</key>
-							<integer>1</integer>
 							<key>ContentConfiguration</key>
 							<dict>
@@ -593,5 +597,4 @@
 									<string>1C37FBAC04509CD000000102</string>
 									<string>1C37FAAC04509CD000000102</string>
-									<string>1C08E77C0454961000C914BD</string>
 									<string>1C37FABC05509CD000000102</string>
 									<string>1C37FABC05539CD112110102</string>
@@ -622,5 +625,5 @@
 									<key>PBXSmartGroupTreeModuleOutlineStateExpansionKey</key>
 									<array>
-										<string>00C654E9FEEE28EC7F000001</string>
+										<string>08FB7794FE84155DC02AAC07</string>
 										<string>1C37FABC05509CD000000102</string>
 									</array>
@@ -637,5 +640,5 @@
 								<array/>
 								<key>XCIncludePerspectivesSwitch</key>
-								<integer>0</integer>
+								<false/>
 							</dict>
 							<key>GeometryConfiguration</key>
@@ -678,5 +681,5 @@
 					</array>
 					<key>Proportion</key>
-					<string>100%</string>
+					<string>368pt</string>
 				</dict>
 			</array>
@@ -693,6 +696,5 @@
 			<array>
 				<string>1C335F2C07B51CD20023D4EE</string>
-				<string>1C335F2D07B51CD20023D4EE</string>
-				<string>1C335F2E07B51CD20023D4EE</string>
+				<string>E1E0320610AE082000C8C3B6</string>
 				<string>1CE0B1FE06471DED0097A5F4</string>
 				<string>1CA1AED706398EBD00589147</string>
@@ -705,5 +707,5 @@
 			<string>1C335F2C07B51CD20023D4EE</string>
 			<key>WindowToolIsVisible</key>
-			<true/>
+			<false/>
 		</dict>
 		<dict>
@@ -731,5 +733,5 @@
 								<string>1CD0528F0623707200166675</string>
 								<key>PBXProjectModuleLabel</key>
-								<string></string>
+								<string>&lt;No Editor&gt;</string>
 								<key>StatusBarVisibility</key>
 								<true/>
@@ -738,12 +740,12 @@
 							<dict>
 								<key>Frame</key>
-								<string>{{0, 0}, {878, 604}}</string>
+								<string>{{0, 0}, {878, 572}}</string>
 								<key>RubberWindowFrame</key>
-								<string>415 151 878 886 0 0 1920 1178 </string>
+								<string>224 36 878 842 0 0 1440 878 </string>
 							</dict>
 							<key>Module</key>
 							<string>PBXNavigatorGroup</string>
 							<key>Proportion</key>
-							<string>604pt</string>
+							<string>572pt</string>
 						</dict>
 						<dict>
@@ -755,5 +757,5 @@
 								<string>XCMainBuildResultsModuleGUID</string>
 								<key>PBXProjectModuleLabel</key>
-								<string>Build</string>
+								<string>Build Results</string>
 								<key>XCBuildResultsTrigger_Collapse</key>
 								<integer>1021</integer>
@@ -764,16 +766,16 @@
 							<dict>
 								<key>Frame</key>
-								<string>{{0, 609}, {878, 236}}</string>
+								<string>{{0, 577}, {878, 224}}</string>
 								<key>RubberWindowFrame</key>
-								<string>415 151 878 886 0 0 1920 1178 </string>
+								<string>224 36 878 842 0 0 1440 878 </string>
 							</dict>
 							<key>Module</key>
 							<string>PBXBuildResultsModule</string>
 							<key>Proportion</key>
-							<string>236pt</string>
+							<string>224pt</string>
 						</dict>
 					</array>
 					<key>Proportion</key>
-					<string>845pt</string>
+					<string>801pt</string>
 				</dict>
 			</array>
@@ -789,5 +791,5 @@
 			<array>
 				<string>1C530D52069F1CE1000CFCEE</string>
-				<string>E1529A140CE15BB4008A50ED</string>
+				<string>E1E031DF10AE028700C8C3B6</string>
 				<string>1CD0528F0623707200166675</string>
 				<string>XCMainBuildResultsModuleGUID</string>
@@ -796,5 +798,5 @@
 			<string>xcode.toolbar.config.buildV3</string>
 			<key>WindowString</key>
-			<string>415 151 878 886 0 0 1920 1178 </string>
+			<string>224 36 878 842 0 0 1440 878 </string>
 			<key>WindowToolGUID</key>
 			<string>1C530D52069F1CE1000CFCEE</string>
@@ -931,4 +933,6 @@
 			<key>Identifier</key>
 			<string>windowTool.find</string>
+			<key>IsVertical</key>
+			<true/>
 			<key>Layout</key>
 			<array>
@@ -954,5 +958,5 @@
 										<string>{{0, 0}, {781, 212}}</string>
 										<key>RubberWindowFrame</key>
-										<string>22 496 781 470 0 0 1280 1002 </string>
+										<string>29 380 781 470 0 0 1440 878 </string>
 									</dict>
 									<key>Module</key>
@@ -980,5 +984,5 @@
 								<string>{{0, 217}, {781, 212}}</string>
 								<key>RubberWindowFrame</key>
-								<string>22 496 781 470 0 0 1280 1002 </string>
+								<string>29 380 781 470 0 0 1440 878 </string>
 							</dict>
 							<key>Module</key>
@@ -1003,13 +1007,11 @@
 			<array>
 				<string>1C530D57069F1CE1000CFCEE</string>
-				<string>1C530D58069F1CE1000CFCEE</string>
-				<string>1C530D59069F1CE1000CFCEE</string>
+				<string>E1E0320810AE082100C8C3B6</string>
+				<string>E1E0320910AE082100C8C3B6</string>
 				<string>1CDD528C0622207200134675</string>
-				<string>1C530D5A069F1CE1000CFCEE</string>
-				<string>1CE0B1FE06471DED0097A5F4</string>
 				<string>1CD0528E0623707200166675</string>
 			</array>
 			<key>WindowString</key>
-			<string>22 496 781 470 0 0 1280 1002 </string>
+			<string>29 380 781 470 0 0 1440 878 </string>
 			<key>WindowToolGUID</key>
 			<string>1C530D57069F1CE1000CFCEE</string>
@@ -1144,5 +1146,5 @@
 								<string>{{0, 0}, {636, 0}}</string>
 								<key>RubberWindowFrame</key>
-								<string>1097 407 636 499 0 0 1920 1178 </string>
+								<string>687 227 636 499 0 0 1440 878 </string>
 							</dict>
 							<key>Module</key>
@@ -1163,9 +1165,9 @@
 									<array>
 										<real>200</real>
-										<real>56</real>
+										<real>56.66162109375</real>
 										<real>63</real>
 										<real>60</real>
 										<real>63</real>
-										<real>355</real>
+										<real>139.556640625</real>
 									</array>
 									<key>PBXCVSModuleTreeModuleColumnsKey</key>
@@ -1189,5 +1191,5 @@
 								<string>{{0, 5}, {636, 453}}</string>
 								<key>RubberWindowFrame</key>
-								<string>1097 407 636 499 0 0 1920 1178 </string>
+								<string>687 227 636 499 0 0 1440 878 </string>
 							</dict>
 							<key>Module</key>
@@ -1212,5 +1214,5 @@
 			<array>
 				<string>E14A28260CDF20F700A5BD78</string>
-				<string>E1529A410CE167D7008A50ED</string>
+				<string>E1E031E010AE028700C8C3B6</string>
 				<string>1C78EAB2065D492600B07095</string>
 				<string>1CD052920623707200166675</string>
@@ -1219,9 +1221,9 @@
 			<string>xcode.toolbar.config.scm</string>
 			<key>WindowString</key>
-			<string>1097 407 636 499 0 0 1920 1178 </string>
+			<string>687 227 636 499 0 0 1440 878 </string>
 			<key>WindowToolGUID</key>
 			<string>E14A28260CDF20F700A5BD78</string>
 			<key>WindowToolIsVisible</key>
-			<true/>
+			<false/>
 		</dict>
 		<dict>
Index: /trunk/appswitch/appswitch/appswitch.xcodeproj/nicholas.pbxuser
===================================================================
--- /trunk/appswitch/appswitch/appswitch.xcodeproj/nicholas.pbxuser	(revision 591)
+++ /trunk/appswitch/appswitch/appswitch.xcodeproj/nicholas.pbxuser	(revision 592)
@@ -2,5 +2,4 @@
 {
 	08FB7793FE84155DC02AAC07 /* Project object */ = {
-		activeArchitecture = i386;
 		activeBuildConfigurationName = Deployment;
 		activeExecutable = E1607F090AF3700B001EAB72 /* appswitch */;
@@ -32,5 +31,5 @@
 				PBXFileTableDataSourceColumnWidthsKey = (
 					20,
-					230,
+					225,
 					20,
 					61,
@@ -49,5 +48,5 @@
 				);
 			};
-			PBXPerProjectTemplateStateSaveDate = 216095544;
+			PBXPerProjectTemplateStateSaveDate = 279839365;
 			PBXPrepackagedSmartGroups_v2 = (
 				{
@@ -470,11 +469,53 @@
 				RubberWindowFrame = "46 125 753 707 0 0 1280 832 ";
 			};
-			PBXWorkspaceStateSaveDate = 216095544;
+			PBXWorkspaceStateSaveDate = 279839365;
 		};
 		perUserProjectItems = {
-			E1529A3E0CE167D7008A50ED /* XCDiffFileBookmark */ = E1529A3E0CE167D7008A50ED /* XCDiffFileBookmark */;
-			E1529A520CE169F4008A50ED /* XCDiffFileBookmark */ = E1529A520CE169F4008A50ED /* XCDiffFileBookmark */;
-			E1529A5F0CE16BCF008A50ED /* PBXBookmark */ = E1529A5F0CE16BCF008A50ED /* PBXBookmark */;
-			E1529A610CE16BCF008A50ED /* PBXBookmark */ = E1529A610CE16BCF008A50ED /* PBXBookmark */;
+			E1529A3E0CE167D7008A50ED = E1529A3E0CE167D7008A50ED /* XCDiffFileBookmark */;
+			E1529A520CE169F4008A50ED = E1529A520CE169F4008A50ED /* XCDiffFileBookmark */;
+			E1529A5F0CE16BCF008A50ED = E1529A5F0CE16BCF008A50ED /* PBXBookmark */;
+			E1529A610CE16BCF008A50ED = E1529A610CE16BCF008A50ED /* PBXBookmark */;
+			E1E031E610AE02AD00C8C3B6 /* PBXBookmark */ = E1E031E610AE02AD00C8C3B6 /* PBXBookmark */;
+			E1E031E710AE02AD00C8C3B6 /* PBXTextBookmark */ = E1E031E710AE02AD00C8C3B6 /* PBXTextBookmark */;
+			E1E031EC10AE02CB00C8C3B6 /* PBXTextBookmark */ = E1E031EC10AE02CB00C8C3B6 /* PBXTextBookmark */;
+			E1E031F110AE06D000C8C3B6 /* PBXTextBookmark */ = E1E031F110AE06D000C8C3B6 /* PBXTextBookmark */;
+			E1E031F210AE06D000C8C3B6 /* PBXTextBookmark */ = E1E031F210AE06D000C8C3B6 /* PBXTextBookmark */;
+			E1E031F510AE06D000C8C3B6 /* PBXTextBookmark */ = E1E031F510AE06D000C8C3B6 /* PBXTextBookmark */;
+			E1E031F710AE06D000C8C3B6 /* PBXTextBookmark */ = E1E031F710AE06D000C8C3B6 /* PBXTextBookmark */;
+			E1E031FB10AE06D000C8C3B6 /* PBXBookmark */ = E1E031FB10AE06D000C8C3B6 /* PBXBookmark */;
+			E1E031FC10AE06D000C8C3B6 /* PBXTextBookmark */ = E1E031FC10AE06D000C8C3B6 /* PBXTextBookmark */;
+			E1E031FD10AE078D00C8C3B6 /* PBXTextBookmark */ = E1E031FD10AE078D00C8C3B6 /* PBXTextBookmark */;
+			E1E031FE10AE078D00C8C3B6 /* PBXTextBookmark */ = E1E031FE10AE078D00C8C3B6 /* PBXTextBookmark */;
+			E1E031FF10AE078D00C8C3B6 /* PBXTextBookmark */ = E1E031FF10AE078D00C8C3B6 /* PBXTextBookmark */;
+			E1E0320A10AE085500C8C3B6 /* PBXTextBookmark */ = E1E0320A10AE085500C8C3B6 /* PBXTextBookmark */;
+			E1E0320B10AE085500C8C3B6 /* PBXTextBookmark */ = E1E0320B10AE085500C8C3B6 /* PBXTextBookmark */;
+			E1E0320C10AE085500C8C3B6 /* PBXTextBookmark */ = E1E0320C10AE085500C8C3B6 /* PBXTextBookmark */;
+			E1E0320D10AE089100C8C3B6 /* PBXTextBookmark */ = E1E0320D10AE089100C8C3B6 /* PBXTextBookmark */;
+			E1E0320E10AE089100C8C3B6 /* PBXTextBookmark */ = E1E0320E10AE089100C8C3B6 /* PBXTextBookmark */;
+			E1E0320F10AE089100C8C3B6 /* PBXTextBookmark */ = E1E0320F10AE089100C8C3B6 /* PBXTextBookmark */;
+			E1E0321310AE0A5100C8C3B6 /* PBXTextBookmark */ = E1E0321310AE0A5100C8C3B6 /* PBXTextBookmark */;
+			E1E0321410AE0A5100C8C3B6 /* PBXTextBookmark */ = E1E0321410AE0A5100C8C3B6 /* PBXTextBookmark */;
+			E1E0321610AE0A6800C8C3B6 /* XCBuildMessageTextBookmark */ = E1E0321610AE0A6800C8C3B6 /* XCBuildMessageTextBookmark */;
+			E1E0321710AE0A6800C8C3B6 /* PBXTextBookmark */ = E1E0321710AE0A6800C8C3B6 /* PBXTextBookmark */;
+			E1E0321810AE0A6900C8C3B6 /* PBXTextBookmark */ = E1E0321810AE0A6900C8C3B6 /* PBXTextBookmark */;
+			E1E0321910AE0A6900C8C3B6 /* PBXTextBookmark */ = E1E0321910AE0A6900C8C3B6 /* PBXTextBookmark */;
+			E1E0322310AE0A8E00C8C3B6 /* PBXBookmark */ = E1E0322310AE0A8E00C8C3B6 /* PBXBookmark */;
+			E1E0322810AE0ACD00C8C3B6 /* PBXTextBookmark */ = E1E0322810AE0ACD00C8C3B6 /* PBXTextBookmark */;
+			E1E0322910AE0ACD00C8C3B6 /* PBXTextBookmark */ = E1E0322910AE0ACD00C8C3B6 /* PBXTextBookmark */;
+			E1E0322A10AE0ACD00C8C3B6 /* PBXTextBookmark */ = E1E0322A10AE0ACD00C8C3B6 /* PBXTextBookmark */;
+			E1E0322D10AE0AE400C8C3B6 /* PBXTextBookmark */ = E1E0322D10AE0AE400C8C3B6 /* PBXTextBookmark */;
+			E1E0322E10AE0AE400C8C3B6 /* PBXTextBookmark */ = E1E0322E10AE0AE400C8C3B6 /* PBXTextBookmark */;
+			E1E0322F10AE0AE400C8C3B6 /* PBXTextBookmark */ = E1E0322F10AE0AE400C8C3B6 /* PBXTextBookmark */;
+			E1E0323410AE0C0700C8C3B6 /* PBXTextBookmark */ = E1E0323410AE0C0700C8C3B6 /* PBXTextBookmark */;
+			E1E0323510AE0C0700C8C3B6 /* PBXTextBookmark */ = E1E0323510AE0C0700C8C3B6 /* PBXTextBookmark */;
+			E1E0323610AE0C0700C8C3B6 /* PBXTextBookmark */ = E1E0323610AE0C0700C8C3B6 /* PBXTextBookmark */;
+			E1E0323710AE0C2000C8C3B6 /* PBXTextBookmark */ = E1E0323710AE0C2000C8C3B6 /* PBXTextBookmark */;
+			E1E0323810AE0C2000C8C3B6 /* PBXTextBookmark */ = E1E0323810AE0C2000C8C3B6 /* PBXTextBookmark */;
+			E1E0323910AE0C2000C8C3B6 /* PBXTextBookmark */ = E1E0323910AE0C2000C8C3B6 /* PBXTextBookmark */;
+			E1E0323C10AE0C4F00C8C3B6 /* PBXTextBookmark */ = E1E0323C10AE0C4F00C8C3B6 /* PBXTextBookmark */;
+			E1E0323D10AE0C4F00C8C3B6 /* PBXTextBookmark */ = E1E0323D10AE0C4F00C8C3B6 /* PBXTextBookmark */;
+			E1E0323E10AE0C4F00C8C3B6 /* PBXTextBookmark */ = E1E0323E10AE0C4F00C8C3B6 /* PBXTextBookmark */;
+			E1E0323F10AE0C5500C8C3B6 /* PBXTextBookmark */ = E1E0323F10AE0C5500C8C3B6 /* PBXTextBookmark */;
+			E1E0324010AE0C5500C8C3B6 /* PBXTextBookmark */ = E1E0324010AE0C5500C8C3B6 /* PBXTextBookmark */;
 		};
 		sourceControlManager = E18A0A29063362FF008DC67C /* Source Control */;
@@ -482,11 +523,11 @@
 		};
 	};
-	08FB7796FE84155DC02AAC07 /* main.c */ = {
+	08FB7796FE84155DC02AAC07 /* main.m */ = {
 		uiCtxt = {
-			sepNavIntBoundsRect = "{{0, 0}, {758, 5654}}";
-			sepNavSelRange = "{1771, 0}";
-			sepNavVisRange = "{0, 3036}";
+			sepNavIntBoundsRect = "{{0, 0}, {756, 6408}}";
+			sepNavSelRange = "{19955, 7}";
+			sepNavVisRange = "{18355, 2857}";
 			sepNavVisRect = "{{0, 853}, {837, 587}}";
-			sepNavWindowFrame = "{{787, 212}, {817, 930}}";
+			sepNavWindowFrame = "{{246, 4}, {817, 874}}";
 		};
 	};
@@ -514,4 +555,5 @@
 	E1529A600CE16BCF008A50ED /* appswitch.1 - SCM */ = {
 		isa = PBXFileReference;
+		lastKnownFileType = file;
 		path = "appswitch.1 - SCM";
 		sourceTree = "<group>";
@@ -523,4 +565,5 @@
 	E1529A620CE16BCF008A50ED /* appswitch.1 - SCM */ = {
 		isa = PBXFileReference;
+		lastKnownFileType = file;
 		path = "appswitch.1 - SCM";
 		sourceTree = "<group>";
@@ -560,4 +603,7 @@
 		};
 		customDataFormattersEnabled = 1;
+		dataTipCustomDataFormattersEnabled = 1;
+		dataTipShowTypeColumn = 1;
+		dataTipSortType = 0;
 		debuggerPlugin = GDBDebugging;
 		disassemblyDisplayState = 0;
@@ -572,4 +618,5 @@
 		savedGlobals = {
 		};
+		showTypeColumn = 0;
 		sourceDirectories = (
 		);
@@ -579,9 +626,9 @@
 	E16C83CC03F7AF7B00050002 /* README */ = {
 		uiCtxt = {
-			sepNavIntBoundsRect = "{{0, 0}, {758, 1144}}";
-			sepNavSelRange = "{3620, 0}";
-			sepNavVisRange = "{791, 2829}";
+			sepNavIntBoundsRect = "{{0, 0}, {756, 1284}}";
+			sepNavSelRange = "{3708, 0}";
+			sepNavVisRange = "{1073, 2497}";
 			sepNavVisRect = "{{0, 0}, {778, 872}}";
-			sepNavWindowFrame = "{{15, 67}, {817, 930}}";
+			sepNavWindowFrame = "{{15, 4}, {817, 874}}";
 		};
 	};
@@ -593,4 +640,7 @@
 			SubversionToolPath = /opt/local/bin/svn;
 			repositoryName = dev.sabi.net;
+			repositoryNamesForRoots = {
+				"" = dev.sabi.net;
+			};
 		};
 		scmType = scm.subversion;
@@ -600,12 +650,420 @@
 		indexTemplatePath = "";
 	};
-	E1A0BD3203EFAD9E00050001 /* CPS.h */ = {
+	E1E031E610AE02AD00C8C3B6 /* PBXBookmark */ = {
+		isa = PBXBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+	};
+	E1E031E710AE02AD00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 28";
+		rLen = 0;
+		rLoc = 1784;
+		rType = 0;
+		vrLen = 2966;
+		vrLoc = 5116;
+	};
+	E1E031EC10AE02CB00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 28";
+		rLen = 0;
+		rLoc = 1784;
+		rType = 0;
+		vrLen = 2551;
+		vrLoc = 0;
+	};
+	E1E031F110AE06D000C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 474";
+		rLen = 0;
+		rLoc = 20550;
+		rType = 0;
+		vrLen = 2727;
+		vrLoc = 18193;
+	};
+	E1E031F210AE06D000C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 470";
+		rLen = 0;
+		rLoc = 19963;
+		rType = 0;
+		vrLen = 2764;
+		vrLoc = 18217;
+	};
+	E1E031F510AE06D000C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F610AE06D000C8C3B6 /* NSApplication.h */;
+		rLen = 0;
+		rLoc = 9223372036854775807;
+		rType = 0;
+	};
+	E1E031F610AE06D000C8C3B6 /* NSApplication.h */ = {
+		isa = PBXFileReference;
+		lastKnownFileType = sourcecode.c.h;
+		name = NSApplication.h;
+		path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSApplication.h;
+		sourceTree = "<absolute>";
+	};
+	E1E031F710AE06D000C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 31";
+		rLen = 0;
+		rLoc = 951;
+		rType = 0;
+		vrLen = 1667;
+		vrLoc = 0;
+	};
+	E1E031F810AE06D000C8C3B6 /* NSApplication.h */ = {
+		isa = PBXFileReference;
+		lastKnownFileType = sourcecode.c.h;
+		name = NSApplication.h;
+		path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSApplication.h;
+		sourceTree = "<absolute>";
 		uiCtxt = {
-			sepNavIntBoundsRect = "{{0, 0}, {877, 869}}";
-			sepNavSelRange = "{446, 0}";
-			sepNavVisRange = "{0, 634}";
-			sepNavVisRect = "{{0, 2937}, {662, 498}}";
-			sepNavWindowFrame = "{{33, 87}, {936, 905}}";
+			sepNavIntBoundsRect = "{{0, 0}, {626, 6564}}";
+			sepNavSelRange = "{5914, 21}";
+			sepNavVisRange = "{5184, 1560}";
 		};
 	};
+	E1E031FB10AE06D000C8C3B6 /* PBXBookmark */ = {
+		isa = PBXBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+	};
+	E1E031FC10AE06D000C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 75";
+		rLen = 0;
+		rLoc = 2472;
+		rType = 0;
+		vrLen = 2410;
+		vrLoc = 1240;
+	};
+	E1E031FD10AE078D00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 468";
+		rLen = 0;
+		rLoc = 19836;
+		rType = 0;
+		vrLen = 2811;
+		vrLoc = 18219;
+	};
+	E1E031FE10AE078D00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 38";
+		rLen = 25;
+		rLoc = 1212;
+		rType = 0;
+		vrLen = 1667;
+		vrLoc = 0;
+	};
+	E1E031FF10AE078D00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 75";
+		rLen = 0;
+		rLoc = 2472;
+		rType = 0;
+		vrLen = 2410;
+		vrLoc = 1240;
+	};
+	E1E0320A10AE085500C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 475";
+		rLen = 0;
+		rLoc = 20115;
+		rType = 0;
+		vrLen = 2803;
+		vrLoc = 18288;
+	};
+	E1E0320B10AE085500C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 154";
+		rLen = 21;
+		rLoc = 5914;
+		rType = 0;
+		vrLen = 1560;
+		vrLoc = 5184;
+	};
+	E1E0320C10AE085500C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 69";
+		rLen = 0;
+		rLoc = 2397;
+		rType = 0;
+		vrLen = 2410;
+		vrLoc = 1240;
+	};
+	E1E0320D10AE089100C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 472";
+		rLen = 0;
+		rLoc = 19896;
+		rType = 0;
+		vrLen = 2803;
+		vrLoc = 18288;
+	};
+	E1E0320E10AE089100C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 154";
+		rLen = 21;
+		rLoc = 5914;
+		rType = 0;
+		vrLen = 1560;
+		vrLoc = 5184;
+	};
+	E1E0320F10AE089100C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 69";
+		rLen = 0;
+		rLoc = 2397;
+		rType = 0;
+		vrLen = 2410;
+		vrLoc = 1240;
+	};
+	E1E0321310AE0A5100C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 154";
+		rLen = 21;
+		rLoc = 5914;
+		rType = 0;
+		vrLen = 1560;
+		vrLoc = 5184;
+	};
+	E1E0321410AE0A5100C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 69";
+		rLen = 0;
+		rLoc = 2397;
+		rType = 0;
+		vrLen = 2410;
+		vrLoc = 1240;
+	};
+	E1E0321610AE0A6800C8C3B6 /* XCBuildMessageTextBookmark */ = {
+		isa = PBXTextBookmark;
+		comments = "CPS.h: No such file or directory";
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		fallbackIsa = XCBuildMessageTextBookmark;
+		rLen = 1;
+		rLoc = 23;
+		rType = 1;
+	};
+	E1E0321710AE0A6800C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 14";
+		rLen = 0;
+		rLoc = 1292;
+		rType = 0;
+		vrLen = 1729;
+		vrLoc = 745;
+	};
+	E1E0321810AE0A6900C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 154";
+		rLen = 21;
+		rLoc = 5914;
+		rType = 0;
+		vrLen = 1560;
+		vrLoc = 5184;
+	};
+	E1E0321910AE0A6900C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 69";
+		rLen = 0;
+		rLoc = 2397;
+		rType = 0;
+		vrLen = 2410;
+		vrLoc = 1240;
+	};
+	E1E0322310AE0A8E00C8C3B6 /* PBXBookmark */ = {
+		isa = PBXBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+	};
+	E1E0322810AE0ACD00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 479";
+		rLen = 0;
+		rLoc = 20269;
+		rType = 0;
+		vrLen = 2865;
+		vrLoc = 18351;
+	};
+	E1E0322910AE0ACD00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 154";
+		rLen = 21;
+		rLoc = 5914;
+		rType = 0;
+		vrLen = 1560;
+		vrLoc = 5184;
+	};
+	E1E0322A10AE0ACD00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 69";
+		rLen = 0;
+		rLoc = 2397;
+		rType = 0;
+		vrLen = 2410;
+		vrLoc = 1240;
+	};
+	E1E0322D10AE0AE400C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 477";
+		rLen = 0;
+		rLoc = 20269;
+		rType = 0;
+		vrLen = 2857;
+		vrLoc = 18351;
+	};
+	E1E0322E10AE0AE400C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 154";
+		rLen = 21;
+		rLoc = 5914;
+		rType = 0;
+		vrLen = 1560;
+		vrLoc = 5184;
+	};
+	E1E0322F10AE0AE400C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 69";
+		rLen = 0;
+		rLoc = 2397;
+		rType = 0;
+		vrLen = 2410;
+		vrLoc = 1240;
+	};
+	E1E0323410AE0C0700C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 28";
+		rLen = 0;
+		rLoc = 1784;
+		rType = 0;
+		vrLen = 2564;
+		vrLoc = 0;
+	};
+	E1E0323510AE0C0700C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 154";
+		rLen = 21;
+		rLoc = 5914;
+		rType = 0;
+		vrLen = 1560;
+		vrLoc = 5184;
+	};
+	E1E0323610AE0C0700C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 106";
+		rLen = 0;
+		rLoc = 3666;
+		rType = 0;
+		vrLen = 2463;
+		vrLoc = 1184;
+	};
+	E1E0323710AE0C2000C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 468";
+		rLen = 7;
+		rLoc = 19955;
+		rType = 0;
+		vrLen = 2857;
+		vrLoc = 18355;
+	};
+	E1E0323810AE0C2000C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 154";
+		rLen = 21;
+		rLoc = 5914;
+		rType = 0;
+		vrLen = 1560;
+		vrLoc = 5184;
+	};
+	E1E0323910AE0C2000C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 106";
+		rLen = 0;
+		rLoc = 3674;
+		rType = 0;
+		vrLen = 2496;
+		vrLoc = 1135;
+	};
+	E1E0323C10AE0C4F00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 08FB7796FE84155DC02AAC07 /* main.m */;
+		name = "main.m: 468";
+		rLen = 7;
+		rLoc = 19955;
+		rType = 0;
+		vrLen = 2857;
+		vrLoc = 18355;
+	};
+	E1E0323D10AE0C4F00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 154";
+		rLen = 21;
+		rLoc = 5914;
+		rType = 0;
+		vrLen = 1560;
+		vrLoc = 5184;
+	};
+	E1E0323E10AE0C4F00C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 107";
+		rLen = 0;
+		rLoc = 3708;
+		rType = 0;
+		vrLen = 2497;
+		vrLoc = 1073;
+	};
+	E1E0323F10AE0C5500C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E1E031F810AE06D000C8C3B6 /* NSApplication.h */;
+		name = "NSApplication.h: 154";
+		rLen = 21;
+		rLoc = 5914;
+		rType = 0;
+		vrLen = 1560;
+		vrLoc = 5184;
+	};
+	E1E0324010AE0C5500C8C3B6 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = E16C83CC03F7AF7B00050002 /* README */;
+		name = "README: 107";
+		rLen = 0;
+		rLoc = 3708;
+		rType = 0;
+		vrLen = 2497;
+		vrLoc = 1073;
+	};
 }
Index: /trunk/appswitch/appswitch/appswitch.xcodeproj/project.pbxproj
===================================================================
--- /trunk/appswitch/appswitch/appswitch.xcodeproj/project.pbxproj	(revision 591)
+++ /trunk/appswitch/appswitch/appswitch.xcodeproj/project.pbxproj	(revision 592)
@@ -8,15 +8,16 @@
 
 /* Begin PBXBuildFile section */
-		E1607EFD0AF3700B001EAB72 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.c */; settings = {ATTRIBUTES = (); }; };
+		E1607EFD0AF3700B001EAB72 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.m */; settings = {ATTRIBUTES = (); }; };
 		E1607EFF0AF3700B001EAB72 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1A0BD4C03EFB64400050001 /* ApplicationServices.framework */; };
+		E1E0321E10AE0A7D00C8C3B6 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1E0321D10AE0A7D00C8C3B6 /* AppKit.framework */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
-		08FB7796FE84155DC02AAC07 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+		08FB7796FE84155DC02AAC07 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		C6859E970290921104C91782 /* appswitch.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = appswitch.1; sourceTree = "<group>"; };
 		E1607F080AF3700B001EAB72 /* appswitch */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = appswitch; sourceTree = BUILT_PRODUCTS_DIR; };
 		E16C83CC03F7AF7B00050002 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		E1A0BD3203EFAD9E00050001 /* CPS.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CPS.h; sourceTree = "<group>"; };
 		E1A0BD4C03EFB64400050001 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
+		E1E0321D10AE0A7D00C8C3B6 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
 /* End PBXFileReference section */
 
@@ -27,4 +28,5 @@
 			files = (
 				E1607EFF0AF3700B001EAB72 /* ApplicationServices.framework in Frameworks */,
+				E1E0321E10AE0A7D00C8C3B6 /* AppKit.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -47,6 +49,5 @@
 			isa = PBXGroup;
 			children = (
-				08FB7796FE84155DC02AAC07 /* main.c */,
-				E1A0BD3203EFAD9E00050001 /* CPS.h */,
+				08FB7796FE84155DC02AAC07 /* main.m */,
 			);
 			name = Source;
@@ -57,4 +58,5 @@
 			children = (
 				E1A0BD4C03EFB64400050001 /* ApplicationServices.framework */,
+				E1E0321D10AE0A7D00C8C3B6 /* AppKit.framework */,
 			);
 			name = "External Frameworks and Libraries";
@@ -120,5 +122,5 @@
 			buildActionMask = 2147483647;
 			files = (
-				E1607EFD0AF3700B001EAB72 /* main.c in Sources */,
+				E1607EFD0AF3700B001EAB72 /* main.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -130,4 +132,5 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				GCC_VERSION = 4.0;
 				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
 			};
@@ -141,4 +144,5 @@
 					i386,
 				);
+				GCC_VERSION = 4.0;
 				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
 			};
Index: unk/appswitch/appswitch/main.c
===================================================================
--- /trunk/appswitch/appswitch/main.c	(revision 591)
+++ 	(revision )
@@ -1,493 +1,0 @@
-/*
- appswitch - a command-line application switcher
- Nicholas Riley <appswitch@sabi.net>
-
- Copyright (c) 2003-07, Nicholas Riley
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- * Neither the name of this software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*/
-
-#define DEBUG 0
-
-#include <unistd.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include "CPS.h"
-
-const char *APP_NAME;
-
-#define VERSION "1.1"
-
-struct {
-    CFStringRef creator;
-    CFStringRef bundleID;
-    CFStringRef name;
-    pid_t pid;
-    CFStringRef path;
-    enum {
-        MATCH_UNKNOWN, MATCH_FRONT, MATCH_CREATOR, MATCH_BUNDLE_ID, MATCH_NAME, MATCH_PID, MATCH_PATH, MATCH_ALL
-    } matchType;
-    enum {
-        APP_NONE, APP_SWITCH, APP_SHOW, APP_HIDE, APP_QUIT, APP_KILL, APP_KILL_HARD, APP_LIST, APP_PRINT_PID, APP_FRONTMOST
-    } appAction;
-    Boolean longList;
-    enum {
-        ACTION_NONE, ACTION_SHOW_ALL, ACTION_HIDE_OTHERS
-    } action;
-    enum {
-        FINAL_NONE, FINAL_SWITCH
-    } finalAction;
-} OPTS =
-{
-    kLSUnknownCreator, NULL, NULL, -1, NULL, MATCH_UNKNOWN, APP_NONE, ACTION_NONE, FINAL_NONE, false
-};
-
-typedef struct {
-    OSStatus status;
-    const char *desc;
-} errRec, errList[];
-
-static errList ERRS = {
-    // Process Manager errors
-    { appIsDaemon, "application is background-only", },
-    { procNotFound, "application not found" },
-    { connectionInvalid, "application is not background-only", },
-    // CoreGraphics errors
-    { kCGErrorIllegalArgument, "window server error.\nAre you logged in?" },
-    { kCGErrorInvalidContext, "application context unavailable" },
-    { fnfErr, "file not found" },
-    // (abused) errors
-    { permErr, "no permission" },
-    { 0, NULL }
-};
-
-void usage() {
-    fprintf(stderr, "usage: %s [-sShHqkKlLPfF] [-c creator] [-i bundleID] [-a name] [-p pid] [path]\n"
-            "  -s            show application, bring windows to front (do not switch)\n"
-            "  -S            show all applications\n"
-            "  -h            hide application\n"
-            "  -H            hide other applications\n"
-            "  -q            quit application\n"
-            "  -k            kill application (SIGTERM)\n"
-            "  -K            kill application hard (SIGKILL)\n"
-            "  -l            list applications\n"
-            "  -L            list applications including full paths and bundle identifiers\n"
-            "  -P            print application process ID\n"
-            "  -f            bring application's frontmost window to front\n"
-            "  -F            bring current application's windows to front\n"
-            "  -c creator    match application by four-character creator code ('ToyS')\n"
-            "  -i bundle ID  match application by bundle identifier (com.apple.ScriptEditor2)\n"
-            "  -p pid        match application by process identifier\n"
-            "  -a name       match application by name\n"
-            , APP_NAME);
-    fprintf(stderr, "appswitch "VERSION" (c) 2003-07 Nicholas Riley <http://web.sabi.net/nriley/software/>.\n"
-            "Please send bugs, suggestions, etc. to <appswitch@sabi.net>.\n");
-
-    exit(1);
-}
-
-char *osstatusstr(OSStatus err) {
-    errRec *rec;
-    const char *errDesc = "unknown error";
-    char * const failedStr = "(unable to retrieve error message)";
-    static char *str = NULL;
-    size_t len;
-    if (str != NULL && str != failedStr) free(str);
-    for (rec = &(ERRS[0]) ; rec->status != 0 ; rec++)
-        if (rec->status == err) {
-            errDesc = rec->desc;
-            break;
-        }
-    len = strlen(errDesc) + 10 * sizeof(char);
-    str = (char *)malloc(len);
-    if (str != NULL)
-        snprintf(str, len, "%s (%ld)", errDesc, err);
-    else
-        str = failedStr;
-    return str;
-}
-
-void osstatusexit(OSStatus err, const char *fmt, ...) {
-    va_list ap;
-    const char *errDesc = osstatusstr(err);
-    va_start(ap, fmt);
-    fprintf(stderr, "%s: ", APP_NAME);
-    vfprintf(stderr, fmt, ap);
-    fprintf(stderr, ": %s\n", errDesc);
-    exit(1);
-}
-
-void errexit(const char *fmt, ...) {
-    va_list ap;
-    va_start(ap, fmt);
-    fprintf(stderr, "%s: ", APP_NAME);
-    vfprintf(stderr, fmt, ap);
-    fprintf(stderr, "\n");
-    exit(1);
-}
-
-void getargs(int argc, char * const argv[]) {
-    extern char *optarg;
-    extern int optind;
-    int ch;
-
-    if (argc == 1) usage();
-
-    const char *opts = "c:i:p:a:sShHqkKlLPfF";
-
-    while ( (ch = getopt(argc, argv, opts)) != -1) {
-        switch (ch) {
-            case 'p':
-                if (OPTS.matchType != MATCH_UNKNOWN) errexit("choose only one of -c, -i, -p, -a options");
-                if (sscanf(optarg, "%d", &OPTS.pid) != 1 || OPTS.pid < 0)
-                    errexit("invalid process identifier (argument of -p)");
-                OPTS.matchType = MATCH_PID;
-                break;
-            case 'c':
-                if (OPTS.matchType != MATCH_UNKNOWN) errexit("choose only one of -c, -i, -p, -a options");
-                OPTS.creator = CFStringCreateWithFileSystemRepresentation(NULL, optarg);
-                if (OPTS.creator == NULL) errexit("invalid creator (wrong text encoding?)");
-                if (CFStringGetLength(OPTS.creator) != 4) errexit("creator (argument of -c) must be four characters long");
-                OPTS.matchType = MATCH_CREATOR;
-                break;
-            case 'i':
-                if (OPTS.matchType != MATCH_UNKNOWN) errexit("choose only one of -c, -i, -p, -a options");
-                OPTS.bundleID = CFStringCreateWithFileSystemRepresentation(NULL, optarg);
-                if (OPTS.bundleID == NULL) errexit("invalid bundle ID (wrong text encoding?)");
-                OPTS.matchType = MATCH_BUNDLE_ID;
-                break;
-            case 'a':
-                if (OPTS.matchType != MATCH_UNKNOWN) errexit("choose only one of -c, -i, -p, -a options");
-                OPTS.name = CFStringCreateWithFileSystemRepresentation(NULL, optarg);
-                if (OPTS.name == NULL) errexit("invalid application name (wrong text encoding?)");
-                OPTS.matchType = MATCH_NAME;
-                break;
-            case 's':
-                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
-                OPTS.appAction = APP_SHOW;
-                break;
-            case 'h':
-                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
-                OPTS.appAction = APP_HIDE;
-                break;
-            case 'q':
-                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
-                OPTS.appAction = APP_QUIT;
-                break;
-            case 'k':
-                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
-                OPTS.appAction = APP_KILL;
-                break;
-            case 'K':
-                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
-                OPTS.appAction = APP_KILL_HARD;
-                break;
-            case 'l':
-                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
-                OPTS.appAction = APP_LIST;
-                break;
-            case 'L':
-                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
-                OPTS.appAction = APP_LIST;
-                OPTS.longList = true;
-                break;
-            case 'P':
-                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
-                OPTS.appAction = APP_PRINT_PID;
-                break;
-            case 'f':
-                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
-                OPTS.appAction = APP_FRONTMOST;
-                break;
-            case 'S':
-                if (OPTS.action != ACTION_NONE) errexit("choose -S, -H or neither option");
-                OPTS.action = ACTION_SHOW_ALL;
-                break;
-            case 'H':
-                if (OPTS.action != ACTION_NONE) errexit("choose -S, -H or neither option");
-                OPTS.action = ACTION_HIDE_OTHERS;
-                break;
-            case 'F':
-                if (OPTS.finalAction != FINAL_NONE) errexit("choose only one -F option");
-                OPTS.finalAction = FINAL_SWITCH;
-                break;
-            default: usage();
-        }
-    }
-
-    argc -= optind;
-    argv += optind;
-
-    if (OPTS.matchType != MATCH_UNKNOWN && argc != 0) usage();
-
-    if (OPTS.matchType == MATCH_UNKNOWN) {
-        if (argc == 0) {
-            if (OPTS.appAction == APP_LIST) {
-                OPTS.matchType = MATCH_ALL;
-            } else if (OPTS.action != ACTION_NONE || OPTS.finalAction != FINAL_NONE) {
-                OPTS.matchType = MATCH_FRONT;
-            } else usage();
-        } else if (argc == 1) {
-            OPTS.path = CFStringCreateWithFileSystemRepresentation(NULL, argv[0]);
-            if (OPTS.path == NULL) errexit("invalid path (wrong text encoding?)");
-            OPTS.matchType = MATCH_PATH;
-        } else usage();
-    }
-
-    if (OPTS.matchType != MATCH_FRONT && OPTS.appAction == APP_NONE)
-        OPTS.appAction = APP_SWITCH;
-
-}
-
-ProcessSerialNumber frontApplication() {
-    ProcessSerialNumber psn;
-    OSStatus err = GetFrontProcess(&psn);
-    if (err != noErr) osstatusexit(err, "can't get frontmost process");
-#if DEBUG
-    fprintf(stderr, "front application PSN %ld.%ld\n", psn.lowLongOfPSN, psn.highLongOfPSN);
-#endif
-    return psn;
-}
-
-OSStatus quitApplication(ProcessSerialNumber *psn) {
-    AppleEvent event;
-    AEAddressDesc appDesc;
-    OSStatus err;
-
-    AEInitializeDesc(&appDesc);
-    err = AECreateDesc(typeProcessSerialNumber, psn, sizeof(*psn), &appDesc);
-    if (err != noErr) return err;
-
-    err = AECreateAppleEvent(kCoreEventClass, kAEQuitApplication, &appDesc, kAutoGenerateReturnID, kAnyTransactionID, &event);
-    if (err != noErr) return err;
-
-    AppleEvent nullReply = {typeNull, nil};
-    err = AESendMessage(&event, &nullReply, kAENoReply, kNoTimeOut);
-    (void)AEDisposeDesc(&event);
-    if (err != noErr) return err;
-
-    (void)AEDisposeDesc(&nullReply); // according to docs, don't call unless AESend returned successfully
-
-    return noErr;
-}
-
-pid_t getPID(const ProcessSerialNumber *psn) {
-    pid_t pid;
-    OSStatus err = GetProcessPID(psn, &pid);
-    if (err != noErr) osstatusexit(err, "can't get process ID");
-    return pid;
-}
-
-bool infoStringMatches(CFDictionaryRef info, CFStringRef key, CFStringRef matchStr) {
-    CFStringRef str = CFDictionaryGetValue(info, key);
-    if (str == NULL)
-        return false;
-    /* note: this means we might match names/paths that are wrong, but works better in the common case */
-    return CFStringCompare(str, matchStr, kCFCompareCaseInsensitive) == kCFCompareEqualTo;
-}
-
-CFStringRef stringTrimmedToWidth(CFStringRef str, CFIndex width) {
-    if (str == NULL)
-        str = CFSTR("");
-    CFIndex length = CFStringGetLength(str);
-    if (length == width)
-        return CFRetain(str);
-    
-    CFMutableStringRef padStr = CFStringCreateMutableCopy(NULL, width, str);
-    CFStringPad(padStr, CFSTR(" "), width, 0);
-    return padStr;
-}
-
-ProcessSerialNumber matchApplication(void) {
-    if (OPTS.matchType == MATCH_FRONT) return frontApplication();
-
-    OSStatus err;
-    ProcessSerialNumber psn = {
-        kNoProcess, kNoProcess
-    };
-    pid_t pid;
-    CFStringRef format = NULL;
-    CFIndex nameWidth = 19;
-    CFIndex pathWidth = 0;
-    if (OPTS.appAction == APP_LIST) {
-        int termwidth = 80;
-        struct winsize ws;
-        char *banner = "        PSN   PID TYPE CREA NAME               ";
-                     // 123456789.0 12345 1234 1234 1234567890123456789
-        if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) != -1 ||
-             ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) != -1 ||
-             ioctl(STDIN_FILENO,  TIOCGWINSZ, (char *)&ws) != -1) ||
-            ws.ws_col != 0) termwidth = ws.ws_col;
-        char *formatButPath = "%9ld.%ld %5ld %@ %@ %@";
-        // XXX don't ever release 'format', should fix if we get called repeatedly
-        if (OPTS.longList) {
-            pathWidth = 1;
-            printf("%s PATH (bundle identifier)\n", banner);
-            format = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %%@"), formatButPath);
-        } else {
-            pathWidth = termwidth - strlen(banner) - 1;
-            if (pathWidth >= 4) {
-                printf("%s PATH\n", banner);
-                format = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %%@"), formatButPath);
-            } else {
-                pathWidth = 0;
-                format = CFStringCreateWithCString(NULL, formatButPath, kCFStringEncodingUTF8);
-            }
-        }
-    }
-    
-    CFDictionaryRef info = NULL;
-    while ( (err = GetNextProcess(&psn)) == noErr) {
-        if (info != NULL) CFRelease(info);
-        info = ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask);
-        if (info == NULL) errexit("can't get information for process with PSN %ld.%ld",
-                                  psn.lowLongOfPSN, psn.highLongOfPSN);
-
-        switch (OPTS.matchType) {
-            case MATCH_ALL:
-                break;
-            case MATCH_CREATOR: if (!infoStringMatches(info, CFSTR("FileCreator"), OPTS.creator)) continue;
-                break;
-            case MATCH_NAME: if (!infoStringMatches(info, CFSTR("CFBundleName"), OPTS.name)) continue;
-                break;
-            case MATCH_PID: err = GetProcessPID(&psn, &pid); if (err != noErr || OPTS.pid != pid) continue;
-                break;
-            case MATCH_PATH: if (!infoStringMatches(info, CFSTR("BundlePath"), OPTS.path) &&
-                !infoStringMatches(info, CFSTR("CFBundleExecutable"), OPTS.path)) continue;
-                break;
-            case MATCH_BUNDLE_ID: if (!infoStringMatches(info, CFSTR("CFBundleIdentifier"), OPTS.bundleID)) continue;
-                break;
-            default:
-                errexit("internal error: invalid match type");
-        }
-        if (OPTS.appAction == APP_LIST) {
-            if (GetProcessPID(&psn, &pid) != noErr)
-                pid = -1;
-            CFStringRef path = NULL;
-            // XXX padding/truncation probably breaks with double-width characters
-            if (pathWidth) {
-                path = CFDictionaryGetValue(info, CFSTR("BundlePath"));
-                if (path == NULL)
-                    path = CFDictionaryGetValue(info, CFSTR("CFBundleExecutable"));
-                if (!OPTS.longList)
-                    path = stringTrimmedToWidth(path, pathWidth);
-            }
-            CFStringRef name = stringTrimmedToWidth(CFDictionaryGetValue(info, CFSTR("CFBundleName")), nameWidth);
-            CFStringRef type = stringTrimmedToWidth(CFDictionaryGetValue(info, CFSTR("FileType")), 4);
-            CFStringRef creator = stringTrimmedToWidth(CFDictionaryGetValue(info, CFSTR("FileCreator")), 4);
-            CFStringRef line = CFStringCreateWithFormat(NULL, NULL, format,
-                psn.lowLongOfPSN, psn.highLongOfPSN, pid, type, creator, name, path);
-            CFRelease(name);
-            CFRelease(type);
-            CFRelease(creator);
-            if (!OPTS.longList)
-                CFRelease(path);
-            else {
-                CFStringRef bundleID = CFDictionaryGetValue(info, CFSTR("CFBundleIdentifier"));
-                if (bundleID != NULL && CFStringGetLength(bundleID) != 0) {
-                    CFStringRef origLine = line;
-                    line = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)"), line, bundleID);
-                    CFRelease(origLine);
-                }
-            }
-            char *cStr = (char *)CFStringGetCStringPtr(line, CFStringGetSystemEncoding());
-            if (cStr != NULL) {
-                puts(cStr);
-            } else {
-                CFIndex cStrLength = CFStringGetMaximumSizeOfFileSystemRepresentation(line);
-                cStr = (char *)malloc(cStrLength * sizeof(char));
-                if (!CFStringGetFileSystemRepresentation(line, cStr, cStrLength)) {
-                    CFShow(cStr);
-                    errexit("internal error: string encoding conversion failed");
-                }
-                puts(cStr);
-                free(cStr);
-            }
-            continue;
-        }
-        return psn;
-    }
-    if (err != procNotFound) osstatusexit(err, "can't get next process");
-
-    if (OPTS.appAction == APP_LIST) return frontApplication();
-
-    errexit("can't find matching process");
-    return psn; // not reached
-}
-
-int main(int argc, char * const argv[]) {
-    OSStatus err = noErr;
-
-    APP_NAME = argv[0];
-    getargs(argc, argv);
-
-    ProcessSerialNumber psn;
-    
-    // required in Leopard to prevent paramErr - rdar://problem/5579375
-    err = GetCurrentProcess(&psn);
-    if (err != noErr) osstatusexit(err, "can't contact window server");
-    
-    psn = matchApplication();
-
-    const char *verb = NULL;
-    switch (OPTS.appAction) {
-        case APP_NONE: break;
-        case APP_LIST: break; // already handled in matchApplication
-        case APP_SWITCH: err = SetFrontProcess(&psn); verb = "set front"; break;
-        case APP_SHOW: err = ShowHideProcess(&psn, true); verb = "show"; break;
-        case APP_HIDE: err = ShowHideProcess(&psn, false); verb = "hide"; break;
-        case APP_QUIT: err = quitApplication(&psn); verb = "quit"; break;
-        case APP_KILL: err = KillProcess(&psn); verb = "send SIGTERM to"; break;
-        case APP_KILL_HARD:
-        {
-            // no Process Manager equivalent - rdar://problem/4808400
-            if (kill(getPID(&psn), SIGKILL) == -1)
-                err = (errno == ESRCH) ? procNotFound : (errno == EPERM ? permErr : paramErr);
-            verb = "send SIGKILL to";
-            break;
-        }
-        case APP_PRINT_PID: printf("%d\n", getPID(&psn)); break;
-        case APP_FRONTMOST: err = SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
-            verb = "bring frontmost window to front"; break;
-        default:
-            errexit("internal error: invalid application action");
-    }
-    if (err != noErr) osstatusexit(err, "can't %s process", verb);
-
-    switch (OPTS.action) {
-        case ACTION_NONE: break;
-        // no Process Manager equivalents - rdar://problem/4808397
-        case ACTION_SHOW_ALL: err = CPSPostShowAllReq(&psn); verb = "show all"; break;
-        case ACTION_HIDE_OTHERS: err = CPSPostHideMostReq(&psn); verb = "hide other"; break;
-        default:
-            errexit("internal error: invalid action");
-    }
-    if (err != noErr) osstatusexit(err, "can't %s processes", verb);
-
-    switch (OPTS.finalAction) {
-        case FINAL_NONE: break;
-        case FINAL_SWITCH:
-            psn = frontApplication();
-#if DEBUG
-            fprintf(stderr, "posting show request for %ld.%ld\n", psn.lowLongOfPSN, psn.highLongOfPSN);
-#endif
-            if (OPTS.action != ACTION_NONE) usleep(750000); // XXX
-            err = ShowHideProcess(&psn, true) || SetFrontProcess(&psn);
-            verb = "bring current application's windows to the front";
-            break;
-        default:
-            errexit("internal error: invalid final action");    
-    }
-    if (err != noErr) osstatusexit(err, "can't %s", verb);
-
-    exit(0);
-}
Index: /trunk/appswitch/appswitch/main.m
===================================================================
--- /trunk/appswitch/appswitch/main.m	(revision 592)
+++ /trunk/appswitch/appswitch/main.m	(revision 592)
@@ -0,0 +1,503 @@
+/*
+ appswitch - a command-line application switcher
+ Nicholas Riley <appswitch@sabi.net>
+
+ Copyright (c) 2003-09, Nicholas Riley
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * Neither the name of this software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+#define DEBUG 0
+
+#include <unistd.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+#include <ApplicationServices/ApplicationServices.h>
+#import <AppKit/AppKit.h>
+
+const char *APP_NAME;
+
+#define VERSION "1.1.1d1"
+
+struct {
+    CFStringRef creator;
+    CFStringRef bundleID;
+    CFStringRef name;
+    pid_t pid;
+    CFStringRef path;
+    enum {
+        MATCH_UNKNOWN, MATCH_FRONT, MATCH_CREATOR, MATCH_BUNDLE_ID, MATCH_NAME, MATCH_PID, MATCH_PATH, MATCH_ALL
+    } matchType;
+    enum {
+        APP_NONE, APP_SWITCH, APP_SHOW, APP_HIDE, APP_QUIT, APP_KILL, APP_KILL_HARD, APP_LIST, APP_PRINT_PID, APP_FRONTMOST
+    } appAction;
+    Boolean longList;
+    enum {
+        ACTION_NONE, ACTION_SHOW_ALL, ACTION_HIDE_OTHERS
+    } action;
+    enum {
+        FINAL_NONE, FINAL_SWITCH
+    } finalAction;
+} OPTS =
+{
+    kLSUnknownCreator, NULL, NULL, -1, NULL, MATCH_UNKNOWN, APP_NONE, ACTION_NONE, FINAL_NONE, false
+};
+
+typedef struct {
+    OSStatus status;
+    const char *desc;
+} errRec, errList[];
+
+static errList ERRS = {
+    // Process Manager errors
+    { appIsDaemon, "application is background-only", },
+    { procNotFound, "application not found" },
+    { connectionInvalid, "application is not background-only", },
+    // CoreGraphics errors
+    { kCGErrorIllegalArgument, "window server error.\nAre you logged in?" },
+    { kCGErrorInvalidContext, "application context unavailable" },
+    { fnfErr, "file not found" },
+    // (abused) errors
+    { permErr, "no permission" },
+    { 0, NULL }
+};
+
+void usage() {
+    fprintf(stderr, "usage: %s [-sShHqkKlLPfF] [-c creator] [-i bundleID] [-a name] [-p pid] [path]\n"
+            "  -s            show application, bring windows to front (do not switch)\n"
+            "  -S            show all applications\n"
+            "  -h            hide application\n"
+            "  -H            hide other applications\n"
+            "  -q            quit application\n"
+            "  -k            kill application (SIGTERM)\n"
+            "  -K            kill application hard (SIGKILL)\n"
+            "  -l            list applications\n"
+            "  -L            list applications including full paths and bundle identifiers\n"
+            "  -P            print application process ID\n"
+            "  -f            bring application's frontmost window to front\n"
+            "  -F            bring current application's windows to front\n"
+            "  -c creator    match application by four-character creator code ('ToyS')\n"
+            "  -i bundle ID  match application by bundle identifier (com.apple.ScriptEditor2)\n"
+            "  -p pid        match application by process identifier\n"
+            "  -a name       match application by name\n"
+            , APP_NAME);
+    fprintf(stderr, "appswitch "VERSION" (c) 2003-07 Nicholas Riley <http://web.sabi.net/nriley/software/>.\n"
+            "Please send bugs, suggestions, etc. to <appswitch@sabi.net>.\n");
+
+    exit(1);
+}
+
+char *osstatusstr(OSStatus err) {
+    errRec *rec;
+    const char *errDesc = "unknown error";
+    char * const failedStr = "(unable to retrieve error message)";
+    static char *str = NULL;
+    size_t len;
+    if (str != NULL && str != failedStr) free(str);
+    for (rec = &(ERRS[0]) ; rec->status != 0 ; rec++)
+        if (rec->status == err) {
+            errDesc = rec->desc;
+            break;
+        }
+    len = strlen(errDesc) + 10 * sizeof(char);
+    str = (char *)malloc(len);
+    if (str != NULL)
+        snprintf(str, len, "%s (%ld)", errDesc, err);
+    else
+        str = failedStr;
+    return str;
+}
+
+void osstatusexit(OSStatus err, const char *fmt, ...) {
+    va_list ap;
+    const char *errDesc = osstatusstr(err);
+    va_start(ap, fmt);
+    fprintf(stderr, "%s: ", APP_NAME);
+    vfprintf(stderr, fmt, ap);
+    fprintf(stderr, ": %s\n", errDesc);
+    exit(1);
+}
+
+void errexit(const char *fmt, ...) {
+    va_list ap;
+    va_start(ap, fmt);
+    fprintf(stderr, "%s: ", APP_NAME);
+    vfprintf(stderr, fmt, ap);
+    fprintf(stderr, "\n");
+    exit(1);
+}
+
+void getargs(int argc, char * const argv[]) {
+    extern char *optarg;
+    extern int optind;
+    int ch;
+
+    if (argc == 1) usage();
+
+    const char *opts = "c:i:p:a:sShHqkKlLPfF";
+
+    while ( (ch = getopt(argc, argv, opts)) != -1) {
+        switch (ch) {
+            case 'p':
+                if (OPTS.matchType != MATCH_UNKNOWN) errexit("choose only one of -c, -i, -p, -a options");
+                if (sscanf(optarg, "%d", &OPTS.pid) != 1 || OPTS.pid < 0)
+                    errexit("invalid process identifier (argument of -p)");
+                OPTS.matchType = MATCH_PID;
+                break;
+            case 'c':
+                if (OPTS.matchType != MATCH_UNKNOWN) errexit("choose only one of -c, -i, -p, -a options");
+                OPTS.creator = CFStringCreateWithFileSystemRepresentation(NULL, optarg);
+                if (OPTS.creator == NULL) errexit("invalid creator (wrong text encoding?)");
+                if (CFStringGetLength(OPTS.creator) != 4) errexit("creator (argument of -c) must be four characters long");
+                OPTS.matchType = MATCH_CREATOR;
+                break;
+            case 'i':
+                if (OPTS.matchType != MATCH_UNKNOWN) errexit("choose only one of -c, -i, -p, -a options");
+                OPTS.bundleID = CFStringCreateWithFileSystemRepresentation(NULL, optarg);
+                if (OPTS.bundleID == NULL) errexit("invalid bundle ID (wrong text encoding?)");
+                OPTS.matchType = MATCH_BUNDLE_ID;
+                break;
+            case 'a':
+                if (OPTS.matchType != MATCH_UNKNOWN) errexit("choose only one of -c, -i, -p, -a options");
+                OPTS.name = CFStringCreateWithFileSystemRepresentation(NULL, optarg);
+                if (OPTS.name == NULL) errexit("invalid application name (wrong text encoding?)");
+                OPTS.matchType = MATCH_NAME;
+                break;
+            case 's':
+                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
+                OPTS.appAction = APP_SHOW;
+                break;
+            case 'h':
+                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
+                OPTS.appAction = APP_HIDE;
+                break;
+            case 'q':
+                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
+                OPTS.appAction = APP_QUIT;
+                break;
+            case 'k':
+                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
+                OPTS.appAction = APP_KILL;
+                break;
+            case 'K':
+                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
+                OPTS.appAction = APP_KILL_HARD;
+                break;
+            case 'l':
+                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
+                OPTS.appAction = APP_LIST;
+                break;
+            case 'L':
+                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
+                OPTS.appAction = APP_LIST;
+                OPTS.longList = true;
+                break;
+            case 'P':
+                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
+                OPTS.appAction = APP_PRINT_PID;
+                break;
+            case 'f':
+                if (OPTS.appAction != APP_NONE) errexit("choose only one of -s, -h, -q, -k, -K, -l, -L, -P, -f options");
+                OPTS.appAction = APP_FRONTMOST;
+                break;
+            case 'S':
+                if (OPTS.action != ACTION_NONE) errexit("choose -S, -H or neither option");
+                OPTS.action = ACTION_SHOW_ALL;
+                break;
+            case 'H':
+                if (OPTS.action != ACTION_NONE) errexit("choose -S, -H or neither option");
+                OPTS.action = ACTION_HIDE_OTHERS;
+                break;
+            case 'F':
+                if (OPTS.finalAction != FINAL_NONE) errexit("choose only one -F option");
+                OPTS.finalAction = FINAL_SWITCH;
+                break;
+            default: usage();
+        }
+    }
+
+    argc -= optind;
+    argv += optind;
+
+    if (OPTS.matchType != MATCH_UNKNOWN && argc != 0) usage();
+
+    if (OPTS.matchType == MATCH_UNKNOWN) {
+        if (argc == 0) {
+            if (OPTS.appAction == APP_LIST) {
+                OPTS.matchType = MATCH_ALL;
+            } else if (OPTS.action != ACTION_NONE || OPTS.finalAction != FINAL_NONE) {
+                OPTS.matchType = MATCH_FRONT;
+            } else usage();
+        } else if (argc == 1) {
+            OPTS.path = CFStringCreateWithFileSystemRepresentation(NULL, argv[0]);
+            if (OPTS.path == NULL) errexit("invalid path (wrong text encoding?)");
+            OPTS.matchType = MATCH_PATH;
+        } else usage();
+    }
+
+    if (OPTS.matchType != MATCH_FRONT && OPTS.appAction == APP_NONE)
+        OPTS.appAction = APP_SWITCH;
+
+}
+
+ProcessSerialNumber frontApplication() {
+    ProcessSerialNumber psn;
+    OSStatus err = GetFrontProcess(&psn);
+    if (err != noErr) osstatusexit(err, "can't get frontmost process");
+#if DEBUG
+    fprintf(stderr, "front application PSN %ld.%ld\n", psn.lowLongOfPSN, psn.highLongOfPSN);
+#endif
+    return psn;
+}
+
+OSStatus quitApplication(ProcessSerialNumber *psn) {
+    AppleEvent event;
+    AEAddressDesc appDesc;
+    OSStatus err;
+
+    AEInitializeDesc(&appDesc);
+    err = AECreateDesc(typeProcessSerialNumber, psn, sizeof(*psn), &appDesc);
+    if (err != noErr) return err;
+
+    err = AECreateAppleEvent(kCoreEventClass, kAEQuitApplication, &appDesc, kAutoGenerateReturnID, kAnyTransactionID, &event);
+    if (err != noErr) return err;
+
+    AppleEvent nullReply = {typeNull, nil};
+    err = AESendMessage(&event, &nullReply, kAENoReply, kNoTimeOut);
+    (void)AEDisposeDesc(&event);
+    if (err != noErr) return err;
+
+    (void)AEDisposeDesc(&nullReply); // according to docs, don't call unless AESend returned successfully
+
+    return noErr;
+}
+
+pid_t getPID(const ProcessSerialNumber *psn) {
+    pid_t pid;
+    OSStatus err = GetProcessPID(psn, &pid);
+    if (err != noErr) osstatusexit(err, "can't get process ID");
+    return pid;
+}
+
+bool infoStringMatches(CFDictionaryRef info, CFStringRef key, CFStringRef matchStr) {
+    CFStringRef str = CFDictionaryGetValue(info, key);
+    if (str == NULL)
+        return false;
+    /* note: this means we might match names/paths that are wrong, but works better in the common case */
+    return CFStringCompare(str, matchStr, kCFCompareCaseInsensitive) == kCFCompareEqualTo;
+}
+
+CFStringRef stringTrimmedToWidth(CFStringRef str, CFIndex width) {
+    if (str == NULL)
+        str = CFSTR("");
+    CFIndex length = CFStringGetLength(str);
+    if (length == width)
+        return CFRetain(str);
+    
+    CFMutableStringRef padStr = CFStringCreateMutableCopy(NULL, width, str);
+    CFStringPad(padStr, CFSTR(" "), width, 0);
+    return padStr;
+}
+
+ProcessSerialNumber matchApplication(void) {
+    if (OPTS.matchType == MATCH_FRONT) return frontApplication();
+
+    OSStatus err;
+    ProcessSerialNumber psn = {
+        kNoProcess, kNoProcess
+    };
+    pid_t pid;
+    CFStringRef format = NULL;
+    CFIndex nameWidth = 19;
+    CFIndex pathWidth = 0;
+    if (OPTS.appAction == APP_LIST) {
+        int termwidth = 80;
+        struct winsize ws;
+        char *banner = "        PSN   PID TYPE CREA NAME               ";
+                     // 123456789.0 12345 1234 1234 1234567890123456789
+        if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) != -1 ||
+             ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) != -1 ||
+             ioctl(STDIN_FILENO,  TIOCGWINSZ, (char *)&ws) != -1) ||
+            ws.ws_col != 0) termwidth = ws.ws_col;
+        char *formatButPath = "%9ld.%ld %5ld %@ %@ %@";
+        // XXX don't ever release 'format', should fix if we get called repeatedly
+        if (OPTS.longList) {
+            pathWidth = 1;
+            printf("%s PATH (bundle identifier)\n", banner);
+            format = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %%@"), formatButPath);
+        } else {
+            pathWidth = termwidth - strlen(banner) - 1;
+            if (pathWidth >= 4) {
+                printf("%s PATH\n", banner);
+                format = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %%@"), formatButPath);
+            } else {
+                pathWidth = 0;
+                format = CFStringCreateWithCString(NULL, formatButPath, kCFStringEncodingUTF8);
+            }
+        }
+    }
+    
+    CFDictionaryRef info = NULL;
+    while ( (err = GetNextProcess(&psn)) == noErr) {
+        if (info != NULL) CFRelease(info);
+        info = ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask);
+        if (info == NULL) errexit("can't get information for process with PSN %ld.%ld",
+                                  psn.lowLongOfPSN, psn.highLongOfPSN);
+
+        switch (OPTS.matchType) {
+            case MATCH_ALL:
+                break;
+            case MATCH_CREATOR: if (!infoStringMatches(info, CFSTR("FileCreator"), OPTS.creator)) continue;
+                break;
+            case MATCH_NAME: if (!infoStringMatches(info, CFSTR("CFBundleName"), OPTS.name)) continue;
+                break;
+            case MATCH_PID: err = GetProcessPID(&psn, &pid); if (err != noErr || OPTS.pid != pid) continue;
+                break;
+            case MATCH_PATH: if (!infoStringMatches(info, CFSTR("BundlePath"), OPTS.path) &&
+                !infoStringMatches(info, CFSTR("CFBundleExecutable"), OPTS.path)) continue;
+                break;
+            case MATCH_BUNDLE_ID: if (!infoStringMatches(info, CFSTR("CFBundleIdentifier"), OPTS.bundleID)) continue;
+                break;
+            default:
+                errexit("internal error: invalid match type");
+        }
+        if (OPTS.appAction == APP_LIST) {
+            if (GetProcessPID(&psn, &pid) != noErr)
+                pid = -1;
+            CFStringRef path = NULL;
+            // XXX padding/truncation probably breaks with double-width characters
+            if (pathWidth) {
+                path = CFDictionaryGetValue(info, CFSTR("BundlePath"));
+                if (path == NULL)
+                    path = CFDictionaryGetValue(info, CFSTR("CFBundleExecutable"));
+                if (!OPTS.longList)
+                    path = stringTrimmedToWidth(path, pathWidth);
+            }
+            CFStringRef name = stringTrimmedToWidth(CFDictionaryGetValue(info, CFSTR("CFBundleName")), nameWidth);
+            CFStringRef type = stringTrimmedToWidth(CFDictionaryGetValue(info, CFSTR("FileType")), 4);
+            CFStringRef creator = stringTrimmedToWidth(CFDictionaryGetValue(info, CFSTR("FileCreator")), 4);
+            CFStringRef line = CFStringCreateWithFormat(NULL, NULL, format,
+                psn.lowLongOfPSN, psn.highLongOfPSN, pid, type, creator, name, path);
+            CFRelease(name);
+            CFRelease(type);
+            CFRelease(creator);
+            if (!OPTS.longList)
+                CFRelease(path);
+            else {
+                CFStringRef bundleID = CFDictionaryGetValue(info, CFSTR("CFBundleIdentifier"));
+                if (bundleID != NULL && CFStringGetLength(bundleID) != 0) {
+                    CFStringRef origLine = line;
+                    line = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)"), line, bundleID);
+                    CFRelease(origLine);
+                }
+            }
+            char *cStr = (char *)CFStringGetCStringPtr(line, CFStringGetSystemEncoding());
+            if (cStr != NULL) {
+                puts(cStr);
+            } else {
+                CFIndex cStrLength = CFStringGetMaximumSizeOfFileSystemRepresentation(line);
+                cStr = (char *)malloc(cStrLength * sizeof(char));
+                if (!CFStringGetFileSystemRepresentation(line, cStr, cStrLength)) {
+                    CFShow(cStr);
+                    errexit("internal error: string encoding conversion failed");
+                }
+                puts(cStr);
+                free(cStr);
+            }
+            continue;
+        }
+        return psn;
+    }
+    if (err != procNotFound) osstatusexit(err, "can't get next process");
+
+    if (OPTS.appAction == APP_LIST) return frontApplication();
+
+    errexit("can't find matching process");
+    return psn; // not reached
+}
+
+int main(int argc, char * const argv[]) {
+    OSStatus err = noErr;
+
+    APP_NAME = argv[0];
+    getargs(argc, argv);
+
+    ProcessSerialNumber psn;
+    
+    // required in Leopard to prevent paramErr - rdar://problem/5579375
+    err = GetCurrentProcess(&psn);
+    if (err != noErr) osstatusexit(err, "can't contact window server");
+    
+    psn = matchApplication();
+
+    const char *verb = NULL;
+    switch (OPTS.appAction) {
+        case APP_NONE: break;
+        case APP_LIST: break; // already handled in matchApplication
+        case APP_SWITCH: err = SetFrontProcess(&psn); verb = "set front"; break;
+        case APP_SHOW: err = ShowHideProcess(&psn, true); verb = "show"; break;
+        case APP_HIDE: err = ShowHideProcess(&psn, false); verb = "hide"; break;
+        case APP_QUIT: err = quitApplication(&psn); verb = "quit"; break;
+        case APP_KILL: err = KillProcess(&psn); verb = "send SIGTERM to"; break;
+        case APP_KILL_HARD:
+        {
+            // no Process Manager equivalent - rdar://problem/4808400
+            if (kill(getPID(&psn), SIGKILL) == -1)
+                err = (errno == ESRCH) ? procNotFound : (errno == EPERM ? permErr : paramErr);
+            verb = "send SIGKILL to";
+            break;
+        }
+        case APP_PRINT_PID: printf("%d\n", getPID(&psn)); break;
+        case APP_FRONTMOST: err = SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
+            verb = "bring frontmost window to front"; break;
+        default:
+            errexit("internal error: invalid application action");
+    }
+    if (err != noErr) osstatusexit(err, "can't %s process", verb);
+
+    switch (OPTS.action) {
+        case ACTION_NONE: break;
+        // no Process Manager equivalents - rdar://problem/4808397
+        case ACTION_SHOW_ALL:
+            [[NSAutoreleasePool alloc] init];
+            [[NSApplication sharedApplication] unhideAllApplications: nil];
+            err = noErr;
+            verb = "show all";
+            break;
+        case ACTION_HIDE_OTHERS:
+            [[NSAutoreleasePool alloc] init];
+            [[NSApplication sharedApplication] hideOtherApplications: nil];
+            err = noErr;
+            verb = "hide other";
+            break;
+        default:
+            errexit("internal error: invalid action");
+    }
+    if (err != noErr) osstatusexit(err, "can't %s processes", verb);
+
+    switch (OPTS.finalAction) {
+        case FINAL_NONE: break;
+        case FINAL_SWITCH:
+            psn = frontApplication();
+#if DEBUG
+            fprintf(stderr, "posting show request for %ld.%ld\n", psn.lowLongOfPSN, psn.highLongOfPSN);
+#endif
+            if (OPTS.action != ACTION_NONE) usleep(750000); // XXX
+            err = ShowHideProcess(&psn, true) || SetFrontProcess(&psn);
+            verb = "bring current application's windows to the front";
+            break;
+        default:
+            errexit("internal error: invalid final action");    
+    }
+    if (err != noErr) osstatusexit(err, "can't %s", verb);
+
+    exit(0);
+}
