Commits

Konstantine Rybnikov committed 9f960f6

enhancements

Comments (0)

Files changed (1)

         for key, val in self.ACTIONS_MAP.iteritems():
             print "%s -> %s" % (key, val)
         print '======================================='
-
+        
+        if 'kdm_gdm' in self.ACTIONS_MAP:
+            # let's write it only for kdm
+            if self.ACTIONS_MAP['kdm_gdm'] == 'kdm':
+                os.system(r"""echo "DISPLAYMANAGER=\"KDE\"" > /etc/sysconfig/desktop""")
+        
         if 'disable_ipv6' in self.ACTIONS_MAP:
             pass
-
+        
         if 'sudo_users' in self.ACTIONS_MAP:
-            pass
-
-        if 'autologin_users' in self.ACTIONS_MAP:
-            pass
-
+            for user in self.ACTIONS_MAP['sudo_users']:
+                os.system("cat >> /etc/sudoers.d/%(username)s << FOE\n"
+                          "%(username)s ALL=(ALL) ALL\n"
+                          "FOE" % dict(username=user))
+                os.system("chmod 0440 /etc/sudoers.d/%(username)s" % dict(username=user))
+        
+        if 'autologin_user' in self.ACTIONS_MAP:
+            # let's say that there is a value for kdm_gdm
+            if 'kdm_gdm' in self.ACTIONS_MAP:
+                if self.ACTIONS_MAP['kdm_gdm'] == 'gdm':
+                    user = self.ACTIONS_MAP['autologin_user']
+                    os.system("cat >> /etc/gdm/custom.conf << FOE\n"
+                              "[daemon]\n"
+                              "TimedLoginEnable=true\n"
+                              "TimedLogin=%(username)s\n"
+                              "TimedLoginDelay=10\n"
+                              "FOE" % dict(username=user))
+                elif self.ACTIONS_MAP['kdm_gdm'] == 'kdm':
+                    user = self.ACTIONS_MAP['autologin_user']
+                    os.system(r"sed -i 's/#AutoLoginEnable=true/AutoLoginEnable=true/' /etc/kde/kdm/kdmrc")
+                    os.system(r"sed -i 's/#AutoLoginUser=fred/AutoLoginUser=%(username)s/' /etc/kde/kdm/kdmrc" % dict(username=user))
+        
         if 'c_m_backspace' in self.ACTIONS_MAP:
             pass
-
-        if 'kdm_gdm' in self.ACTIONS_MAP:
-            pass
         
         return RESULT_SUCCESS
-
+    
     def callb_radio(self, widget, data=None):
         if widget.get_active():
             self.ACTIONS_MAP[data['key']] = data['val']
         #
         # Autologin
         #
-        self.ACTIONS_MAP['autologin_users'] = []
+        #self.ACTIONS_MAP['autologin_user'] = None
+        
+        # def autologin_callb(widget, data=None):
+        #     return autologin_and_sudo_callb(self.ACTIONS_MAP['autologin_user'], widget, data)
+        
+        autologin_box = gtk.VBox()
+        autologin_box.pack_start(gtk.Label(_("Autologin user:")))
+        
+        def change_autologin_user(widget):
+            def get_active_text(combobox):
+                model = combobox.get_model()
+                active = combobox.get_active()
+                if active < 0:
+                    return None
+                return model[active][0]
+            
+            if widget.get_active() > 0:
+                self.ACTIONS_MAP['autologin_user'] = get_active_text(widget)
+            else:
+                if 'autologin_user' in self.ACTIONS_MAP:
+                    del self.ACTIONS_MAP['autologin_user']
+        
+        alog_opt = gtk.combo_box_new_text()
+        alog_opt.append_text(_('Choose user:'))
+        for user in users:
+            alog_opt.append_text(user)
+        alog_opt.connect('changed', change_autologin_user)
+        alog_opt.set_active(0)
+        
+        autologin_box.pack_start(alog_opt)
+        hbox.pack_start(autologin_box)
+        
+        #
+        # Sudo
+        #
+        self.ACTIONS_MAP['sudo_users'] = []
         
         def autologin_and_sudo_callb(var, widget, data=None):
             if widget.get_active():
                 if data['user'] in var:
                     del var[var.index(data['user'])]
         
-        def autologin_callb(widget, data=None):
-            return autologin_and_sudo_callb(self.ACTIONS_MAP['autologin_users'], widget, data)
-        
-        autologin_box = gtk.VBox()
-        autologin_box.pack_start(gtk.Label(_("Use autologin for users:")))
-        AUTOLOGIN_MAP = {}
-        for user in users:
-            checkbox = gtk.CheckButton(label=user)
-            autologin_box.pack_start(checkbox)
-            checkbox.connect("toggled", autologin_callb, {'user': user})
-        hbox.pack_start(autologin_box)
-        
-        #
-        # Sudo
-        #
-        self.ACTIONS_MAP['sudo_users'] = []
-        
         def sudo_callb(widget, data=None):
             return autologin_and_sudo_callb(self.ACTIONS_MAP['sudo_users'], widget, data)