AppleScript Bluetooth

AirDropを開く


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions
property refMe : a reference to current application

set strBundleID to "com.apple.finder.Open-AirDrop" as text

set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
if ocidAppBundle ≠ (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else if ocidAppBundle = (missing value) then
  set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
end if
if ocidAppPathURL = (missing value) then
  tell application "Finder"
    try
      set aliasAppApth to (application file id strBundleID) as alias
    on error
return "アプリケーションが見つかりませんでした"
    end try
  end tell
  set strAppPath to POSIX path of aliasAppApth as text
  set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
  set strAppPath to strAppPathStr's stringByStandardizingPath()
  set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:true
end if

set ocidOpenConfig to refMe's NSWorkspaceOpenConfiguration's configuration
(ocidOpenConfig's setActivates:(refMe's NSNumber's numberWithBool:true))
(appSharedWorkspace's openApplicationAtURL:(ocidAppPathURL) configuration:(ocidOpenConfig) completionHandler:(missing value))


|

[Bluetooth]スクリプトメニュー用 Bluetooth便利セット(更新)

blueutilのバージョンが2.9.1になった

ダウンロード - bluetooth.zip



【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()


########################
####保存先ディレクトリ
########################
set ocidLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserPathURL to ocidLibraryPathArray's objectAtIndex:0
set ocidSaveDirPathURL to ocidUserPathURL's URLByAppendingPathComponent:"Scripts/Bluetooth" isDirectory:true
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
set listResults to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)


########################
#### ファイルダウンロード
########################
###起動時に削除される項目
set ocidTempDirPathURL to appFileManager's temporaryDirectory()
set ocidCleanupAtStartupURL to ocidTempDirPathURL's URLByAppendingPathComponent:"Cleanup At Startup"
####アクセス権777で作成
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
appFileManager's createDirectoryAtURL:ocidCleanupAtStartupURL withIntermediateDirectories:true attributes:ocidAttrDict |error|:(reference)

set strZipFileURL to "https://quicktimer.cocolog-nifty.com/icefloe/files/bluetooth.zip"
set ocidZipFilePath to (refMe's NSString's stringWithString:strZipFileURL)
set ocidZipFilePathURL to refMe's NSURL's alloc()'s initWithString:ocidZipFilePath

set ocidZipData to refMe's NSData's dataWithContentsOfURL:ocidZipFilePathURL

set ocidSaveZipFilePathURL to ocidCleanupAtStartupURL's URLByAppendingPathComponent:"bluetooth.zip" isDirectory:false
set boolResults to ocidZipData's writeToURL:ocidSaveZipFilePathURL atomically:true

if boolResults is false then
return "ダウンロードに失敗しました"
end if

########################
#### 解凍
########################
set strZipFilePathURL to ocidSaveZipFilePathURL's |path|() as text
set strSaveDirPathURL to (ocidSaveDirPathURL's URLByDeletingLastPathComponent())'s |path|() as text
log strZipFilePathURL
log strSaveDirPathURL
try
  set theComandText to ("/usr/bin/ditto -xk \"" & strZipFilePathURL & "\"   \"" & strSaveDirPathURL & "\"") as text
  do shell script theComandText
end try

#############################
###スクリプトメニューを有効にする
#############################
tell application id "com.apple.ScriptMenuApp"
  launch
  activate
end tell
#############################
###設定
#############################

do shell script "/usr/bin/defaults write com.apple.ScriptMenuApp \"NSStatusItem Visible com.apple.scriptmenu\" -bool true"
do shell script "/usr/bin/defaults write com.apple.scriptmenu PutAppScriptsFirst -bool true"
do shell script "/usr/bin/defaults write com.apple.scriptmenu ScriptMenuEnabled -bool true"
do shell script "/usr/bin/defaults write com.apple.scriptmenu ShowLibraryScripts -bool true"

do shell script "/usr/bin/defaults read com.apple.scriptmenu"
do shell script "/usr/bin/defaults read com.apple.ScriptMenuApp"
delay 1
#############################
###CFPreferencesを再起動
#############################
#####CFPreferencesを再起動
set strCommandText to "/usr/bin/killall cfprefsd" as text
do shell script strCommandText
delay 1
#############################
###関連エイリアス生成
#############################
set strOrgFilePath to "/System/Applications/Utilities/Bluetooth File Exchange.app"
set ocidFilePathStr to refMe's NSString's stringWithString:strOrgFilePath
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
##
set ocidDistPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"Bluetooth File Exchange.app" isDirectory:true
##
set listBookMarkNSData to (ocidFilePathURL's bookmarkDataWithOptions:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) includingResourceValuesForKeys:{refMe's NSURLCustomIconKey} relativeToURL:(missing value) |error|:(reference))
set ocdiBookMarkData to (item 1 of listBookMarkNSData)
set listResults to (refMe's NSURL's writeBookmarkData:ocdiBookMarkData toURL:ocidDistPathURL options:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) |error|:(reference))


set strOrgFilePath to "/System/Library/CoreServices/BluetoothSetupAssistant.app"
set ocidFilePathStr to refMe's NSString's stringWithString:strOrgFilePath
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
##
set ocidDistPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"BluetoothSetupAssistant.app" isDirectory:true
##
set listBookMarkNSData to (ocidFilePathURL's bookmarkDataWithOptions:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) includingResourceValuesForKeys:{refMe's NSURLCustomIconKey} relativeToURL:(missing value) |error|:(reference))
set ocdiBookMarkData to (item 1 of listBookMarkNSData)
set listResults to (refMe's NSURL's writeBookmarkData:ocdiBookMarkData toURL:ocidDistPathURL options:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) |error|:(reference))


