pandora-scripts: make op_nubmode.py update nubs.state directly
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_nubmode.py
index 7b858ff..3086271 100755 (executable)
@@ -6,6 +6,7 @@ import sys
 import gtk
 import time
 import optparse
+import shutil
 
 # ================================================================
 
@@ -15,7 +16,7 @@ PROFILES = '/etc/pandora/conf/nub_profiles.conf'
 # Shell command to reset nub: 3-0066 = left-nub, 3-0067 = right-nub
 # apparently they are linked and resetting one resets both.
 #RESET_CMD = 'echo %i > /sys/bus/i2c/drivers/vsense/3-00%i/reset'
-RESET_CMD = "sudo ./reset_nubs.sh"
+RESET_CMD = "sudo /usr/pandora/scripts/reset_nubs.sh"
 
 # Valid values for mode setting
 MODES = ("mouse", "mbuttons", "scroll", "absolute")
@@ -289,6 +290,10 @@ class NubConfig(object):
 
     def on_WriteNubConfig_clicked(self, widget, *data):
         StoreProc(self.model.settings)
+        shutil.copyfile("/etc/pandora/conf/nubs.state", "/tmp/nubs.state");
+        os.system("sed -i -e '1c\%s' /tmp/nubs.state" % self.model.settings['mode0'])
+        os.system("sed -i -e '7c\%s' /tmp/nubs.state" % self.model.settings['mode1'])
+        shutil.copyfile("/tmp/nubs.state", "/etc/pandora/conf/nubs.state");
         self.Notify("Nub configuration updated.")
 
     def on_SaveProfile_clicked(self, widget, *data):