#!/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 scripting additions
property refMe : a reference to current application
###警告を出さないようにする
tell application "Finder"
set boolWarns to (trash's warns before emptying) as boolean
if boolWarns is true then
set trash's warns before emptying to false
end if
set boolWarns to (trash's warns before emptying) as boolean
end tell
###警告出すようにする
tell application "Finder"
set boolWarns to (trash's warns before emptying) as boolean
if boolWarns is false then
set trash's warns before emptying to true
end if
set boolWarns to (trash's warns before emptying) as boolean
end tell
######警告出すようにする
set strFilePath to "~/Library/Preferences/com.apple.finder.plist"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's fileURLWithPath:(ocidFilePath)
### 読み込み
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidFilePathURL)
### 値確認
set boolValue to ocidPlistDict's valueForKey:("WarnOnEmptyTrash")
if boolValue = (refMe's NSNumber's numberWithBool:false) then
ocidPlistDict's setValue:(refMe's NSNumber's numberWithBool:true) forKey:("WarnOnEmptyTrash")
####保存
set boolDone to ocidPlistDict's writeToURL:(ocidFilePathURL) atomically:true
end if
###警告を出さないようにする
set strFilePath to "~/Library/Preferences/com.apple.finder.plist"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's fileURLWithPath:(ocidFilePath)
### 読み込み
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidFilePathURL)
### 値確認
set boolValue to ocidPlistDict's valueForKey:("WarnOnEmptyTrash")
if boolValue = (refMe's NSNumber's numberWithBool:true) then
ocidPlistDict's setValue:(refMe's NSNumber's numberWithBool:false) forKey:("WarnOnEmptyTrash")
####保存
set boolDone to ocidPlistDict's writeToURL:(ocidFilePathURL) atomically:true
end if
###警告を出さないようにする
set strCommandText to ("/usr/libexec/PlistBuddy -c \"Print:WarnOnEmptyTrash\" \"$HOME/Library/Preferences/com.apple.finder.plist\"") as text
set strBoolWarns to (do shell script strCommandText) as text
if strBoolWarns is "true" then
##値の変更 BOOL
set strCommandText to ("/usr/libexec/PlistBuddy -c \"Set:WarnOnEmptyTrash bool false\" \"$HOME/Library/Preferences/com.apple.finder.plist\"") as text
do shell script strCommandText
##確認
set strCommandText to ("/usr/libexec/PlistBuddy -c \"Print:WarnOnEmptyTrash\" \"$HOME/Library/Preferences/com.apple.finder.plist\"") as text
do shell script strCommandText
##保存
set strCommandText to ("/usr/libexec/PlistBuddy -c \"Save\" \"$HOME/Library/Preferences/com.apple.finder.plist\"") as text
do shell script strCommandText
end if
###警告出すようにする
set strCommandText to ("/usr/libexec/PlistBuddy -c \"Print:WarnOnEmptyTrash\" \"$HOME/Library/Preferences/com.apple.finder.plist\"") as text
set strBoolWarns to (do shell script strCommandText) as text
if strBoolWarns is "false" then
##値の変更 BOOL
set strCommandText to ("/usr/libexec/PlistBuddy -c \"Set:WarnOnEmptyTrash bool true\" \"$HOME/Library/Preferences/com.apple.finder.plist\"") as text
do shell script strCommandText
##確認
set strCommandText to ("/usr/libexec/PlistBuddy -c \"Print:WarnOnEmptyTrash\" \"$HOME/Library/Preferences/com.apple.finder.plist\"") as text
do shell script strCommandText
##保存
set strCommandText to ("/usr/libexec/PlistBuddy -c \"Save\" \"$HOME/Library/Preferences/com.apple.finder.plist\"") as text
do shell script strCommandText
end if
###警告出すようにする
set strCommandText to ("/usr/bin/defaults read com.apple.finder WarnOnEmptyTrash") as text
set strBoolWarns to (do shell script strCommandText) as text
if strBoolWarns is "0" then
set boolWarns to false as boolean
set strCommandText to ("/usr/bin/defaults write com.apple.finder WarnOnEmptyTrash -boolean true") as text
do shell script strCommandText
end if
set strCommandText to ("/usr/bin/defaults read com.apple.finder WarnOnEmptyTrash") as text
set strBoolWarns to (do shell script strCommandText) as text
###警告を出さないようにする
set strCommandText to ("/usr/bin/defaults read com.apple.finder WarnOnEmptyTrash") as text
set strBoolWarns to (do shell script strCommandText) as text
if strBoolWarns is "1" then
set boolWarns to false as boolean
set strCommandText to ("/usr/bin/defaults write com.apple.finder WarnOnEmptyTrash -boolean false") as text
do shell script strCommandText
end if
set strCommandText to ("/usr/bin/defaults read com.apple.finder WarnOnEmptyTrash") as text
set strBoolWarns to (do shell script strCommandText) as text