set strOrgFilePath to "/System/Library/CoreServices/Paired Devices.app"
set ocidFilePathStr to refMe's NSString's stringWithString:strOrgFilePath
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
##
set ocidDistPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"Paired Devices.app" isDirectory:true
##
set listBookMarkNSData to (ocidFilePathURL's bookmarkDataWithOptions:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) includingResourceValuesForKeys:{refMe's NSURLCustomIconKey} relativeToURL:(missing value) |error|:(reference))
set ocdiBookMarkData to (item 1 of listBookMarkNSData)
set listResults to (refMe's NSURL's writeBookmarkData:ocdiBookMarkData toURL:ocidDistPathURL options:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) |error|:(reference))



#############################
###Finderでフォルダを開く
#############################
appShardWorkspace's openURL:ocidSaveDirPathURL


return "処理終了"


|

[Bluetooth]AirDropを停止する


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#error number -128
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

###今の設定
set strCommandText to ("/usr/bin/defaults read com.apple.NetworkBrowser DisableAirDrop") as text
set intResults to (do shell script strCommandText) as integer

if intResults = 0 then
  set strMes to "AirDropが有効です 無効にします"
  set listButtons to {"AirDrop無効にします", "AirDrop有効にします", "キャンセル"}
else
  set strMes to "AirDropが無効です 有効にします"
  set listButtons to {"AirDrop有効にします", "AirDrop無効にします", "キャンセル"}
end if
#####ダイアログ
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

set aliasIconPath to POSIX file "/System/Library/CoreServices/Finder.app/Contents/Applications/AirDrop.app/Contents/Resources/OpenAirDropAppIcon.icns" as alias
set strDefaultAnswer to strMes as text
try
  set recordResponse to (display dialog strMes with title "選んでください" buttons listButtons default button (item 1 of listButtons) cancel button (item 3 of listButtons) with icon aliasIconPath giving up after 20 without hidden answer)
on error
  log "エラーしました"
return "エラーしました"
end try
if true is equal to (gave up of recordResponse) then
return "時間切れですやりなおしてください"
end if
if "AirDrop無効にします" is equal to (button returned of recordResponse) then
  set boolAirDrop to true as boolean
else if "AirDrop有効にします" is equal to (button returned of recordResponse) then
  set boolAirDrop to false as boolean
