op_nubmode.sh: Small bugfix
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_nubmode.sh
1 #!/bin/bash
2
3 while mainsel=$(zenity --title="Nub-Configuration" --width="430" --height="400" --list --column "id" --column "Please select" --hide-column=1 --text="What do you want to do?" "nub0mode" "Change the mode for the left nub" "nub0msense" "Change the mouse speed for the left nub" "nub0ssense" "Change the scroll sensitivity for the left nub" "nub0rate" "Change the scroll speed for the left nub" "nub0thres" "Change the mouse button sensitivity for the left nub" "nub1mode" "Change the mode for the right nub" "nub1msense" "Change the mouse speed for the right nub" "nub1ssense" "Change the scroll sensitivity for the right nub" "nub1rate" "Change the scroll speed for the right nub" "nub1thres" "Change the mouse button sensitivity for the right nub" "default" "Restore default settings for both nubs"); do
4
5 case $mainsel in
6
7   "nub0mode")
8       if nubm=$(zenity --height=300 --list --title="Select Nub-mode for the left nub" --text="Please select the modus for the left nub.\n\nNote: This can affect running programs.\nSome programs also may change the nub mode themselves."  --column "return" --hide-column=1 --column "Nub Mode" "mouse" "Use the nub as mouse" "mbuttons" "Use the nub for mousebuttons" "scroll" "Use the nub for scrolling" "absolute" "Use the nub as joystick") ; then
9
10       echo $nubm > /proc/pandora/nub0/mode
11       fi;;
12
13   "nub0msense")
14       curmsense=$(cat /proc/pandora/nub0/mouse_sensitivity)
15       newmsense=$(zenity --scale --text "Set speed for left nub mouse.\nThe default value is 150. Higher value means faster mouse." --min-value=50 --max-value=300 --value=$curmsense --step 1)
16       echo $newmsense > /proc/pandora/nub0/mouse_sensitivity
17       ;;
18     
19   "nub0ssense")
20       curssense=$(cat /proc/pandora/nub0/scrollx_sensitivity)
21       newssense=$(zenity --scale --text "Set the scroll sensitivity for the left nub for the X-Axis.\nThe default value is 7. Higher value means more sensitive.\nA negative value inverts the axis." --min-value=-32 --max-value=32 --value=$curssense --step 1)
22       echo $newssense > /proc/pandora/nub0/scrollx_sensitivity
23       curssense=$(cat /proc/pandora/nub0/scrolly_sensitivity)
24       newssense=$(zenity --scale --text "Set the scroll sensitivity for the left nub for the Y-Axis.\nThe default value is 7. Higher value means more sensitive.\nA negative value inverts the axis." --min-value=-32 --max-value=32 --value=$curssense --step 1)
25       echo $newssense > /proc/pandora/nub0/scrolly_sensitivity
26       ;;
27
28   "nub0rate")
29       currate=$(cat /proc/pandora/nub0/scroll_rate)
30       newrate=$(zenity --scale --text "Set the scroll speed for the left nub.\nThe default value is 20. Higher value means more sensitive." --min-value=1 --max-value=40 --value=$currate --step 1)
31       echo $newrate > /proc/pandora/nub0/scroll_rate
32       ;;
33      
34   "nub0thres")
35       curthres=$(cat /proc/pandora/nub0/mbutton_threshold)
36       newthres=$(zenity --scale --text "Change the mousebutton sensitivity for the left nub.\nThe default value is 20.\nThe higher the value the higher you need to move the nub" --min-value=1 --max-value=40 --value=$curthres --step 1)
37       echo $newthres > /proc/pandora/nub0/mbutton_threshold
38       ;;
39
40   "nub1mode")
41       if nubm=$(zenity --height=300 --list --title="Select Nub-mode for the right nub" --text="Please select the modus for the right nub.\n\nNote: This can affect running programs.\nSome programs also may change the nub mode themselves."  --column "return" --hide-column=1 --column "Nub Mode" "mouse" "Use the nub as mouse" "mbuttons" "Use the nub for mousebuttons" "scroll" "Use the nub for scrolling" "absolute" "Use the nub as joystick") ; then
42
43       echo $nubm > /proc/pandora/nub1/mode
44       fi;;
45
46   "nub1msense")
47       curmsense=$(cat /proc/pandora/nub1/mouse_sensitivity)
48       newmsense=$(zenity --scale --text "Set speed for right nub mouse.\nThe default value is 150. Higher value means faster mouse." --min-value=50 --max-value=300 --value=$curmsense --step 1)
49       echo $newmsense > /proc/pandora/nub1/mouse_sensitivity
50       ;;
51     
52   "nub1ssense")
53        curssense=$(cat /proc/pandora/nub1/scrollx_sensitivity)
54       newssense=$(zenity --scale --text "Set the scroll sensitivity for the right nub for the X-Axis.\nThe default value is 7. Higher value means more sensitive.\nA negative value inverts the axis." --min-value=-32 --max-value=32 --value=$curssense --step 1)
55       echo $newssense > /proc/pandora/nub1/scrollx_sensitivity
56       curssense=$(cat /proc/pandora/nub1/scrolly_sensitivity)
57       newssense=$(zenity --scale --text "Set the scroll sensitivity for the right nub for the Y-Axis.\nThe default value is 7. Higher value means more sensitive.\nA negative value inverts the axis." --min-value=-32 --max-value=32 --value=$curssense --step 1)
58       echo $newssense > /proc/pandora/nub1/scrolly_sensitivity
59       ;;
60
61   "nub1rate")
62       currate=$(cat /proc/pandora/nub1/scroll_rate)
63       newrate=$(zenity --scale --text "Set the scroll speed for the right nub.\nThe default value is 20. Higher value means more sensitive." --min-value=1 --max-value=40 --value=$currate --step 1)
64       echo $newrate > /proc/pandora/nub1/scroll_rate
65       ;;
66      
67   "nub1thres")
68       curthres=$(cat /proc/pandora/nub1/mbutton_threshold)
69       newthres=$(zenity --scale --text "Change the mousebutton sensitivity for the right nub.\nThe default value is 20.\nThe higher the value the higher you need to move the nub" --min-value=1 --max-value=40 --value=$curthres --step 1)
70       echo $newthres > /proc/pandora/nub1/mbutton_threshold
71       ;;
72   "default")
73       echo mouse > /proc/pandora/nub0/mode
74       echo 150 > /proc/pandora/nub0/mouse_sensitivity
75       echo 7 > /proc/pandora/nub0/scrollx_sensitivity
76       echo 7 > /proc/pandora/nub0/scrolly_sensitivity
77       echo 20 > /proc/pandora/nub0/scroll_rate
78       echo 20 > /proc/pandora/nub0/mbutton_threshold
79       echo mbuttons > /proc/pandora/nub1/mode
80       echo 150 > /proc/pandora/nub1/mouse_sensitivity
81       echo 7 > /proc/pandora/nub1/scrollx_sensitivity
82       echo 7 > /proc/pandora/nub1/scrolly_sensitivity
83       echo 20 > /proc/pandora/nub1/scroll_rate
84       echo 20 > /proc/pandora/nub1/mbutton_threshold
85       zenity --info --title="Settings restored" --text "The default nub-settings have been restored." --timeout 6
86     ;;
87 esac
88 done