-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
original by Frederik Seiffert <[email protected]>
- Loading branch information
0 parents
commit 41bb69f
Showing
5 changed files
with
375 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pbxproj -crlf -merge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
build/ | ||
*.pbxuser | ||
*.mode1v3 | ||
*.mode2v3 | ||
*.perspective | ||
*.perspectivev3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. | ||
.\"See Also: | ||
.\"man mdoc.samples for a complete listing of options | ||
.\"man mdoc for the short list of editing options | ||
.\"/usr/share/misc/mdoc.template | ||
.Dd 03.05.06 \" DATE | ||
.Dt blueutil 1 \" Program name and manual section number | ||
.Os Darwin | ||
.Sh NAME \" Section Header - required - don't modify | ||
.Nm blueutil, | ||
.\" The following lines are read in generating the apropos(man -k) database. Use only key | ||
.\" words here as the database is built based on the words here and in the .ND line. | ||
.Nm Other_name_for_same_program(), | ||
.Nm Yet another name for the same program. | ||
.\" Use .Nm macro to designate other names for the documented program. | ||
.Nd This line parsed for whatis database. | ||
.Sh SYNOPSIS \" Section Header - required - don't modify | ||
.Nm | ||
.Op Fl abcd \" [-abcd] | ||
.Op Fl a Ar path \" [-a path] | ||
.Op Ar file \" [file] | ||
.Op Ar \" [file ...] | ||
.Ar arg0 \" Underlined argument - use .Ar anywhere to underline | ||
arg2 ... \" Arguments | ||
.Sh DESCRIPTION \" Section Header - required - don't modify | ||
Use the .Nm macro to refer to your program throughout the man page like such: | ||
.Nm | ||
Underlining is accomplished with the .Ar macro like this: | ||
.Ar underlined text . | ||
.Pp \" Inserts a space | ||
A list of items with descriptions: | ||
.Bl -tag -width -indent \" Begins a tagged list | ||
.It item a \" Each item preceded by .It macro | ||
Description of item a | ||
.It item b | ||
Description of item b | ||
.El \" Ends the list | ||
.Pp | ||
A list of flags and their descriptions: | ||
.Bl -tag -width -indent \" Differs from above in tag removed | ||
.It Fl a \"-a flag as a list item | ||
Description of -a flag | ||
.It Fl b | ||
Description of -b flag | ||
.El \" Ends the list | ||
.Pp | ||
.\" .Sh ENVIRONMENT \" May not be needed | ||
.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 | ||
.\" .It Ev ENV_VAR_1 | ||
.\" Description of ENV_VAR_1 | ||
.\" .It Ev ENV_VAR_2 | ||
.\" Description of ENV_VAR_2 | ||
.\" .El | ||
.Sh FILES \" File used or created by the topic of the man page | ||
.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact | ||
.It Pa /usr/share/file_name | ||
FILE_1 description | ||
.It Pa /Users/joeuser/Library/really_long_file_name | ||
FILE_2 description | ||
.El \" Ends the list | ||
.\" .Sh DIAGNOSTICS \" May not be needed | ||
.\" .Bl -diag | ||
.\" .It Diagnostic Tag | ||
.\" Diagnostic informtion here. | ||
.\" .It Diagnostic Tag | ||
.\" Diagnostic informtion here. | ||
.\" .El | ||
.Sh SEE ALSO | ||
.\" List links in ascending order by section, alphabetically within a section. | ||
.\" Please do not reference files that do not exist without filing a bug report | ||
.Xr a 1 , | ||
.Xr b 1 , | ||
.Xr c 1 , | ||
.Xr a 2 , | ||
.Xr b 2 , | ||
.Xr a 3 , | ||
.Xr b 3 | ||
.\" .Sh BUGS \" Document known, unremedied bugs | ||
.\" .Sh HISTORY \" Document history if command behaves in a unique manner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* blueutil | ||
* Command-line utility to control Bluetooth. | ||
* Uses private API from IOBluetooth framework (i.e. IOBluetoothPreference*()). | ||
* http://www.frederikseiffert.de/blueutil | ||
* | ||
* This software is public domain. It is provided without any warranty whatsoever, | ||
* and may be modified or used without attribution. | ||
* | ||
* Written by Frederik Seiffert <[email protected]> | ||
* Last change: 2009-10-30 | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
// link against IOBluetooth.framework | ||
|
||
|
||
inline int BTPowerState() | ||
{ | ||
return IOBluetoothPreferenceGetControllerPowerState(); | ||
} | ||
|
||
int BTSetPowerState(int powerState) | ||
{ | ||
IOBluetoothPreferenceSetControllerPowerState(powerState); | ||
|
||
usleep(2000000); // wait until BT has been set | ||
if (BTPowerState() != powerState) { | ||
printf("Error: unable to turn Bluetooth %s\n", powerState ? "on" : "off"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
void BTStatus() | ||
{ | ||
printf("Status: %s\n", BTPowerState() ? "on" : "off"); | ||
} | ||
|
||
int main(int argc, const char * argv[]) | ||
{ | ||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | ||
int result = EXIT_SUCCESS; | ||
|
||
if (!IOBluetoothPreferencesAvailable()) { | ||
printf("Error: Bluetooth not available"); | ||
result = EXIT_FAILURE; | ||
} else if (argc == 2 && strcmp(argv[1], "status") == 0) { | ||
BTStatus(); | ||
} else if (argc == 2 && strcmp(argv[1], "on") == 0) { | ||
result = BTSetPowerState(1); | ||
} else if (argc == 2 && strcmp(argv[1], "off") == 0) { | ||
result = BTSetPowerState(0); | ||
} else { | ||
printf("Usage: %s [status|on|off]\n", argv[0]); | ||
result = EXIT_FAILURE; | ||
} | ||
|
||
[pool release]; | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
// !$*UTF8*$! | ||
{ | ||
archiveVersion = 1; | ||
classes = { | ||
}; | ||
objectVersion = 42; | ||
objects = { | ||
|
||
/* Begin PBXBuildFile section */ | ||
86885D8B0A09577A000379F8 /* IOBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86885D8A0A09577A000379F8 /* IOBluetooth.framework */; }; | ||
8DD76F9A0486AA7600D96B5E /* blueutil.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* blueutil.m */; settings = {ATTRIBUTES = (); }; }; | ||
8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; }; | ||
8DD76F9F0486AA7600D96B5E /* blueutil.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859EA3029092ED04C91782 /* blueutil.1 */; }; | ||
/* End PBXBuildFile section */ | ||
|
||
/* Begin PBXCopyFilesBuildPhase section */ | ||
8DD76F9E0486AA7600D96B5E /* CopyFiles */ = { | ||
isa = PBXCopyFilesBuildPhase; | ||
buildActionMask = 8; | ||
dstPath = /usr/share/man/man1/; | ||
dstSubfolderSpec = 0; | ||
files = ( | ||
8DD76F9F0486AA7600D96B5E /* blueutil.1 in CopyFiles */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 1; | ||
}; | ||
/* End PBXCopyFilesBuildPhase section */ | ||
|
||
/* Begin PBXFileReference section */ | ||
08FB7796FE84155DC02AAC07 /* blueutil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = blueutil.m; sourceTree = "<group>"; }; | ||
08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; | ||
86885D8A0A09577A000379F8 /* IOBluetooth.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOBluetooth.framework; path = /System/Library/Frameworks/IOBluetooth.framework; sourceTree = "<absolute>"; }; | ||
8DD76FA10486AA7600D96B5E /* blueutil */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = blueutil; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
C6859EA3029092ED04C91782 /* blueutil.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = blueutil.1; sourceTree = "<group>"; }; | ||
/* End PBXFileReference section */ | ||
|
||
/* Begin PBXFrameworksBuildPhase section */ | ||
8DD76F9B0486AA7600D96B5E /* Frameworks */ = { | ||
isa = PBXFrameworksBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */, | ||
86885D8B0A09577A000379F8 /* IOBluetooth.framework in Frameworks */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
/* End PBXFrameworksBuildPhase section */ | ||
|
||
/* Begin PBXGroup section */ | ||
08FB7794FE84155DC02AAC07 /* blueutil */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
08FB7795FE84155DC02AAC07 /* Source */, | ||
C6859EA2029092E104C91782 /* Documentation */, | ||
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */, | ||
1AB674ADFE9D54B511CA2CBB /* Products */, | ||
); | ||
name = blueutil; | ||
sourceTree = "<group>"; | ||
}; | ||
08FB7795FE84155DC02AAC07 /* Source */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
08FB7796FE84155DC02AAC07 /* blueutil.m */, | ||
); | ||
name = Source; | ||
sourceTree = "<group>"; | ||
}; | ||
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
08FB779EFE84155DC02AAC07 /* Foundation.framework */, | ||
86885D8A0A09577A000379F8 /* IOBluetooth.framework */, | ||
); | ||
name = "External Frameworks and Libraries"; | ||
sourceTree = "<group>"; | ||
}; | ||
1AB674ADFE9D54B511CA2CBB /* Products */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
8DD76FA10486AA7600D96B5E /* blueutil */, | ||
); | ||
name = Products; | ||
sourceTree = "<group>"; | ||
}; | ||
C6859EA2029092E104C91782 /* Documentation */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
C6859EA3029092ED04C91782 /* blueutil.1 */, | ||
); | ||
name = Documentation; | ||
sourceTree = "<group>"; | ||
}; | ||
/* End PBXGroup section */ | ||
|
||
/* Begin PBXNativeTarget section */ | ||
8DD76F960486AA7600D96B5E /* blueutil */ = { | ||
isa = PBXNativeTarget; | ||
buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "blueutil" */; | ||
buildPhases = ( | ||
8DD76F990486AA7600D96B5E /* Sources */, | ||
8DD76F9B0486AA7600D96B5E /* Frameworks */, | ||
8DD76F9E0486AA7600D96B5E /* CopyFiles */, | ||
); | ||
buildRules = ( | ||
); | ||
dependencies = ( | ||
); | ||
name = blueutil; | ||
productInstallPath = "$(HOME)/bin"; | ||
productName = blueutil; | ||
productReference = 8DD76FA10486AA7600D96B5E /* blueutil */; | ||
productType = "com.apple.product-type.tool"; | ||
}; | ||
/* End PBXNativeTarget section */ | ||
|
||
/* Begin PBXProject section */ | ||
08FB7793FE84155DC02AAC07 /* Project object */ = { | ||
isa = PBXProject; | ||
buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "blueutil" */; | ||
compatibilityVersion = "Xcode 2.4"; | ||
developmentRegion = English; | ||
hasScannedForEncodings = 1; | ||
knownRegions = ( | ||
English, | ||
Japanese, | ||
French, | ||
German, | ||
); | ||
mainGroup = 08FB7794FE84155DC02AAC07 /* blueutil */; | ||
projectDirPath = ""; | ||
projectRoot = ""; | ||
targets = ( | ||
8DD76F960486AA7600D96B5E /* blueutil */, | ||
); | ||
}; | ||
/* End PBXProject section */ | ||
|
||
/* Begin PBXSourcesBuildPhase section */ | ||
8DD76F990486AA7600D96B5E /* Sources */ = { | ||
isa = PBXSourcesBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
8DD76F9A0486AA7600D96B5E /* blueutil.m in Sources */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
/* End PBXSourcesBuildPhase section */ | ||
|
||
/* Begin XCBuildConfiguration section */ | ||
1DEB927508733DD40010E9CD /* Debug */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
COPY_PHASE_STRIP = NO; | ||
GCC_DYNAMIC_NO_PIC = NO; | ||
GCC_ENABLE_FIX_AND_CONTINUE = YES; | ||
GCC_MODEL_TUNING = G5; | ||
GCC_OPTIMIZATION_LEVEL = 0; | ||
INSTALL_PATH = "$(HOME)/bin"; | ||
PRODUCT_NAME = blueutil; | ||
ZERO_LINK = YES; | ||
}; | ||
name = Debug; | ||
}; | ||
1DEB927608733DD40010E9CD /* Release */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
ARCHS = ( | ||
ppc, | ||
i386, | ||
); | ||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO; | ||
GCC_MODEL_TUNING = G5; | ||
INSTALL_PATH = "$(HOME)/bin"; | ||
PRODUCT_NAME = blueutil; | ||
}; | ||
name = Release; | ||
}; | ||
1DEB927908733DD40010E9CD /* Debug */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)"; | ||
ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc"; | ||
GCC_WARN_ABOUT_RETURN_TYPE = YES; | ||
GCC_WARN_UNUSED_VARIABLE = YES; | ||
PREBINDING = NO; | ||
SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; | ||
}; | ||
name = Debug; | ||
}; | ||
1DEB927A08733DD40010E9CD /* Release */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)"; | ||
ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc"; | ||
GCC_WARN_ABOUT_RETURN_TYPE = YES; | ||
GCC_WARN_UNUSED_VARIABLE = YES; | ||
PREBINDING = NO; | ||
SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; | ||
}; | ||
name = Release; | ||
}; | ||
/* End XCBuildConfiguration section */ | ||
|
||
/* Begin XCConfigurationList section */ | ||
1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "blueutil" */ = { | ||
isa = XCConfigurationList; | ||
buildConfigurations = ( | ||
1DEB927508733DD40010E9CD /* Debug */, | ||
1DEB927608733DD40010E9CD /* Release */, | ||
); | ||
defaultConfigurationIsVisible = 0; | ||
defaultConfigurationName = Release; | ||
}; | ||
1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "blueutil" */ = { | ||
isa = XCConfigurationList; | ||
buildConfigurations = ( | ||
1DEB927908733DD40010E9CD /* Debug */, | ||
1DEB927A08733DD40010E9CD /* Release */, | ||
); | ||
defaultConfigurationIsVisible = 0; | ||
defaultConfigurationName = Release; | ||
}; | ||
/* End XCConfigurationList section */ | ||
}; | ||
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; | ||
} |