op_power: handle screensaver too
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_nubmode.sh
1 #!/bin/bash
2 # Released under the GPL
3 # Nub-Settings, v1.1, written by Michael Mrozek aka EvilDragon 2010
4 # This scripts allows you to configure all parameters of the Pandora-Nubs. The left and right nub can both be configured individually.
5
6 while mainsel=$(zenity --title="Nub-Configuration" --width="380" --height="200" --list --column "id" --column "Please select" --hide-column=1 --text="What do you want to do?" "leftnub" "Configure left nub" "rightnub" "Configure right nub" "default" "Restore default settings for both nubs"); do
7
8 case $mainsel in
9   "leftnub")
10
11    while leftsel=$(zenity --title="Configure Left Nub" --width="430" --height="300" --list --column "id" --column "Please select" --hide-column=1 --text="What do you want to do?" "nub0mode" "Change Nub mode" "nub0msense" "Change the mouse speed" "nub0ssense" "Change the scroll sensitivity" "nub0rate" "Change the scroll speed" "nub0thres" "Change the mouse button sensitivity" "nub0reset" "Reset Nub"); do
12    case $leftsel in
13
14     "nub0mode")
15         if nubm=$(zenity --height=300 --list --title="Select Nub-mode for the left nub" --text="Please select the mode 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
16
17         echo $nubm > /proc/pandora/nub0/mode
18         fi;;
19
20     "nub0msense")
21         curmsense=$(cat /proc/pandora/nub0/mouse_sensitivity)
22         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)
23         echo $newmsense > /proc/pandora/nub0/mouse_sensitivity
24         ;;
25     
26     "nub0ssense")
27         curssense=$(cat /proc/pandora/nub0/scrollx_sensitivity)
28         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)
29         echo $newssense > /proc/pandora/nub0/scrollx_sensitivity
30         curssense=$(cat /proc/pandora/nub0/scrolly_sensitivity)
31         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)
32         echo $newssense > /proc/pandora/nub0/scrolly_sensitivity
33         ;;
34
35     "nub0rate")
36         currate=$(cat /proc/pandora/nub0/scroll_rate)
37         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)
38         echo $newrate > /proc/pandora/nub0/scroll_rate
39         ;;
40      
41     "nub0thres")
42         curthres=$(cat /proc/pandora/nub0/mbutton_threshold)
43         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)
44         echo $newthres > /proc/pandora/nub0/mbutton_threshold
45         ;;
46  
47     "nub0reset")
48         echo 1 > /sys/bus/i2c/drivers/vsense/3-0066/reset
49         sleep 1
50         echo 0 > /sys/bus/i2c/drivers/vsense/3-0066/reset
51         curmode=$(cat /proc/pandora/nub0/mode)
52         echo mouse > /proc/pandora/nub0/mode
53         while ! zenity --question --title="Resetted left nub" --text="The left nub has been resetted.\nPlease try to move the mouse cursor\nto test if it is working properly." --ok-label="Working properly" --cancel-label="Reset again"; do
54         echo 1 > /sys/bus/i2c/drivers/vsense/3-0066/reset
55         sleep 1
56         echo 0 > /sys/bus/i2c/drivers/vsense/3-0066/reset      
57         done
58         echo $curmode > /proc/pandora/nub0/mode
59         ;;
60      esac
61    done
62   ;;
63   
64   "rightnub")
65   
66    while rightsel=$(zenity --title="Configure Right Nub" --width="430" --height="300" --list --column "id" --column "Please select" --hide-column=1 --text="What do you want to do?" "nub1mode" "Change Nub mode" "nub1msense" "Change the mouse speed" "nub1ssense" "Change the scroll sensitivity" "nub1rate" "Change the scroll speed" "nub1thres" "Change the mouse button sensitivity" "nub1reset" "Reset Nub"); do
67    case $rightsel in
68   
69     "nub1mode")
70         if nubm=$(zenity --height=300 --list --title="Select Nub-mode for the right nub" --text="Please select the mode 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
71
72         echo $nubm > /proc/pandora/nub1/mode
73         fi;;
74
75     "nub1msense")
76         curmsense=$(cat /proc/pandora/nub1/mouse_sensitivity)
77         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)
78         echo $newmsense > /proc/pandora/nub1/mouse_sensitivity
79         ;;
80     
81     "nub1ssense")
82         curssense=$(cat /proc/pandora/nub1/scrollx_sensitivity)
83         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)
84         echo $newssense > /proc/pandora/nub1/scrollx_sensitivity
85         curssense=$(cat /proc/pandora/nub1/scrolly_sensitivity)
86         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)
87         echo $newssense > /proc/pandora/nub1/scrolly_sensitivity
88         ;;
89
90     "nub1rate")
91         currate=$(cat /proc/pandora/nub1/scroll_rate)
92         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)
93         echo $newrate > /proc/pandora/nub1/scroll_rate
94         ;;
95      
96     "nub1thres")
97         curthres=$(cat /proc/pandora/nub1/mbutton_threshold)
98         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)
99         echo $newthres > /proc/pandora/nub1/mbutton_threshold
100         ;;
101
102     "nub1reset")
103         echo 1 > /sys/bus/i2c/drivers/vsense/3-0067/reset
104         sleep 1
105         echo 0 > /sys/bus/i2c/drivers/vsense/3-0067/reset
106         curmode=$(cat /proc/pandora/nub1/mode)
107         echo mouse > /proc/pandora/nub1/mode
108         while ! zenity --question --title="Resetted right nub" --text="The right nub has been resetted.\nPlease try to move the mouse cursor\nto test if it is working properly." --ok-label="Working properly" --cancel-label="Reset again"; do
109         echo 1 > /sys/bus/i2c/drivers/vsense/3-0067/reset
110         sleep 1
111         echo 0 > /sys/bus/i2c/drivers/vsense/3-0067/reset      
112         done
113         echo $curmode > /proc/pandora/nub1/mode
114         ;;
115      esac
116    done
117    ;;
118
119 "default")
120       echo mouse > /proc/pandora/nub0/mode
121       echo 150 > /proc/pandora/nub0/mouse_sensitivity
122       echo 7 > /proc/pandora/nub0/scrollx_sensitivity
123       echo 7 > /proc/pandora/nub0/scrolly_sensitivity
124       echo 20 > /proc/pandora/nub0/scroll_rate
125       echo 20 > /proc/pandora/nub0/mbutton_threshold
126       echo mbuttons > /proc/pandora/nub1/mode
127       echo 150 > /proc/pandora/nub1/mouse_sensitivity
128       echo 7 > /proc/pandora/nub1/scrollx_sensitivity
129       echo 7 > /proc/pandora/nub1/scrolly_sensitivity
130       echo 20 > /proc/pandora/nub1/scroll_rate
131       echo 20 > /proc/pandora/nub1/mbutton_threshold
132       zenity --info --title="Settings restored" --text "The default nub-settings have been restored." --timeout 6
133     ;;
134 esac
135 done