Tomotaka SUWA
t-suw****@users*****
2006年 2月 25日 (土) 16:27:33 JST
Index: AquaSKK/Package/scripts/postflight diff -u AquaSKK/Package/scripts/postflight:1.1.2.2 AquaSKK/Package/scripts/postflight:1.1.2.3 --- AquaSKK/Package/scripts/postflight:1.1.2.2 Sun Feb 19 16:09:12 2006 +++ AquaSKK/Package/scripts/postflight Sat Feb 25 16:27:33 2006 @@ -1,44 +1,118 @@ #!/bin/sh -# domain +# library path +#PREF=/tmp # for DEBUG PREF=~/Library/Preferences +ASKK=~/Library/AquaSKK + +### +### generate new user defaults +### OLD_DOMAIN="org.ccm-software.AquaSKKServer" NEW_DOMAIN="jp.sourceforge.AquaSKKServer" -FILE_PATH=$PREF/$NEW_DOMAIN +OLD_PATH=$PREF/$OLD_DOMAIN +OLD_PLIST=$OLD_PATH.plist + +NEW_PATH=$PREF/$NEW_DOMAIN +NEW_PLIST=$NEW_PATH.plist + +# not exists ? +if [ ! -f $NEW_PLIST ]; then + # copy old user defaults + cp $OLD_PLIST $NEW_PLIST + + # rename keys + defaults rename $NEW_PATH dic.FontName.Window candidates_font_name + defaults rename $NEW_PATH dic.FontSize.Window candidates_font_size + defaults rename $NEW_PATH dic.WindowAlpha.kotoeri candidates_window_alpha + defaults rename $NEW_PATH dic.WindowColor.kotoeri candidates_window_color + defaults rename $NEW_PATH dic.skk-egg-like-newline.kotoeri egg_like_newline + defaults rename $NEW_PATH ForceASCIImodeStartup force_ascii_mode_startup + defaults rename $NEW_PATH KeyboardLayoutIdentifier keyboard_layout_id + defaults rename $NEW_PATH dic.NumericKeypad_HalfWidth.kotoeri numkeypad_use_halfwidth + defaults rename $NEW_PATH pref.skkserv.enabled skkserv_enabled + defaults rename $NEW_PATH pref.skkserv.local-only skkserv_localonly + defaults rename $NEW_PATH pref.skkserv.port skkserv_port + + # delete unused keys + defaults delete $NEW_PATH dic.path.kotoeri + defaults delete $NEW_PATH dic.path.main + defaults delete $NEW_PATH dic.path.sub + + # change owner + chown $USER $NEW_PLIST +fi -OLD_PLIST=$PREF/$OLD_DOMAIN.plist -NEW_PLIST=$FILE_PATH.plist +### +### generate DictionarySet.plist +### + +DIC_PATH=$ASKK/DictionarySet +DIC_PLIST=$DIC_PATH.plist # already exists ? -if [ -f $NEW_PLIST ]; then - echo "[$NEW_PLIST] already exists." - exit 0 +if [ -f $DIC_PLIST ]; then + echo $DIC_PLIST already exists. + exit 0; +fi + +# create initial plist +cat >$DIC_PLIST<<EOF +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<array> +EOF + +# read old paths +SUB_PATH=`defaults read $OLD_PATH dic.path.sub` +MAIN_PATH=`defaults read $OLD_PATH dic.path.main` +KOTOERI_PATH=`defaults read $OLD_PATH dic.path.kotoeri|sed 's/[,()"]//g'` + +# skk dictionary +if [ -z $SUB_PATH ]; then + SUB_PATH=~/.skk-jisyo fi -# copy old user defaults -cp $OLD_PLIST $NEW_PLIST +if [ -z $MAIN_PATH ]; then + MAIN_PATH=~/Library/AquaSKK/SKK-JISYO.L +fi -# rename keys -defaults rename $FILE_PATH dic.FontName.Window candidates_font_name -defaults rename $FILE_PATH dic.FontSize.Window candidates_font_size -defaults rename $FILE_PATH dic.WindowAlpha.kotoeri candidates_window_alpha -defaults rename $FILE_PATH dic.WindowColor.kotoeri candidates_window_color -defaults rename $FILE_PATH dic.skk-egg-like-newline.kotoeri egg_like_newline -defaults rename $FILE_PATH ForceASCIImodeStartup force_ascii_mode_startup -defaults rename $FILE_PATH KeyboardLayoutIdentifier keyboard_layout_id -defaults rename $FILE_PATH dic.NumericKeypad_HalfWidth.kotoeri numkeypad_must_halfwidth -defaults rename $FILE_PATH pref.skkserv.enabled skkserv_enabled -defaults rename $FILE_PATH pref.skkserv.local-only skkserv_localonly -defaults rename $FILE_PATH pref.skkserv.port skkserv_port - -# delete unused keys -defaults delete $FILE_PATH dic.path.kotoeri -defaults delete $FILE_PATH dic.path.main -defaults delete $FILE_PATH dic.path.sub +for path in $SUB_PATH $MAIN_PATH; do +cat >>$DIC_PLIST<<EOF + <dict> + <key>active</key> + <true/> + <key>location</key> + <string>${path}</string> + <key>type</key> + <integer>10</integer> + </dict> +EOF +done + +# kotoeri dictionary +for path in $KOTOERI_PATH; do +cat >>$DIC_PLIST<<EOF + <dict> + <key>active</key> + <true/> + <key>location</key> + <string>${path}</string> + <key>type</key> + <integer>20</integer> + </dict> +EOF +done + +cat >>$DIC_PLIST<<EOF +</array> +</plist> +EOF # change owner -chown $USER $NEW_PLIST +chown $USER $DIC_PLIST exit 0