else
  log "キャンセルしました"
return "キャンセルしました"
end if

###コマンド実行
if boolAirDrop = true then
  log "AirDropが有効です"
  set strCommandText to ("/usr/bin/defaults write com.apple.NetworkBrowser DisableAirDrop -bool true") as text
  set intResults to (do shell script strCommandText) as integer
  log "AirDropを無効に切り替えました"
else
  log "AirDropが無効です"
  set strCommandText to ("/usr/bin/defaults write com.apple.NetworkBrowser DisableAirDrop -bool false") as text
  set intResults to (do shell script strCommandText) as integer
  log "AirDropを有効に切り替えました"
end if


###CFPreferencesを再起動
set strCommandText to "/usr/bin/killall cfprefsd" as text
do shell script strCommandText
###Finder再起動
set strCommandText to "/usr/bin/killall Finder" as text
do shell script strCommandText

|

Bluetooth スクリプトメニュー用

ダウンロード - bluetooth.zip




【スクリプトエディタで開く】

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()


########################
####保存先ディレクトリ
########################
set ocidLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserPathURL to ocidLibraryPathArray's objectAtIndex:0
set ocidSaveDirPathURL to ocidUserPathURL's URLByAppendingPathComponent:"Scripts/Bluetooth" isDirectory:true
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
set listResults to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)


########################
#### ファイルダウンロード
########################
###起動時に削除される項目
set ocidTempDirPathURL to appFileManager's temporaryDirectory()
set ocidCleanupAtStartupURL to ocidTempDirPathURL's URLByAppendingPathComponent:"Cleanup At Startup"
####アクセス権777で作成
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
appFileManager's createDirectoryAtURL:ocidCleanupAtStartupURL withIntermediateDirectories:true attributes:ocidAttrDict |error|:(reference)

set strZipFileURL to "https://quicktimer.cocolog-nifty.com/icefloe/files/bluetooth.zip"
set ocidZipFilePath to (refMe's NSString's stringWithString:strZipFileURL)
set ocidZipFilePathURL to refMe's NSURL's alloc()'s initWithString:ocidZipFilePath

set ocidZipData to refMe's NSData's dataWithContentsOfURL:ocidZipFilePathURL

set ocidSaveZipFilePathURL to ocidCleanupAtStartupURL's URLByAppendingPathComponent:"bluetooth.zip" isDirectory:false
set boolResults to ocidZipData's writeToURL:ocidSaveZipFilePathURL atomically:true

if boolResults is false then
  return "ダウンロードに失敗しました"
end if

########################
#### 解凍
########################
set strZipFilePathURL to ocidSaveZipFilePathURL's |path|() as text
set strSaveDirPathURL to (ocidSaveDirPathURL's URLByDeletingLastPathComponent())'s |path|() as text
log strZipFilePathURL
log strSaveDirPathURL
try
  set theComandText to ("/usr/bin/ditto -xk  \"" & strZipFilePathURL & "\"   \"" & strSaveDirPathURL & "\"") as text
  do shell script theComandText
end try

#############################
###スクリプトメニューを有効にする
#############################
tell application id "com.apple.ScriptMenuApp"
  launch
  activate
end tell
#############################
###設定
#############################

do shell script "/usr/bin/defaults write com.apple.ScriptMenuApp \"NSStatusItem Visible com.apple.scriptmenu\"  -bool true"
do shell script "/usr/bin/defaults write com.apple.scriptmenu PutAppScriptsFirst -bool true"
do shell script "/usr/bin/defaults write com.apple.scriptmenu ScriptMenuEnabled -bool true"
do shell script "/usr/bin/defaults write com.apple.scriptmenu ShowLibraryScripts -bool true"

do shell script "/usr/bin/defaults read com.apple.scriptmenu"
do shell script "/usr/bin/defaults read com.apple.ScriptMenuApp"
delay 1
#############################
###CFPreferencesを再起動
#############################
#####CFPreferencesを再起動
set strCommandText to "/usr/bin/killall cfprefsd" as text
do shell script strCommandText
delay 1
#############################
###関連エイリアス生成
#############################
set strOrgFilePath to "/System/Applications/Utilities/Bluetooth File Exchange.app"
set ocidFilePathStr to refMe's NSString's stringWithString:strOrgFilePath
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
##
set ocidDistPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"Bluetooth File Exchange.app" isDirectory:true
##
set listBookMarkNSData to (ocidFilePathURL's bookmarkDataWithOptions:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) includingResourceValuesForKeys:{refMe's NSURLCustomIconKey} relativeToURL:(missing value) |error|:(reference))
set ocdiBookMarkData to (item 1 of listBookMarkNSData)
set listResults to (refMe's NSURL's writeBookmarkData:ocdiBookMarkData toURL:ocidDistPathURL options:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) |error|:(reference))


