Firefox 起動時に zenity で Flash のバージョンを切り替えできるようにしてみた
全くいっつもいっつも Adobe の Flash for Linux はこう面倒なんよなー,ほんと.
I'm tierd for Adobe Flash Player of Linux
Flash 10 が出てから、最近 Vine のユーザーフォーラムや ML,2ch のスレでも話題になっている.
というわけで,異なるバージョンの Adobe Flash プラグインを使い分ける([id:munepi:20080504:1209886177])で晒しているスクリプトを進化させて,zenity で選択できるようにしてみました.こんな感じです!
例えば,9.0.48 を選択して,次回 firefox を起動すると,前回選択したバージョンが表示されます.
[キャンセル]を押すと,firefox の起動をキャンセルします.何も選択せずに[ OK ]を押すと,前回選択していたバージョンで firefox を起動します.
んで,そのスクリプトを恥を忍んでそのまま晒します.私は myfirefox という名前にしています.
#!/bin/sh ### No the variable MOZ_PLUGIN_PATH exists in /usr/bin/firefox of Debian!!! __ls=/bin/ls __sed=/bin/sed POPD="cd `pwd`" if [ ! -d $HOME/.mozilla/firefox/*.default ]; then /usr/bin/firefox $* else fix-firefox > /dev/null 2>&1 MY_MOZ_PROFILE_DIR=`$__ls -d $HOME/.mozilla/firefox/*.default | head -1` MY_MOZ_DEFAULT_PROFILE=`basename $MY_MOZ_PROFILE_DIR` PUSHD="cd $MY_MOZ_PROFILE_DIR" $PUSHD MY_FLASH_PLUGIN_LIST="`$__ls -d -1 plugins-*` デフォルト" MY_CURRENT_FLASH_PLUGIN=`$__ls -l plugins | cut -d " " -f 10 | $__sed s/plugins-//` MY_FLASH_PLUGIN=$(zenity --list \ --title "Flashの選択" \ --width=500 --height=400 \ --window-icon=/usr/share/pixmaps/firefox.png \ --text "プロファイル $MY_MOZ_DEFAULT_PROFILE の利用可能な Flash のリストから\n利用したい Flash のバージョンを選択してください\n現在選択されている Flash のバージョンは $MY_CURRENT_FLASH_PLUGIN です" \ --column "Flash のリスト" $MY_FLASH_PLUGIN_LIST) #echo $MY_FLASH_PLUGIN [ $? = 1 ] && \ $POPD && exit 1 || \ rm -f plugins && ln -sf $MY_FLASH_PLUGIN plugins LANG=ja_JP.utf8 \ MOZ_PLUGIN_PATH=$MY_MOZ_PROFILE_DIR/plugins \ /usr/bin/firefox $* $POPD fi exit ### end of file
myfirefox 中の fix-firefox というのは,重複起動しないようにするためと,不正終了于したときのごみ取りとプロセス殺しのために,入れています.fix-firefox 単体でもそれなりに使える処理です.
#!/bin/sh ## This script is to remove main lock file ".parentlock" from your profiles. ## When your firefox is freeze on your system, you may use this script. if [ "`whoami`" = "root" ]; then if [ $# = 0 ]; then echo "You notice that you are root user!!!"; echo "Usage: $0 [user name]"; exit 1; else killall -u $1 firefox-bin; killall -u $1 firefox; find /home/$1/.mozilla/ -type f | grep '.parentlock' | xargs rm; exit 0; fi else killall -u `whoami` firefox-bin killall -u `whoami` firefox find $HOME/.mozilla/ -type f | grep '.parentlock' | xargs rm; echo "Please restart firefox." fi exit 0 ### end of file
上記のスクリプトを適当なパスが通っているところにおきます.
あとは,プロファイルのディレクトリに Flash のプラグインを詰めまくります.こんな感じです.
$ ls -l (snip) drwxr-xr-x 2 munepi munepi 4096 11月 9日 01:35 plugins-10.0.12/ drwxr-xr-x 2 munepi munepi 4096 5月18日 01:11 plugins-10.0.b128/ drwxr-xr-x 2 munepi munepi 4096 10月26日 13:57 plugins-10.0.d525/ drwxr-xr-x 2 munepi munepi 4096 3月 8日 2008 plugins-9.0.115/ drwxr-xr-x 2 munepi munepi 4096 4月26日 2008 plugins-9.0.124/ drwxr-xr-x 2 munepi munepi 4096 11月 9日 01:28 plugins-9.0.151/ drwxr-xr-x 2 munepi munepi 4096 2月 5日 2008 plugins-9.0.48/ (snip) $ ls plugins-* plugins-10.0.12: libflashplayer.so* plugins-10.0.b128: libflashplayer.so* plugins-10.0.d525: libflashplayer.so* plugins-9.0.115: libflashplayer.so* plugins-9.0.124: libflashplayer.so* plugins-9.0.151: libflashplayer.so* plugins-9.0.48: libflashplayer.so*
これで,各 Flash バージョンのテストや用途や目的に応じて選ぶといった使い方ができますね.
とりあえず,おしまいッ!
追記 [2008/11/22]:ちょっと myfirefox を修正。なぜこんなミスをして up したんだろう!?
- MY_CURRENT_FLASH_PLUGIN=`$__ls -l plugins | cut -d " " -f 11 | $__sed s/plugins-//` + MY_CURRENT_FLASH_PLUGIN=`$__ls -l plugins | cut -d " " -f 10 | $__sed s/plugins-//`