| 001 | #!/usr/bin/env osascript |
| 002 | #coding: utf-8 |
| 003 | ----+----1----+----2----+----3----+----4----+----5----+----6----+----7 |
| 004 | (* |
| 005 |
|
| 006 | FinderWindowの検索の『キー』になる値の設定 |
| 007 | SlicesRootAttributes |
| 008 |
|
| 009 |
|
| 010 | defaults write がうまくいかない場合はこちらの方法で |
| 011 |
|
| 012 |
|
| 013 | v1 初回作成 |
| 014 | v1.1 『com_apple_ats_names』はNGみたいなので外した |
| 015 |
|
| 016 |
|
| 017 |
|
| 018 | com.cocolog-nifty.quicktimer.icefloe *) |
| 019 | ----+----1----+----2----+----3----+----4----+----5----+----6----+----7 |
| 020 | use AppleScript version "2.8" |
| 021 | use framework "Foundation" |
| 022 | use framework "AppKit" |
| 023 | use scripting additions |
| 024 | property refMe : a reference to current application |
| 025 |
|
| 026 | #################### |
| 027 | #NSUserDefaultsからDOCKの設定を取り出し |
| 028 | set appUserDefaults to refMe's NSUserDefaults's standardUserDefaults() |
| 029 | set ocidDefaultsDict to appUserDefaults's persistentDomainForName:("com.apple.finder") |
| 030 | set ocidDefaultsDictM to ocidDefaultsDict's mutableCopy() |
| 031 | # |
| 032 | set ocidItemArray to ocidDefaultsDictM's objectForKey:("SlicesRootAttributes") |
| 033 | set ocidItemArrayM to ocidItemArray's mutableCopy() |
| 034 | ############ |
| 035 | set listValue to {"com_apple_ats_name_family", "com_apple_ats_name_fond", "com_apple_ats_name_full", "com_apple_ats_name_postscript", "com_apple_ats_name_style", "com_apple_ats_names", "kMDItemFonts", "kMDItemFonts.ShortName"} as list |
| 036 |
|
| 037 | set listValue to {"com_apple_ats_name_family", "com_apple_ats_name_fond", "com_apple_ats_name_full", "com_apple_ats_name_postscript", "com_apple_ats_name_style", "kMDItemFonts", "kMDItemFonts.ShortName"} as list |
| 038 | repeat with itemValue in listValue |
| 039 | set boolContain to (ocidItemArrayM's containsObject:(itemValue)) |
| 040 | if boolContain is false then |
| 041 | (ocidItemArrayM's addObject:(itemValue)) |
| 042 | end if |
| 043 | end repeat |
| 044 | ############ |
| 045 | set listValue to {"kMDItemKind", "kMDItemLastUsedDate", "kMDItemFSContentChangeDate", "kMDItemContentCreationDate", "kMDItemDisplayName", "kMDItemTextContent"} as list |
| 046 | repeat with itemValue in listValue |
| 047 | set boolContain to (ocidItemArrayM's containsObject:(itemValue)) |
| 048 | if boolContain is false then |
| 049 | (ocidItemArrayM's addObject:(itemValue)) |
| 050 | end if |
| 051 | end repeat |
| 052 |
|
| 053 | ############ |
| 054 | set listValue to {"kMDItemXMPCredit", "kMDItemXMPDigitalSourceType"} as list |
| 055 | repeat with itemValue in listValue |
| 056 | set boolContain to (ocidItemArrayM's containsObject:(itemValue)) |
| 057 | if boolContain is false then |
| 058 | (ocidItemArrayM's addObject:(itemValue)) |
| 059 | end if |
| 060 | end repeat |
| 061 | ############ |
| 062 | set listValue to {"kMDItemFinderComment", "kMDItemComment", "kMDItemContentModificationDate", "kMDItemMediaTypes", "kMDItemUserTags", "kMDItemEmailAddresses", "com_apple_FileExtensionAttribute", "kMDItemFSInvisible", "kMDItemFSNodeCount", "kMDItemFSCreationDate", "kMDItemFSName", "kMDItemFSSize", "kMDItemFSLabel", "kMDItemColorSpace", "kMDItemLayerNames", "kMDItemPixelCount", "kMDItemPixelWidth", "kMDItemPixelHeight", "kMDItemPageHeight", "kMDItemPageWidth", "kMDItemOrientation", "kMDItemDurationSeconds", "kMDItemBitsPerSample"} as list |
| 063 | repeat with itemValue in listValue |
| 064 | set boolContain to (ocidItemArrayM's containsObject:(itemValue)) |
| 065 | if boolContain is false then |
| 066 | (ocidItemArrayM's addObject:(itemValue)) |
| 067 | end if |
| 068 | end repeat |
| 069 | ############ |
| 070 | ocidDefaultsDictM's setObject:(ocidItemArrayM) forKey:("SlicesRootAttributes") |
| 071 | appUserDefaults's setPersistentDomain:(ocidDefaultsDictM) forName:("com.apple.finder") |
| 072 |
|
| 073 | set boolDone to appUserDefaults's synchronize() |
| 074 |
|
| 075 |
|
| 076 | #ここまで |
| 077 | return |
| 078 | #ここからはメモ程度 |
| 079 |
|
| 080 | set recordSystemInfo to (system info) as record |
| 081 | set strUID to (short user name of recordSystemInfo) as text |
| 082 | set strFilePath to ("/Users/" & strUID & "/Library/Preferences/com.apple.finder.plist") as text |
| 083 |
|
| 084 |
|
| 085 | repeat with itemValue in listDefValue |
| 086 | set strValue to itemValue as text |
| 087 | set strCmd to ("/usr/bin/defaults read com.apple.finder SlicesRootAttributes") as text |
| 088 | |
| 089 | do shell script strCmd |
| 090 | end repeat |
| 091 |
|
| 092 |
|
| 093 |
|
| 094 | set strCmd to ("/bin/ps -lax | grep cfprefsd | grep $(id -u)| grep -v grep|awk '{print $2}'") as text |
| 095 | set strPID to (do shell script strCmd) as text |
| 096 |
|
| 097 | set strCmd to ("/bin/kill -9 " & strPID & "") as text |
| 098 | do shell script strCmd |