set strOrgFilePath to "/System/Library/CoreServices/BluetoothSetupAssistant.app"
set ocidFilePathStr to refMe's NSString's stringWithString:strOrgFilePath
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
##
set ocidDistPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"BluetoothSetupAssistant.app" isDirectory:true
##
set listBookMarkNSData to (ocidFilePathURL's bookmarkDataWithOptions:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) includingResourceValuesForKeys:{refMe's NSURLCustomIconKey} relativeToURL:(missing value) |error|:(reference))
set ocdiBookMarkData to (item 1 of listBookMarkNSData)
set listResults to (refMe's NSURL's writeBookmarkData:ocdiBookMarkData toURL:ocidDistPathURL options:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) |error|:(reference))


set strOrgFilePath to "/System/Library/CoreServices/Paired Devices.app"
set ocidFilePathStr to refMe's NSString's stringWithString:strOrgFilePath
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
##
set ocidDistPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"Paired Devices.app" isDirectory:true
##
set listBookMarkNSData to (ocidFilePathURL's bookmarkDataWithOptions:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) includingResourceValuesForKeys:{refMe's NSURLCustomIconKey} relativeToURL:(missing value) |error|:(reference))
set ocdiBookMarkData to (item 1 of listBookMarkNSData)
set listResults to (refMe's NSURL's writeBookmarkData:ocdiBookMarkData toURL:ocidDistPathURL options:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) |error|:(reference))



#############################
###Finderでフォルダを開く
#############################
appShardWorkspace's openURL:ocidSaveDirPathURL


return "処理終了"

|

システム設定 パネルを開く アンカー指定

【スクリプトエディタで開く】

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
#        com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

###起動
tell application id "com.apple.systempreferences"
  launch
end tell

###起動待ち
tell application id "com.apple.systempreferences"
  ###起動確認 最大10秒
  repeat 10 times
    activate
    set boolFrontMost to frontmost as boolean
    if boolFrontMost is true then
      exit repeat
    else
      delay 1
    end if
  end repeat
end tell
###パネルを開く アンカー指定
tell application id "com.apple.systempreferences"
  launch
  activate
  reveal anchor "Main" of pane id "com.apple.BluetoothSettings"
end tell
###名前を取得して
tell application id "com.apple.systempreferences"
  launch
  activate
  tell front window
    set strWindowName to name as text
  end tell
end tell
####開けていなかったらコマンドで開く
if strWindowName is not "Bluetooth" then
  set theCommandText to ("open \"x-apple.systempreferences:com.apple.preferences.Bluetooth?Main\"") as text
  do shell script theCommandText
else
  return "処理終了"
end if



|

[システム設定]Bluetooth com.apple.BluetoothSettings(macOS13)

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#error number -128
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions




property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL


set aliasScriptsFolder to path to scripts folder from user domain as alias
tell application "Finder"
set boolFolderChk to (exists of (folder "Bluetooth" of folder aliasScriptsFolder)) as boolean
if (boolFolderChk is false) then
make new folder at aliasScriptsFolder with properties {name:"Bluetooth"}
end if
set aliasColorFolder to folder "Bluetooth" of folder aliasScriptsFolder as «class furl»
end tell

