2012-12-25 35 views
0

我想創建一個應用程序來更改通知中心的背景,以便對其進行編程。有人請告訴我我的代碼有什麼問題。Applescript一個應用程序來更改獅子山通知中心的背景

set NCBGPath to "/System/Library/CoreServices/Notification Center/Contents/Resources/" 
set NCBackground to "linen.tiff" 
set themeFolder to (choose folder with prompt "Choose a Theme") as text 
set themePath to themeFolder & NCBackground 
set posixNCPath to NCBGPath & NCBackground 

set shouldCopy to false 
tell application "Finder" 
    if exists file themePath then set shouldCopy to true 
end tell 

if shouldCopy then 
    do shell script "cp " & quoted form of POSIX path of themePath & space & quoted form of posixNCPath with administrator privileges 
    -- you probably should correct the file permissions too as the copied file probably won't have the proper owner and stuff 
else 
    display dialog "Could not find the background file in the chosen folder." 
end if 

回答

0

可能是這樣的:「如果cp檢測到將文件複製到自身,則複製將失敗。」

if語句,如果你改變最後會發生什麼:

if shouldCopy then 
    do shell script "cp " & quoted form of POSIX path of themePath & space & quoted form of NCBGPath with administrator privileges 
    -- you probably should correct the file permissions too as the copied file probably won't have the proper owner and stuff 
else 
    display dialog "Could not find the background file in the chosen folder." 
end if 
+0

它說/系統/圖書館/ CoreServices /通知中心/內容/資源/不存在 –

相關問題