擬似的にプレビューできるようにした。
SUB_DIALOGを表示する際に、MAIN_DIALOGにhideを与えるようにした。
※ 注意 ※
0)Precise Puppy 5.7.1JP でしか動作確認していません。
動作には、gtkdialog0.8.3 xcur2png が必要です。
1)動作の保証はしません。
2)隠しファイルの操作をしています。
3)最悪の場合、Puppy Linux自体の不具合が起こります。
よって、スクリプトは読むだけ にしてください
以上宜しくお願いします。
- #!/bin/bash
- #mouse_setting053
- ########## Page1 ##########
- #設定ファイル.gtkrc.mineの存在を確認する
- if [ ! -e /root/.gtkrc.mine ];then
- touch /root/.gtkrc.mine
- echo "gtk-double-click-time=250" > /root/.gtkrc.mine
- echo "gtk-double-click-distance=5" >> /root/.gtkrc.mine
- fi
- #/root/.config/rox.sourceforge.net/ROX-Filer/Optionsから
- #bind_single_clickとbind_single_pinboardの値を切り出し、変数に代入
- rox_path="/root/.config/rox.sourceforge.net/ROX-Filer/Options"
- single_click_n=$(grep -n "bind_single_click" $rox_path)
- single_click_n=$(echo $single_click_n | cut -f1 -d ":")
- def_single_click_str=$(grep "bind_single_click" $rox_path)
- def_single_click_value=$(echo $def_single_click_str | cut -c 34)
- single_pinboard_n=$(grep -n "bind_single_pinboard" $rox_path)
- single_pinboard_n=$(echo $single_pinboard_n | cut -f1 -d ":")
- def_single_pinboard_str=$(grep "bind_single_pinboard" $rox_path)
- def_single_pinboard_value=$(echo $def_single_pinboard_str | cut -c 37)
- def_single_flag=`echo $(( $def_single_click_value + $def_single_pinboard_value ))`
- if [ "$def_single_flag" != 0 ]; then
- def_single_click_boolean="false"
- else
- def_single_click_boolean="true"
- fi
- #gtk-double-click-timeの値を.gtkrc.mineから切り出し、変数に代入
- def_time_str=$(grep "gtk-double-click-time" /root/.gtkrc.mine)
- if [ "$def_time_str" = "" ]; then
- echo "gtk-double-click-time=250" >> /root/.gtkrc.mine
- def_time_str=$(grep "gtk-double-click-time" /root/.gtkrc.mine)
- fi
- def_time_value=$(echo $def_time_str | cut -c 23-${#def_time_str})
- #gtk-double-click-distanceの値を.gtkrc/mineから切り出し、変数に代入
- def_distance_str=$(grep "gtk-double-click-distance" /root/.gtkrc.mine)
- if [ "$def_distance_str" = "" ]; then
- echo "gtk-double-click-distance=5" >> /root/.gtkrc.mine
- def_distance_str=$(grep "gtk-double-click-distance" /root/.gtkrc.mine)
- fi
- def_distance_value=$(echo $def_distance_str | cut -c 27-${#def_distance_str})
- ########## Page2 ##########
- #xset -qコマンドからマウス関連の数値を切り出し、変数に代入
- temp_xset=$(xset -q)
- def_acceleration_str=$(echo "$temp_xset" | grep "acceleration")
- def_acceleration_value_str=$(echo $def_acceleration_str | cut -f2 -d " ")
- def_acceleration_value=$(echo $def_acceleration_value_str | cut -f1 -d "/")
- dot_point=$(echo $(( ${#def_acceleration_value} - 1 )))
- front_value=$(echo "$def_acceleration_value" | cut -c 1-"$dot_point")
- bottom_value=$(echo "$def_acceleration_value" | cut -c ${#def_acceleration_value})
- def_acceleration_value=$front_value"."$bottom_value
- def_threshold_value=$(echo $def_acceleration_str | cut -f4 -d " ")
- def_x_parameter="m "$def_acceleration_value_str" "$def_threshold_value
- #設定ファイル/.xset.shの存在を確認する
- if [ ! -e /root/.xset.sh ]; then
- touch /root/.xset.sh
- chmod +x /root/.xset.sh
- echo "xset "$def_x_parameter > /root/.xset.sh
- fi
- ########## Page3 ##########
- default_png='
- cat <<'EOF'>> /tmp/ao_o10yan_temp/left_ptr_000.png
- /* XPM */
- static const char * xpm_data[] = {
- "16 16 2 1",
- " c None",
- ". c #000000000000",
- " ",
- ". ",
- ".. ",
- "... ",
- ".... ",
- "..... ",
- "...... ",
- "....... ",
- "........ ",
- "..... ",
- ".. .. ",
- ". .. ",
- " .. ",
- " .. ",
- " .. ",
- " "};
- EOF
- cat <<'EOF'>> /tmp/ao_o10yan_temp/hand_000.png
- /* XPM */
- static const char * xpm_data[] = {
- "16 16 2 1",
- " c None",
- ". c #000000000000",
- " ",
- " ",
- " ........ ",
- ". . ",
- " ...... . ",
- " . . ",
- " ... . ",
- " . . ",
- " ... . . ",
- " . . . ",
- " .. . . ",
- " .. . ",
- " . . . ",
- " . . ",
- " . . ",
- " . "};
- EOF
- cat <<'EOF'>> /tmp/ao_o10yan_temp/watch_000.png
- /* XPM */
- static const char * xpm_data[] = {
- "16 16 2 1",
- " c None",
- ". c #000000000000",
- " ........ ",
- " ........ ",
- " ........ ",
- " .......... ",
- " .. . .. ",
- ".. . .. ",
- ". . ...",
- ". ... ...",
- ". ... ...",
- ". . ...",
- ".. . .. ",
- " .. .. ",
- " .......... ",
- " ........ ",
- " ........ ",
- " ........ "};
- EOF
- '
- mkdir -p /tmp/ao_o10yan_temp
- #symlinkの存在を確認する
- if [ -e /root/.icons/default ]; then
- def_symlink=$(readlink /root/.icons/default)
- def_symlink_dir=$(echo $def_symlink | cut -f4 -d "/")
- else
- def_symlink="/root/.icons/default"
- def_symlink_dir="default"
- fi
- #lsコマンドで列挙して<list>の<item>を作成する
- temp_directories=$(ls /root/.icons/)
- #echo $temp_directories
- i_count=0
- items="<item>default</item>"
- if [ "$def_symlink_dir" = "default" ]; then
- def_selected_rwo=0
- eval "$default_png"
- fi
- for i in $temp_directories
- do
- if [ "$i" != "default" -a "$i" != "ROX" -a -e "/root/.icons/""$i""/cursors" ]; then
- i_count=$(( $i_count + 1 ))
- # echo $i_count$i
- if [ "$def_symlink_dir" = "$i" ]; then
- def_selected_row="$i_count"
- xcur2png -d /tmp/ao_o10yan_temp /root/.icons/"$i"/cursors/left_ptr
- xcur2png -d /tmp/ao_o10yan_temp /root/.icons/"$i"/cursors/hand
- xcur2png -d /tmp/ao_o10yan_temp /root/.icons/"$i"/cursors/watch
- fi
- items=$items"<item>"$i"</item>"
- fi
- # echo $items
- done
- ###############################################################################
- #OKボタンが押された時に呼び出す
- export ok_action='
- #前処理
- msg_flag1=0
- msg_flag2=0
- msg_flag3=0
- new_time_str="gtk-double-click-time="$TIME
- new_distance_str="gtk-double-click-distance="$DISTANCE
- #ダブルクリック、シングルクリックの切替設定
- if [ "'$def_single_click_boolean'" != "$CHKBOX" ]; then
- if [ "$CHKBOX" = "true" ]; then
- new_single_flag=0
- else
- new_single_flag=1
- fi
- #ファイラとピンボードの設定を一緒に行う
- #どちらかがシングル、どちらかがダブルと言う設定にはしない!!
- sed --in-place "'$single_click_n's/'$def_single_click_value'/$new_single_flag/" '$rox_path'
- sed --in-place "'$single_pinboard_n's/'$def_single_pinboard_value'/$new_single_flag/" '$rox_path'
- msg_flag1=1
- fi
- #ダブルクリック間隔、反応距離の設定(文字列整形した後の比較じゃなくてもいいのに)
- if [ "'$def_time_str'" != "$new_time_str" -o "'$def_distance_str'" != "$new_distance_str" ]; then
- sed --in-place --expression=s/'$def_time_str'/$new_time_str/ /root/.gtkrc.mine
- sed --in-place --expression=s/'$def_distance_str'/$new_distance_str/ /root/.gtkrc.mine
- msg_flag1=1
- fi
- #加速の設定
- if [ "'$def_acceleration_value'" != "$ACCELERATION" -o "'$def_threshold_value'" != "$THRESHOLD" ]; then
- new_acceleration=$(echo $ACCELERATION | sed "s/\.//")
- echo $new_acceleration
- new_x_parameter="m "$new_acceleration"/10 "$THRESHOLD
- echo $new_x_parameter
- xset $new_x_parameter
- sed --in-place "s:'$def_x_parameter':$new_x_parameter:" /root/.xset.sh
- msg_flag2=3
- fi
- #テーマの変更
- new_symlink="/root/.icons/"$DIRECTORY
- echo "def_symlink="'$def_symlink'
- echo "new_symlink="$new_symlink
- if [ "$new_symlink" != "/root/.icons/" -a "'$def_symlink'" != "$new_symlink" ]; then
- if [ -e /root/.icons/default ]; then
- rm /root/.icons/default
- fi
- if [ "'$def_symlink'" != "$new_symlink" ]; then
- if [ "$new_symlink" != "/root/.icons/default" ]; then
- ln -s $new_symlink /root/.icons/default
- fi
- msg_flag3=1
- fi
- fi
- #change_msg_flagにより、表示するメッセージを変える
- change_msg_flag=$(( $msg_flag1 + $msg_flag2 + $msg_flag3 ))
- if [ "$change_msg_flag" = "0" ]; then
- msg0="設定が変更されていません"
- msg1="何もせずに終了します"
- msg2="..."
- else
- msg0="マウスの設定を変更しました"
- msg1="Xサーバをリスタートして効果を確認してください"
- msg2="..."
- #加速調整はxのリスタートなしで反映される
- if [ "$change_msg_flag" = "3" ]; then
- msg1="..."
- fi
- if [ "$msg_flag2" = "3" ]; then
- msg2="加速の変更は、既に反映されています。確認してください"
- fi
- fi
- export SUB_DIALOG="
- <window title=\"Double Click Adjust\" width_request=\"400\" height_request=\"300\">
- <vbox>
- <text height-request=\"40\">
- <label>"$msg0"</label>
- </text>
- <text height-request=\"40\">
- <label>"$msg1"</label>
- </text>
- <text height-request=\"40\">
- <label>"$msg2"</label>
- </text>
- <button height-request=\"100\"><label>閉じる</label>
- <action type=\"exit\">exit</action>
- </button>
- </vbox>
- </window>"
- gtkdialog -c --program SUB_DIALOG
- '
- ###############################################################################
- #マウステーマプレビュー用
- export list_on_change='
- if [ "$DIRECTORY" = "default" ]; then
- if [ -e /tmp/ao_o10yan_temp/left_ptr_000.png ]; then
- rm /tmp/ao_o10yan_temp/left_ptr_000.png
- rm /tmp/ao_o10yan_temp/hand_000.png
- rm /tmp/ao_o10yan_temp/watch_000.png
- '$default_png'
- fi
- else
- temp_file_dir="/tmp/ao_o10yan_temp/"$DIRECTORY
- if [ "$temp_file_dir" != "/tmp/ao_o10yan_temp/" ]; then
- xcur2png -d /tmp/ao_o10yan_temp /root/.icons/"$DIRECTORY"/cursors/left_ptr
- xcur2png -d /tmp/ao_o10yan_temp /root/.icons/"$DIRECTORY"/cursors/hand
- xcur2png -d /tmp/ao_o10yan_temp /root/.icons/"$DIRECTORY"/cursors/watch
- fi
- fi
- '
- ###############################################################################
- #後始末
- export del_temp='
- rm -rf /tmp/ao_o10yan_temp
- rm -f ./left_ptr.conf
- rm -f ./hand.conf
- rm -f ./watch.conf
- '
- ###############################################################################
- export MAIN_DIALOG='
- <window title="マウスの設定" width_request="400" height_request="300">
- <vbox>
- <notebook labels="ダブルクリック|加速|テーマ">
- <vbox>
- <text>
- <label>ダブルクリック調整用スライダー</label>
- </text>
- <frame>
- <checkbox>
- <label>ダブルクリックを有効にする</label>
- <default>'$def_single_click_boolean'</default>
- <variable>CHKBOX</variable>
- <action>if true enable:TIME</action>
- <action>if false disable:TIME</action>
- <action>if true enable:DISTANCE</action>
- <action>if false disable:DISTANCE</action>
- </checkbox>
- </frame>
- <frame 間隔(ミリ秒)>
- <hscale range-min="250" range-max="2000" range-step="1">
- <default>'$def_time_value'</default>
- <variable>TIME</variable>
- <sensitive>'$def_single_click_boolean'</sensitive>
- </hscale>
- </frame>
- <frame 距離(ピクセル)>
- <hscale range-min="5" range-max="100" range-step="1">
- <default>'$def_distance_value'</default>
- <variable>DISTANCE</variable>
- <sensitive>'$def_single_click_boolean'</sensitive>
- </hscale>
- </frame>
- </vbox>
- <vbox>
- <text>
- <label>加速調整用スライダー</label>
- </text>
- <frame 加速(数値が大きい程、マウスが速く動きます)>
- <hscale range-min="1" range-max="10" range-step="0.1">
- <default>'$def_acceleration_value'</default>
- <variable>ACCELERATION</variable>
- </hscale>
- </frame>
- <frame 閾値(数値が小さい程、マウスが速く動きます)>
- <hscale range-max="20" range-min="1" range-step="1">
- <default>'$def_threshold_value'</default>
- <variable>THRESHOLD</variable>
- </hscale>
- </frame>
- </vbox>
- <vbox>
- <text>
- <label>マウスのテーマ切替</label>
- </text>
- <hbox>
- <list selected-row="'$def_selected_row'">
- <variable>DIRECTORY</variable>
- <width>150</width>
- <height>208</height>
- '$items'
- <action>bash -c "$list_on_change"</action>
- <action>refresh:LEFT_PTR</action>
- <action>refresh:HAND</action>
- <action>refresh:WATCH</action>
- </list>
- <frame プレビュー>
- <vbox>
- <pixmap space-fill="false" space-fill="false">
- <variable>LEFT_PTR</variable>
- <height>32</height>
- <input file>/tmp/ao_o10yan_temp/left_ptr_000.png</input>
- </pixmap>
- <pixmap space-fill="false" space-fill="false">
- <variable>HAND</variable>
- <height>32</height>
- <input file>/tmp/ao_o10yan_temp/hand_000.png</input>
- </pixmap>
- <pixmap space-fill="false" space-fill="false">
- <variable>WATCH</variable>
- <height>32</height>
- <input file>/tmp/ao_o10yan_temp/watch_000.png</input>
- </pixmap>
- </vbox>
- </frame>
- </hbox>
- </vbox>
- </notebook>
- <hbox>
- <button ok>
- <action>hide:MAIN_DIALOG</action>
- <action>bash -c "$ok_action"</action>
- <action>bash -c "$del_temp"</action>
- <action type="exit">exit</action>
- </button>
- <button cancel>
- <action>bash -c "$del_temp"</action>
- <action type="exit">exit</action>
- </button>
- </hbox>
- </vbox>
- </window>
- '
- gtkdialog -c --program MAIN_DIALOG
0 件のコメント :
コメントを投稿