set aliasOrigFilePath to (POSIX file "/System/Applications/Utilities/Bluetooth File Exchange.app") as alias

tell application "Finder"
set boolFolderChk to (exists of (file "Bluetoothファイル交換.app" of folder "Bluetooth" of folder aliasScriptsFolder)) as boolean
if (boolFolderChk is false) then
make alias at aliasColorFolder to aliasOrigFilePath
end if
end tell

set aliasOrigFilePath to (POSIX file "/System/Library/CoreServices/BluetoothSetupAssistant.app") as alias

tell application "Finder"
set boolFolderChk to (exists of (file "Bluetooth設定アシスタント.app" of folder "Bluetooth" of folder aliasScriptsFolder)) as boolean
if (boolFolderChk is false) then
make alias at aliasColorFolder to aliasOrigFilePath
end if
end tell


set aliasOrigFilePath to (POSIX file "//System/Library/CoreServices/Paired Devices.app") as alias

tell application "Finder"
set boolFolderChk to (exists of (file "ペアリング済みのデバイス.app" of folder "Bluetooth" of folder aliasScriptsFolder)) as boolean
if (boolFolderChk is false) then
make alias at aliasColorFolder to aliasOrigFilePath
end if
end tell


set ocidWorkspace to refMe's NSWorkspace's sharedWorkspace()

###
set ocidSystemPreferencesURL to refNSURL's URLWithString:"x-apple.systempreferences:com.apple.BluetoothSettings"



###アンカーの指定方法がわからない
ocidWorkspace's openURL:ocidSystemPreferencesURL

|

[Bluetooth]/blueutil

https://github.com/toy/blueutil
XcodeでBuildしても良いですし
makeもできます。

sh-3.2$ ./blueutil

Power: 1

Discoverable: 0

sh-3.2$ 

sh-3.2$ ./blueutil -H

blueutil: invalid option -- H

blueutil v2.9.0


Usage:

  blueutil [options]


Without options outputs current state


    -p, --power               output power state as 1 or 0

    -p, --power STATE         set power state

    -d, --discoverable        output discoverable state as 1 or 0

    -d, --discoverable STATE  set discoverable state


        --favourites, --favorites

                              list favourite devices

        --inquiry [T]         inquiry devices in range, 10 seconds duration by default excluding time for name updates

        --paired              list paired devices

        --recent [N]          list recently used devices, 10 by default, 0 to list all

        --connected           list connected devices


        --info ID             show information about device

        --is-connected ID     connected state of device as 1 or 0

        --connect ID          create a connection to device

        --disconnect ID       close the connection to device

        --pair ID [PIN]       pair with device, optional PIN of up to 16 characters will be used instead of interactive input if requested in specific pair mode

        --unpair ID           EXPERIMENTAL unpair the device

        --add-favourite ID, --add-favorite ID

                              add to favourites

        --remove-favourite ID, --remove-favorite ID

                              remove from favourites


        --format FORMAT       change output format of info and all listing commands


        --wait-connect ID [TIMEOUT]

                              EXPERIMENTAL wait for device to connect

        --wait-disconnect ID [TIMEOUT]

                              EXPERIMENTAL wait for device to disconnect

        --wait-rssi ID OP VALUE [PERIOD [TIMEOUT]]

                              EXPERIMENTAL wait for device RSSI value which is 0 for golden range, -129 if it cannot be read (e.g. device is disconnected)


    -h, --help                this help

    -v, --version             show version


STATE can be one of: 1, on, 0, off, toggle

ID can be either address in form xxxxxxxxxxxx, xx-xx-xx-xx-xx-xx or xx:xx:xx:xx:xx:xx, or name of device to search in used devices

OP can be one of: >, >=, <, <=, =, !=; or equivalents: gt, ge, lt, le, eq, ne

PERIOD is in seconds, defaults to 1

TIMEOUT is in seconds, default value 0 doesn't add timeout

