[TCC]位置情報 locationd とLiverpoolからアプリケーションを指定して削除
#!/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 framework "AppKit"
use scripting additions
property refMe : a reference to current application
tell application "Finder"
set aliasTemporaryItems to path to temporary items from local domain as alias with folder creation
set strTemporaryItemsPath to (POSIX path of aliasTemporaryItems) as text
end tell
set strFilePath to "/var/db/locationd/clients.plist" as text
set strDistFilePath to (strTemporaryItemsPath & "clients.plist") as text
set strCommandText to ("/usr/bin/sudo /usr/bin/ditto \"" & strFilePath & "\" \"" & strDistFilePath & "\"") as text
do shell script strCommandText with administrator privileges
set strCommandText to ("/usr/bin/sudo /bin/chmod 777 \"" & strDistFilePath & "\"") as text
do shell script strCommandText with administrator privileges
set ocidFilePathStr to refMe's NSString's stringWithString:(strDistFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
set ocidPlistDict to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:(ocidFilePathURL)
set ocidAllKeys to ocidPlistDict's allKeys()
set listAllKeys to ocidAllKeys as list
##############################
#####ダイアログを前面に
##############################
tell current application
set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
tell application "Finder"
activate
end tell
else
tell current application
activate
end tell
end if
##############################
#####ダイアログ
##############################
try
set listResponse to (choose from list listAllKeys with title "選んでください" with prompt "位置情報『locationd』から削除する項目を選んでください" default items (item 3 of listAllKeys) without multiple selections allowed and empty selection allowed)
on error
log "エラーしました"
return "エラーしました"
end try
if listResponse is false then
return "キャンセルしました"
end if
set strResponse to (item 1 of listResponse) as text
##############################
#####clients.plistから項目を削除
##############################
set strCommandText to ("/usr/bin/sudo /usr/bin/defaults delete \"" & strFilePath & "\" \"" & strResponse & "\"") as text
do shell script strCommandText with administrator privileges
##############################
#####TCCリセット用にUTIにする
##############################
set AppleScript's text item delimiters to ":"
set listDelim to (every text item of strResponse) as list
set AppleScript's text item delimiters to ""
set strUTI to (item 2 of listDelim) as text
###TCCの位置情報サービスkTCCServiceLiverpoolをリセット
set strCommandText to ("/usr/bin/tccutil reset \"Liverpool\" \"" & strUTI & "\"") as text
do shell script strCommandText with administrator privileges
###TCCの位置情報サービスkTCCServiceLiverpoolをリセット
set strCommandText to ("/usr/bin/sudo /usr/bin/tccutil reset \"Liverpool\" \"" & strUTI & "\"") as text
do shell script strCommandText with administrator privileges
| 固定リンク
「TCC」カテゴリの記事
- [TCC]サービス名を指定してTCCをリセットする(2023.06.05)
- [TCC]位置情報 locationd とLiverpoolからアプリケーションを指定して削除(2023.06.05)
- [sqlite3]モード (output mode)その1 ファイルに書き出す(2023.06.01)
- [sqlite3]モード (output mode)その2(2023.06.01)
- [TCC]kTCCService(OS13.4)(2023.06.01)
「locationd」カテゴリの記事
- [TCC]位置情報 locationd とLiverpoolからアプリケーションを指定して削除(2023.06.05)
- [locate]再構成(2023.06.04)
- spctl 設定変更(2023.05.07)
- [locate]基本(2023.03.30)
- [locationd]位置情報サービス(2022.04.06)