FORMAT can be one of:

  default - human readable text output not intended for consumption by scripts

  new-default - human readable comma separated key-value pairs (EXPERIMENTAL, THE BEHAVIOUR MAY CHANGE)

  json - compact JSON

  json-pretty - pretty printed JSON


Due to possible problems, blueutil will refuse to run as root user (see https://github.com/toy/blueutil/issues/41).

Use environment variable BLUEUTIL_ALLOW_ROOT=1 to override (sudo BLUEUTIL_ALLOW_ROOT=1 blueutil …).


Exit codes:

   0 Success

   1 General failure

  64 Wrong usage like missing or unexpected arguments, wrong parameters

  69 Bluetooth or interface not available

  70 Internal error

  71 System error like shortage of memory

  75 Timeout error

sh-3.2$ 

sh-3.2$ 

|

[Bluetooth]Bluetoothファイル共有を停止させる

Bluetoothファイル共有を停止させる

ダウンロード - bluetoothstopfileshare.scpt.zip

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use scripting additions

try
set theComandText to ("/usr/bin/defaults -currentHost write com.apple.Bluetooth PrefKeyServicesEnabled -boolean false") as text
do shell script theComandText
end try

try
set theComandText to ("/usr/bin/defaults -currentHost write com.apple.Bluetooth OBEXFileHandling -integer 2") as text
do shell script theComandText
end try

try
set theComandText to ("/usr/bin/defaults -currentHost write com.apple.Bluetooth OBEXBrowseConnectionHandling -integer 2") as text
do shell script theComandText
end try

try
set theComandText to ("/usr/bin/defaults -currentHost write com.apple.Bluetooth OBEXOtherDataDisposition -integer 0") as text
do shell script theComandText
end try
#######################
try
set theComandText to ("/usr/bin/defaults write com.apple.BluetoothFileExchange OBEXFTPRootFolderLocation -string \"~/Public\"") as text
do shell script theComandText
end try
try
set theComandText to ("/usr/bin/defaults write com.apple.BluetoothFileExchange OBEXPIMDataSaveToLocation -string \"~/Downloads\"") as text
do shell script theComandText
end try

#######################
try
set theComandText to ("/usr/bin/defaults write com.apple.BluetoothFileExchange IOBluetoothDeviceSelectorModalDeviceTypeIndex -integer 0") as text
do shell script theComandText
end try
try
set theComandText to ("/usr/bin/defaults write com.apple.BluetoothFileExchange IOBluetoothDeviceSelectorModalDeviceCategoryIndex -integer 0") as text
do shell script theComandText
end try
try
set theComandText to ("/usr/bin/defaults write com.apple.BluetoothFileExchange StartupBehaviorKey -integer 0") as text
do shell script theComandText
end try
try
set theComandText to ("/usr/bin/defaults write com.apple.BluetoothFileExchange NSNavLastRootDirectory -string \"~/Public\"") as text
do shell script theComandText
end try
#######################
try
tell application "System Preferences" to launch

repeat
set doLaunchApp to get running of application "System Preferences"
if doLaunchApp is false then
delay 0.5
else
exit repeat
end if
end repeat

repeat
try
tell application "System Preferences"
set current pane to pane "com.apple.preferences.sharing"
set thePaneID to id of current pane
end tell
on error
delay 0.5
tell application "System Preferences"
set thePaneID to id of current pane
end tell
end try
if thePaneID is "com.apple.preferences.sharing" then
exit repeat
else
delay 0.5
end if
end repeat

--アンカーを指定する
tell application "System Preferences"
tell current pane
reveal anchor "share"
end tell
end tell
tell application "System Preferences"
tell current pane
reveal anchor "share"
end tell
activate
end tell


on error
set theCommandText to ("open \"x-apple.systempreferences:com.apple.preferences.sharing?Services_BluetoothSharing\"") as text
do shell script theCommandText

end try

|

[Bluetooth]BlueTool

/System/Library/LaunchDaemons/com.apple.BlueTool.plist
/usr/sbin/BlueTool


sh-3.2$  /usr/sbin/BlueTool -h

BlueTool -- A Bluetooth Config/Control Tool


Options:

-h              This message.

-f <filename>   Read commands from file at startup.

-F sequenceruns the default script for a given sequence.

-c <commands>   Execute commands from string at startup.


sh-3.2$ 




sh-3.2$  /usr/sbin/BlueTool -h

BlueTool -- A Bluetooth Config/Control Tool


Options:

-h              This message.

-f <filename>   Read commands from file at startup.

-F sequenceruns the default script for a given sequence.

-c <commands>   Execute commands from string at startup.


sh-3.2$ 




bluetool-> -h

-h - unknown command.

bluetool-> autobaud -h

bluetool_command_autobaud

Device not currently opened.

autobaud returned 3

bluetool-> device -h

-D           - Open pci transport (boot/hci)

-h           - Print device help prompt


bluetool-> hci -h

usage: hci <command>

where <command> is one of:

  info             : Sends read local version to device

  reset            : Sends reset command to device

  dut              : Places device into dut test mode

  sef              : Set event filter (Type, Condition, AutoAccept)

  wse              : Write scan enable (Scan)

  cmd              : Send HCI command (Command, Param1, Param2, Param3, ..., ParamN)

  localName        : Sends the read local name command to device

bluetool-> aci -h

aci - ACI Specific Commands

-V    - Print ACI version information

-W    - Download ACI init script internally or from /etc/bluetool/

-w    - Download HCD file from /path/to/hcd/file.hcd

-b    - Set the baud rate - Baud Rate (UART only)

-B    - Set the baud rate using a predefined value (UART only)

-a    - Set BDADDR - 00:00:00:00:00:00

-A    - Set BDADDR using devicetree

-n    - Set the local name - Local Name

-p    - Routes sco over PCM

-t    - Routes sco over Transport (HCI)

-c    - Get ACL data, up to 256 bytes

-s    - Get SCO data to file

-S    - Set device for SCO over HCI, Set Event filter to accept any connection and change the bT address to 123456

-o    - For ACI options: 

addr1- to change BT address to 123456, 

hcivoice- for voice over HCI (UART), 

pcmvoice- for voice over PCM include Trio L codec configuration script

-O    - Sleep delay after "power on", adapted to different ACI chipsets (BGA, FPGA, etc...)

-F    - Download FW RAM image HCD file from /etc/bluetool/

-U    - Get System Status 

-R    - Set Rand Seed 

-Q    - Download MSF from ioreg

-q    - Download MSF from /path/to/msf/msf.bin

-K    - Download power regulatory HCD file internally


bluetool-> bcm -h

bcm - Broadcom Specific Commands

-w    - Download HCD configuration file /path/to/hcd/file.hcd

-W    - Download default HCD 

-L    - Download Low power mode FW 

-v    - prints the default hcd file loaded 

-a    - Set BDADDR - 00:00:00:00:00:00

-A    - Set BDADDR using devicetree

-b    - Set the baud rate - Baud Rate

-B    - Set the baud rate using a predefined value

-P    - Configure I2S PCM and GPIO pins (inactive function/mode)

-g    - Setup the I2S GPIO lines

-p    - Routes sco over PCM

-t    - Routes sco over Transport (HCI)

-n    - Set the local name - Local Name

-N    - Set the local name to equal the host name

-s    - Set the sleep mode - Sleep Mode, (0x09 = H5)

                             Idle Threshold Host, (Not applicable to 

                             Idle Threshold HC,

                             BT WAKE Active Mode,

                             Host WAKE Active Mode,

                             Allow Host Sleep During SCO,

                             Combine Sleep Mode and LPM,

                             Enable Tristate Control of UART TX Line,

                             Active Connection Handling On Suspend,

                             Resume Timeout,

                             Enable Break to Host,

                             Pulsed Host Wake,

-m    - Checks manufacturer

-R    - Run RSSI sweep (MFG FW required)

-r    - Writes to RAM

-x    - Load regulatory power table

-u    - Update firmware in serial flash

|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom