Permalink
Browse files

Policykit

  • Loading branch information...
1 parent b684d2d commit 86ccef128861c04d57bfe45198819f51ebc2fe78 @Nano77 committed Oct 11, 2011
Showing with 489 additions and 210 deletions.
  1. +3 −0 README.md
  2. +17 −0 apps.nano77.gdm3setup.conf
  3. +25 −0 apps.nano77.gdm3setup.policy
  4. +5 −0 apps.nano77.gdm3setup.service
  5. +125 −0 gdm3setup-daemon.py
  6. +211 −128 gdm3setup.py
  7. +4 −6 gdmlogin.py
  8. +1 −2 get_gdm.sh
  9. +0 −6 get_gdm_helper.sh
  10. +0 −66 set_gdm.py
  11. +84 −2 set_gdm.sh
  12. +14 −0 start-gdm3setup-daemon
View
3 README.md
@@ -37,5 +37,8 @@ You need to run `sudo chown -R gdm:gdm /var/lib/gdm/`
And use the DEB package from : [https://github.com/Nano77/various/tree/master/deb]()
+Debian (experimental)
+------
+You can use the "debian" DEB package from : [https://github.com/Nano77/various/tree/master/deb]()
View
17 apps.nano77.gdm3setup.conf
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <type>system</type>
+ <!-- Only root can own the service -->
+ <policy user="root">
+ <allow own="apps.nano77.gdm3setup"/>
+ </policy>
+
+ <!-- Allow anyone to invoke methods on the interfaces -->
+ <policy context="default">
+ <allow send_destination="apps.nano77.gdm3setup"/>
+ <allow send_interface="apps.nano77.gdm3setup"/>
+ </policy>
+</busconfig>
+
View
25 apps.nano77.gdm3setup.policy
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC
+ "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
+<policyconfig>
+ <vendor>Nano77</vendor>
+ <vendor_url>http://github.com/Nano77</vendor_url>
+ <icon_name>stock_person</icon_name>
+
+
+ <action id="apps.nano77.gdm3setup.set">
+ <description>GDM3 Setup</description>
+ <message>Authentication is required to change GDM3 parameters</message>
+ <message xml:lang="fr">L'authentification est nécéssaire pour changer les paramétres de GDM3</message>
+ <message xml:lang="de_DE">Authentifizierung erforderlichzur änderung von einstellungen der GDM3</message>
+ <message xml:lang="it_IT">L'autenticazione è necessaria.per modificare impostazioni di GDM3</message>
+ <message xml:lang="es_ES">La autenticación es necesaria para cambiar la Configuratión de GDM3</message>
+ <defaults>
+ <allow_any>no</allow_any>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ </action>
+
+</policyconfig>
View
5 apps.nano77.gdm3setup.service
@@ -0,0 +1,5 @@
+[D-BUS Service]
+Name=apps.nano77.gdm3setup
+Exec=/usr/bin/start-gdm3setup-daemon
+User=root
+
View
125 gdm3setup-daemon.py
@@ -0,0 +1,125 @@
+#! /usr/bin/python2
+# -*- coding: <utf-8> -*-
+
+import dbus
+import dbus.service
+from dbus.mainloop.glib import DBusGMainLoop
+import subprocess
+import os
+from gi.repository import GObject
+
+
+subprocess.call("echo $LANG",shell=True)
+LANG = os.environ['LANG']
+
+loop = GObject.MainLoop()
+
+def GetValue(target,default):
+ targetfile = "/etc/gdm/custom.conf"
+ ofile = open(targetfile,'r')
+ lines = ofile.readlines()
+ ofile.close()
+
+ value = ""
+ for i in range(len(lines)) :
+ line = lines[i].strip()
+ if line[0:len(target)+1]==target+"=" :
+ value = line[len(target)+1:len(line)]
+ break
+ else:
+ value=default
+ return value
+
+def str_to_bool(state) :
+ if state.capitalize()=="True" or state=="1":
+ b_state = True
+ else :
+ b_state = False
+
+ return b_state
+
+class GDM3SetupDBusService(dbus.service.Object):
+ def __init__(self):
+ bus=dbus.SystemBus()
+ bus_name = dbus.service.BusName('apps.nano77.gdm3setup', bus)
+ dbus.service.Object.__init__(self, bus_name, '/apps/nano77/gdm3setup')
+
+ def policykit_test(self,sender,connexion,action):
+ bus = dbus.SystemBus()
+ proxy_dbus = connexion.get_object('org.freedesktop.DBus','/org/freedesktop/DBus/Bus', False)
+ dbus_info = dbus.Interface(proxy_dbus,'org.freedesktop.DBus')
+ sender_pid = dbus_info.GetConnectionUnixProcessID(sender)
+ proxy_policykit = bus.get_object('org.freedesktop.PolicyKit1','/org/freedesktop/PolicyKit1/Authority',False)
+ policykit_authority = dbus.Interface(proxy_policykit,'org.freedesktop.PolicyKit1.Authority')
+
+ Subject = ('unix-process', {'pid': dbus.UInt32(sender_pid, variant_level=1),
+ 'start-time': dbus.UInt64(0, variant_level=1)})
+ (is_authorized,is_challenge,details) = policykit_authority.CheckAuthorization(Subject, action, {'': ''}, dbus.UInt32(1), '') #, timeout=5000
+ return is_authorized
+
+ @dbus.service.method('apps.nano77.gdm3setup.set',in_signature='ss', out_signature='s',
+ sender_keyword='sender', connection_keyword='connexion')
+ def SetUI(self,name,value,sender=None, connexion=None):
+ if self.policykit_test(sender,connexion,'apps.nano77.gdm3setup.set') :
+ subprocess.call(unicode("su - gdm -s /bin/bash -c 'LANG="+LANG+" set_gdm.sh -n "+name+" -v "+'"'+value+'"'+"'"),shell=True)
+ return "OK"
+ else :
+ return "ERROR : YOU ARE NOT ALLOWED !"
+
+ @dbus.service.method('apps.nano77.gdm3setup.get','','as',sender_keyword='sender', connection_keyword='connexion')
+ def GetUI(self,sender=None, connexion=None):
+ subprocess.call("su - gdm -s /bin/sh -c 'LANG="+LANG+" get_gdm.sh'",shell=True)
+ ifile = open("/tmp/GET_GDM",'r')
+ settings = ifile.readlines()
+ ifile.close()
+ os.remove("/tmp/GET_GDM")
+ return settings
+
+ @dbus.service.method('apps.nano77.gdm3setup.set','bsbi','s',sender_keyword='sender', connection_keyword='connexion')
+ def SetAutoLogin(self,AUTOLOGIN,USERNAME,TIMED,TIMED_TIME,sender=None, connexion=None):
+ if self.policykit_test(sender,connexion,'apps.nano77.gdm3setup.set') :
+ if AUTOLOGIN :
+ if TIMED :
+ subprocess.call("gdmlogin.py -a -u "+USERNAME+" -d "+str(int(TIMED_TIME)),shell=True)
+ else:
+ subprocess.call("gdmlogin.py -a -u "+USERNAME,shell=True)
+ else:
+ subprocess.call("gdmlogin.py -m",shell=True)
+ return "OK"
+ else :
+ return "ERROR : YOU ARE NOT ALLOWED !"
+
+
+ @dbus.service.method('apps.nano77.gdm3setup.get','','bsbi',sender_keyword='sender', connection_keyword='connexion')
+ def GetAutoLogin(self,sender=None, connexion=None):
+
+ AutomaticLoginEnable = str_to_bool(GetValue("AutomaticLoginEnable","False"))
+ AutomaticLogin = GetValue("AutomaticLogin","")
+ TimedLoginEnable = str_to_bool(GetValue("TimedLoginEnable","False"))
+ TimedLogin = GetValue("TimedLogin","")
+ TimedLoginDelay = GetValue("TimedLoginDelay","30")
+
+ AUTOLOGIN = AutomaticLoginEnable or TimedLoginEnable
+ TIMED = TimedLoginEnable
+ TIMED_TIME = int(TimedLoginDelay)
+
+ if AutomaticLoginEnable:
+ USERNAME = AutomaticLogin
+
+ if TimedLoginEnable:
+ USERNAME = TimedLogin
+
+ if not (AutomaticLoginEnable or TimedLoginEnable ):
+ USERNAME = ""
+
+
+ return AUTOLOGIN,USERNAME,TIMED,TIMED_TIME
+
+ @dbus.service.method('apps.nano77.gdm3setup',sender_keyword='sender', connection_keyword='connexion')
+ def stop(self,sender=None, connexion=None):
+ loop.quit()
+
+
+DBusGMainLoop(set_as_default=True)
+myservice = GDM3SetupDBusService()
+loop.run()
View
339 gdm3setup.py
@@ -1,29 +1,86 @@
-#! /usr/bin/env python2
+#! /usr/bin/python2
+# -*- coding: utf-8 -*-
import os
import stat
import time
import subprocess
from gi.repository import Gtk
-
+from gi.repository import GObject
import gettext
-
import getpass
+import dbus
+
+
gettext.install("gdm3setup")
+print os.environ['LANG']
-GTK3_THEME = "Zukitwo"
-ICON_THEME = "Faenza-Dark"
-CURSOR_THEME = "Adwaita"
-WALLPAPER = "/usr/share/backgrounds/gnome/Terraform-blue.jpg"
-LOGO_ICON = "distributor-logo"
+GTK3_THEME = u"Zukitwo"
+ICON_THEME = u"Faenza-Dark"
+CURSOR_THEME = u"Adwaita"
+WALLPAPER = u"/usr/share/backgrounds/gnome/Terraform-blue.jpg"
+LOGO_ICON = u"distributor-logo"
USER_LIST = False
MENU_BTN = False
BANNER = False
-BANNER_TEXT = "Welcome"
+BANNER_TEXT = u"Welcome"
+
+#-----------------------------------------------
+class WallpaperChooserClass(Gtk.Bin):
+
+ def __init__(self):
+ Gtk.Bin.__init__(self)
+ gettext.install("gtk30")
+ self.Button = Gtk.Button(_('(None)'))
+ gettext.install("gdm3setup")
+ self.Image = Gtk.Image()
+ self.Image.set_from_icon_name("fileopen",Gtk.IconSize.SMALL_TOOLBAR)
+ self.Button.set_image(self.Image)
+ self.Button.set_image_position(Gtk.PositionType.RIGHT)
+ self.Align = self.Button.get_children()[0]
+ self.Button.remove(self.Align)
+ self.Box = self.Align.get_children()[0]
+ self.Align.remove(self.Box)
+ self.Label = self.Box.get_children()[0]
+ self.Image = self.Box.get_children()[1]
+ self.Button.add(self.Box)
+ self.Box.set_child_packing(self.Label,False,False,0,Gtk.PackType.START)
+ self.Box.set_child_packing(self.Image,False,False,0,Gtk.PackType.END)
+ self.Sepparator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
+ self.Box.pack_end(self.Sepparator, False, False, 8)
+ GObject.signal_new("file-changed", WallpaperChooserClass, GObject.SIGNAL_RUN_FIRST,GObject.TYPE_NONE, ())
+ self.Filename = ""
+ self.Button.connect("clicked",self._Clicked)
+
+ def Get_Filename(self):
+ return self.Filename
+
+ def Set_Filename(self,filename=""):
+ self.Filename = filename
+ self.Label.set_label(os.path.basename(filename))
+ self.emit("file-changed")
+
+ def _Clicked(self,e) :
+ gettext.install("gtk30")
+ self.FileChooserDialog = Gtk.FileChooserDialog(title=_("Select a File"),action=Gtk.FileChooserAction.OPEN,buttons=(Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL,Gtk.STOCK_OPEN,Gtk.ResponseType.ACCEPT))
+ gettext.install("gdm3setup")
+ filter = Gtk.FileFilter()
+ filter.add_pixbuf_formats()
+ filter.set_name('Image')
+ self.FileChooserDialog.add_filter(filter)
+ result = self.FileChooserDialog.run()
+ if result==Gtk.ResponseType.ACCEPT :
+ self.Filename = self.FileChooserDialog.get_filename()
+ self.Label.set_label(os.path.basename(self.Filename))
+ self.FileChooserDialog.destroy()
+ self.emit("file-changed")
+ else:
+ self.FileChooserDialog.destroy()
#-----------------------------------------------
def mainwin_close(event):
+ StopDaemon()
Gtk.main_quit()
def load_gtk3_list():
@@ -43,20 +100,25 @@ def load_icon_list():
ComboBox_cursor.append_text(lst_icons[i])
else :
ComboBox_icon.append_text(lst_icons[i])
-
+
def get_setting(name,data):
- value = None
for line in data:
+ line = unicode(line)
if line[0:len(name)+1]==name+"=":
value = line[len(name)+1:len(line)-1]
+ break
+ return value
- return value
+def unquote(value):
+ if value[0:1] == "'" and value[len(value)-1:len(value)] == "'" :
+ value = value[1:len(value)-1]
+ return value
def str_to_bool(state) :
if state.capitalize()=="True" :
b_state = True
else :
- b_state = False
+ b_state = False
return b_state
@@ -71,107 +133,134 @@ def get_iter(model,target):
iter_test = model.iter_next(iter_test)
return target_iter
-def set_gdm(e):
- subprocess.call( \
- 'gksu -D "GDM3Setup" "su - gdm -s /bin/sh -c '+"'"+'set_gdm.sh'+ \
- ' --GTK3_THEME='+GTK3_THEME+ \
- ' --ICON_THEME='+ICON_THEME+ \
- ' --CURSOR_THEME='+CURSOR_THEME+ \
- ' --WALLPAPER='+WALLPAPER+ \
- ' --LOGO_ICON='+LOGO_ICON+ \
- ' --USER_LIST='+str(USER_LIST)+ \
- ' --MENU_BTN='+str(MENU_BTN)+ \
- ' --BANNER='+str(BANNER)+ \
- ' --BANNER_TEXT='+BANNER_TEXT \
- +"'"+'"'
- ,shell=True)
-
-def get_gdm(e):
- p = subprocess.call('gksu -D "GDM3Setup" get_gdm_helper.sh '+getpass.getuser(),shell=True)
-
- file3 = open("/tmp/GET_GDM",'r')
- settings = file3.readlines()
- file3.close()
- os.remove("/tmp/GET_GDM")
-
- #---------------
- global WALLPAPER
-
- ComboBox_gtk.set_active_iter(get_iter(ComboBox_gtk.get_model(),get_setting("GTK",settings)))
+def set_gdm(name,value):
+ if SetUI(name,value)=="OK" :
+ return True
+ else :
+ return False
+
+def get_gdm():
+ settings = list(GetUI())
+ global GTK3_THEME,ICON_THEME,CURSOR_THEME,WALLPAPER,LOGO_ICON,USER_LIST,MENU_BTN,BANNER,BANNER_TEXT
+ GTK3_THEME = get_setting("GTK",settings)
+ ICON_THEME = get_setting("ICON",settings)
+ CURSOR_THEME = get_setting("CURSOR",settings)
BKG = get_setting("BKG",settings)
WALLPAPER = BKG[8:len(BKG)-1]
- FCB_bkg.set_filename(WALLPAPER)
- ComboBox_icon.set_active_iter(get_iter(ComboBox_icon.get_model(),get_setting("ICON",settings)))
- ComboBox_cursor.set_active_iter(get_iter(ComboBox_cursor.get_model(),get_setting("CURSOR",settings)))
- Entry_logo.set_text(get_setting("LOGO",settings))
- CheckButton_banner.set_active(str_to_bool(get_setting("BANNER",settings)))
- Entry_banner_text.set_text(get_setting("BANNER_TEXT",settings))
- CheckButton_user.set_active(str_to_bool(get_setting("USER_LIST",settings)))
- CheckButton_restart.set_active(str_to_bool(get_setting("BTN",settings)))
-
-
-def status_update():
- if(ComboBox_gtk.get_active_text()!=None and ComboBox_icon.get_active_text()!=None \
- and ComboBox_cursor.get_active_text()!=None and Entry_logo.get_text()!="" and FCB_bkg.get_filename()!=None):
- BTN_apply.set_sensitive(True)
- else:
- BTN_apply.set_sensitive(False)
+ LOGO_ICON = get_setting("LOGO",settings)
+ USER_LIST = str_to_bool(get_setting("USER_LIST",settings))
+ MENU_BTN = str_to_bool( get_setting("BTN" ,settings))
+ BANNER = str_to_bool(get_setting("BANNER",settings))
+ BANNER_TEXT = get_setting("BANNER_TEXT",settings)
+
+ ComboBox_gtk.set_active_iter(get_iter(ComboBox_gtk.get_model(),GTK3_THEME))
+ WallpaperChooser.Set_Filename(WALLPAPER)
+ ComboBox_icon.set_active_iter(get_iter(ComboBox_icon.get_model(),ICON_THEME))
+ ComboBox_cursor.set_active_iter(get_iter(ComboBox_cursor.get_model(),CURSOR_THEME))
+ Entry_logo.set_text(LOGO_ICON)
+ CheckButton_banner.set_active(BANNER)
+ Entry_banner_text.set_text(BANNER_TEXT)
+ CheckButton_user.set_active(USER_LIST)
+ CheckButton_restart.set_active(MENU_BTN)
+ Entry_banner_text.set_sensitive(BANNER)
def gtk3_theme_changed(e):
global GTK3_THEME
- GTK3_THEME = ComboBox_gtk.get_active_text()
- print "GTK3 Theme Changed : " + GTK3_THEME
- status_update()
-
-def wallpaper_changed(e):
+ gtk_theme = unicode(ComboBox_gtk.get_active_text(),'UTF_8')
+ if gtk_theme!=unquote(GTK3_THEME) :
+ if set_gdm('GTK_THEME',gtk_theme) :
+ GTK3_THEME = gtk_theme
+ print("GTK3 Theme Changed : " + GTK3_THEME)
+ else :
+ ComboBox_gtk.set_active_iter(get_iter(ComboBox_gtk.get_model(),GTK3_THEME))
+
+def wallpaper_filechanged(e):
global WALLPAPER
- WALLPAPER = FCB_bkg.get_filename()
- print "Wallpaper Changed : " + WALLPAPER
- status_update()
+ wallpaper = unicode(WallpaperChooser.Get_Filename(),'UTF_8')
+ if WALLPAPER != wallpaper :
+ if set_gdm('WALLPAPER',wallpaper) :
+ WALLPAPER = wallpaper
+ print("Wallpaper Changed : " + WALLPAPER)
+ else :
+ WallpaperChooser.Set_Filename(WALLPAPER)
def icon_theme_changed(e):
global ICON_THEME
- ICON_THEME = ComboBox_icon.get_active_text()
- print "Icon Theme Changed : " + ICON_THEME
- status_update()
+ icon_theme = unicode(ComboBox_icon.get_active_text(),'UTF_8')
+ if unquote(ICON_THEME) != icon_theme:
+ if set_gdm('ICON_THEME',icon_theme) :
+ ICON_THEME = icon_theme
+ print ("Icon Theme Changed : " + ICON_THEME)
+ else:
+ ComboBox_icon.set_active_iter(get_iter(ComboBox_icon.get_model(),ICON_THEME))
def cursor_theme_changed(e):
global CURSOR_THEME
- CURSOR_THEME = ComboBox_cursor.get_active_text()
- print "Cursor Theme Changed : " + CURSOR_THEME
- status_update()
+ cursor_theme = unicode(ComboBox_cursor.get_active_text(),'UTF_8')
+ if unquote(CURSOR_THEME) != cursor_theme:
+ if set_gdm('CURSOR_THEME',cursor_theme) :
+ CURSOR_THEME = cursor_theme
+ print ("Cursor Theme Changed : " + CURSOR_THEME)
+ else :
+ ComboBox_cursor.set_active_iter(get_iter(ComboBox_cursor.get_model(),CURSOR_THEME))
def logo_icon_changed(e):
global LOGO_ICON
- LOGO_ICON = Entry_logo.get_text()
- print "Logo Icon Changed : " + LOGO_ICON
- status_update()
+ logo_icon = unicode(Entry_logo.get_text(),'UTF_8')
+ if LOGO_ICON != logo_icon :
+ if set_gdm('LOGO_ICON',logo_icon) :
+ LOGO_ICON = logo_icon
+ print ("Logo Icon Changed : " + LOGO_ICON)
+ else:
+ Entry_logo.set_text(LOGO_ICON)
def banner_toggled(e):
global BANNER
- BANNER = CheckButton_banner.get_active()
- print "Banner Changed : " + str(BANNER)
- if BANNER :
- Entry_banner_text.set_sensitive(True)
- else:
- Entry_banner_text.set_sensitive(False)
+ banner = CheckButton_banner.get_active()
+ if banner!=BANNER :
+ if set_gdm('BANNER',str(banner)) :
+ BANNER = banner
+ print ("Banner Changed : " + str(BANNER))
+
+ if BANNER :
+ Entry_banner_text.set_sensitive(True)
+ else:
+ Entry_banner_text.set_sensitive(False)
+ else:
+ CheckButton_banner.set_active(BANNER)
def banner_text_changed(e):
global BANNER_TEXT
- BANNER_TEXT = Entry_banner_text.get_text()
- print "Banner Text Changed : " + BANNER_TEXT
- status_update()
+ banner_text = unicode(Entry_banner_text.get_text(),'UTF_8')
+ if banner_text!=BANNER_TEXT :
+ if set_gdm('BANNER_TEXT',banner_text) :
+ BANNER_TEXT = banner_text
+ print ("Banner Text Changed : " + BANNER_TEXT)
+ else :
+ Entry_banner_text.set_text(BANNER_TEXT)
def user_list_toggled(e):
global USER_LIST
- USER_LIST = CheckButton_user.get_active()
- print "User List Changed : " + str(USER_LIST)
-
+ user_list = CheckButton_user.get_active()
+ if USER_LIST != user_list :
+ if set_gdm('USER_LIST',str(user_list)) :
+ USER_LIST = user_list
+ print ("User List Changed : " + str(USER_LIST))
+ else:
+ CheckButton_user.set_active(USER_LIST)
def menu_btn_toggled(e):
global MENU_BTN
- MENU_BTN = CheckButton_restart.get_active()
- print "Menu Btn Changed : " + str(MENU_BTN)
+ menu_btn = CheckButton_restart.get_active()
+ if MENU_BTN != menu_btn :
+ if set_gdm('MENU_BTN',str(menu_btn)) :
+ MENU_BTN = menu_btn
+ print ("Menu Btn Changed : " + str(MENU_BTN))
+ else:
+ CheckButton_restart.set_active(MENU_BTN)
+
+
+#--------------------------------------------------------
def autologin_clicked(e):
win_autologin.show_all()
@@ -191,13 +280,13 @@ def AutoLogin_toggled(e):
if Entry_username.get_text()!="" or not CheckButton_AutoLogin.get_active():
HBox_AutoLogin_Apply.set_sensitive(True)
else:
- HBox_AutoLogin_Apply.set_sensitive(False)
+ HBox_AutoLogin_Apply.set_sensitive(False)
def username_changed(e):
if Entry_username.get_text()!="":
HBox_AutoLogin_Apply.set_sensitive(True)
else:
- HBox_AutoLogin_Apply.set_sensitive(False)
+ HBox_AutoLogin_Apply.set_sensitive(False)
def Delay_toggled(e):
if CheckButton_Delay.get_active():
@@ -211,16 +300,17 @@ def AutoLogin_Apply_clicked(e):
TIMED_TIME = SpinButton_Delay.get_value()
USERNAME = Entry_username.get_text()
- if AUTOLOGIN :
- if TIMED :
- subprocess.call("gksu -D 'GDM3Setup' 'gdmlogin.py -a -u "+USERNAME+" -d "+str(int(TIMED_TIME))+"'",shell=True)
- else:
- subprocess.call("gksu -D 'GDM3Setup' 'gdmlogin.py -a -u "+USERNAME+"'",shell=True)
- else:
- subprocess.call("gksu -D 'GDM3Setup' 'gdmlogin.py -m'",shell=True)
+ SetAutoLogin(AUTOLOGIN,USERNAME,TIMED,int(TIMED_TIME))
win_autologin.hide()
+def get_autologin():
+ AUTOLOGIN,USERNAME,TIMED,TIMED_TIME = GetAutoLogin()
+ CheckButton_AutoLogin.set_active(AUTOLOGIN)
+ CheckButton_Delay.set_active(TIMED)
+ SpinButton_Delay.set_value(TIMED_TIME)
+ Entry_username.set_text(USERNAME)
+
#-----------------------------------------------
mainwin = Gtk.Window()
mainwin.connect("destroy",mainwin_close)
@@ -247,70 +337,53 @@ def AutoLogin_Apply_clicked(e):
VBox_Left.pack_start(Label_gtk, False, True, 0)
ComboBox_gtk = Gtk.ComboBoxText.new()
-ComboBox_gtk.connect("changed",gtk3_theme_changed)
VBox_Right.pack_start(ComboBox_gtk, False, True, 0)
Label_bkg = Gtk.Label(_("Wallpaper"))
Label_bkg.set_alignment(0,0.5)
VBox_Left.pack_start(Label_bkg, False, True, 0)
-gettext.install("gtk30")
-FCB_bkg = Gtk.FileChooserButton.new(_('Select a File'),Gtk.FileChooserAction.OPEN)
-FCB_bkg.set_current_folder('/usr/share/backgrounds/gnome/')
-filter_bkg = Gtk.FileFilter()
-filter_bkg.add_pixbuf_formats()
-filter_bkg.set_name('All images')
-FCB_bkg.add_filter(filter_bkg)
-FCB_bkg.connect("file-set",wallpaper_changed)
-VBox_Right.pack_start(FCB_bkg, False, True, 0)
-gettext.install("gdm3setup")
+WallpaperChooser = WallpaperChooserClass()
+VBox_Right.pack_start(WallpaperChooser.Button, False, True, 0)
Label_icon = Gtk.Label(_("Icon theme"))
Label_icon.set_alignment(0,0.5)
VBox_Left.pack_start(Label_icon, False, True, 0)
ComboBox_icon = Gtk.ComboBoxText.new()
-ComboBox_icon.connect("changed",icon_theme_changed)
VBox_Right.pack_start(ComboBox_icon, False, True, 0)
Label_cursor = Gtk.Label(_("Cursor theme"))
Label_cursor.set_alignment(0,0.5)
VBox_Left.pack_start(Label_cursor, False, True, 0)
ComboBox_cursor = Gtk.ComboBoxText.new()
-ComboBox_cursor.connect("changed",cursor_theme_changed)
VBox_Right.pack_start(ComboBox_cursor, False, True, 0)
Label_logo = Gtk.Label(_("Logo Icon"))
Label_logo.set_alignment(0,0.5)
VBox_Left.pack_start(Label_logo, False, True, 0)
-Entry_logo = Gtk.Entry()
-Entry_logo.connect("changed",logo_icon_changed)
+Entry_logo = Gtk.Entry()
VBox_Right.pack_start(Entry_logo, False, True, 0)
CheckButton_banner = Gtk.CheckButton(label=_("Enable Banner"),use_underline=True)
-CheckButton_banner.connect("toggled",banner_toggled)
VBox_Left.pack_start(CheckButton_banner, False, True, 0)
-Entry_banner_text = Gtk.Entry()
+Entry_banner_text = Gtk.Entry()
Entry_banner_text.set_sensitive(False)
-Entry_banner_text.set_text(BANNER_TEXT)
-Entry_banner_text.connect("changed",banner_text_changed)
VBox_Right.pack_start(Entry_banner_text, False, True, 0)
HBox_user = Gtk.HBox.new(True, 0)
VBox_Main.pack_start(HBox_user, False, True, 0)
CheckButton_user = Gtk.CheckButton(label=_("Disable User List"),use_underline=True)
-CheckButton_user.connect("toggled",user_list_toggled)
HBox_user.pack_start(CheckButton_user, False, True, 0)
HBox_restart = Gtk.HBox.new(True, 0)
VBox_Main.pack_start(HBox_restart, False, True, 0)
CheckButton_restart = Gtk.CheckButton(label=_("Disable Restart Buttons"),use_underline=True)
-CheckButton_restart.connect("toggled",menu_btn_toggled)
HBox_restart.pack_start(CheckButton_restart, False, True, 0)
HBox9 = Gtk.HBox.new(False, 8)
@@ -320,15 +393,6 @@ def AutoLogin_Apply_clicked(e):
BTN_autologin.connect("clicked",autologin_clicked)
HBox9.pack_start(BTN_autologin, False, False, 0)
-BTN_apply = Gtk.Button(_('Apply'))
-BTN_apply.connect("clicked",set_gdm)
-BTN_apply.set_sensitive(False)
-HBox9.pack_end(BTN_apply, False, False, 0)
-
-BTN_Load = Gtk.Button(_('Load'))
-BTN_Load.connect("clicked",get_gdm)
-HBox9.pack_end(BTN_Load, False, False, 0)
-
#-------
win_autologin = Gtk.Window()
win_autologin.connect("delete-event",Close_AutoLogin)
@@ -378,11 +442,30 @@ def AutoLogin_Apply_clicked(e):
BTN_AutoLogin_Apply.connect("clicked",AutoLogin_Apply_clicked)
HBox_AutoLogin_Apply.pack_start(BTN_AutoLogin_Apply, True, False, 0)
-
-
mainwin.show_all()
+bus = dbus.SystemBus()
+gdm3setup = bus.get_object('apps.nano77.gdm3setup','/apps/nano77/gdm3setup')
+SetUI = gdm3setup.get_dbus_method('SetUI','apps.nano77.gdm3setup.set')
+GetUI = gdm3setup.get_dbus_method('GetUI','apps.nano77.gdm3setup.get')
+SetAutoLogin = gdm3setup.get_dbus_method('SetAutoLogin','apps.nano77.gdm3setup.set')
+GetAutoLogin = gdm3setup.get_dbus_method('GetAutoLogin','apps.nano77.gdm3setup.get')
+StopDaemon = gdm3setup.get_dbus_method('stop', 'apps.nano77.gdm3setup')
+
load_gtk3_list()
load_icon_list()
+get_gdm()
+get_autologin()
+
+WallpaperChooser.connect("file-changed",wallpaper_filechanged)
+ComboBox_icon.connect("changed",icon_theme_changed)
+ComboBox_cursor.connect("changed",cursor_theme_changed)
+Entry_logo.connect("changed",logo_icon_changed)
+ComboBox_gtk.connect("changed",gtk3_theme_changed)
+CheckButton_banner.connect("toggled",banner_toggled)
+Entry_banner_text.connect("changed",banner_text_changed)
+CheckButton_user.connect("toggled",user_list_toggled)
+CheckButton_restart.connect("toggled",menu_btn_toggled)
+
Gtk.main()
View
10 gdmlogin.py
@@ -4,7 +4,6 @@
import sys
import getopt
-
CONF_PATH = "/etc/gdm/custom.conf"
#---
@@ -85,7 +84,7 @@ def SetValue(targetfile,targetsection,target,value):
if not os.path.isfile(CONF_PATH) :
-
+
ofile = open(CONF_PATH,'w')
ofile.write("# GDM configuration storage\n\n\
[daemon]\n\n\
@@ -96,7 +95,6 @@ def SetValue(targetfile,targetsection,target,value):
[debug]\n\n\
")
ofile.close()
-
if (MANUALLOGIN and AUTOLOGIN) or (AUTOLOGIN and not USER) or (not AUTOLOGIN and not MANUALLOGIN):
if MANUALLOGIN and AUTOLOGIN :
@@ -111,7 +109,7 @@ def SetValue(targetfile,targetsection,target,value):
-d :\tDelay before autologin in second"
else:
- if AUTOLOGIN :
+ if AUTOLOGIN :
if AUTOLOGIN and not TIMED :
print "AutomaticLoginEnable=1"
print "AutomaticLogin="+USER_NAME
@@ -127,11 +125,11 @@ def SetValue(targetfile,targetsection,target,value):
SetValue(CONF_PATH,"daemon","AutomaticLoginEnable","0")
SetValue(CONF_PATH,"daemon","TimedLoginEnable","1")
SetValue(CONF_PATH,"daemon","TimedLogin",USER_NAME)
- SetValue(CONF_PATH,"daemon","TimedLoginDelay",TIMED_TIME)
+ SetValue(CONF_PATH,"daemon","TimedLoginDelay",TIMED_TIME)
else:
print "AutomaticLoginEnable=0"
print "TimedLoginEnable=0"
- SetValue(CONF_PATH,"daemon","AutomaticLoginEnable","0")
+ SetValue(CONF_PATH,"daemon","AutomaticLoginEnable","0")
SetValue(CONF_PATH,"daemon","TimedLoginEnable","0")
else:
print >> sys.stderr, "Must Be Run as root"
View
3 get_gdm.sh
@@ -1,8 +1,7 @@
-#! /bin/sh
+#! /bin/bash
#
#
-`dbus-launch | sed "s/^/export /"`
echo -n "GTK=" > /tmp/GET_GDM
gsettings get org.gnome.desktop.interface gtk-theme >> /tmp/GET_GDM
echo -n "ICON=" >> /tmp/GET_GDM
View
6 get_gdm_helper.sh
@@ -1,6 +0,0 @@
-#! /bin/sh
-#
-#
-
-su - gdm -s /bin/sh -c get_gdm.sh
-chown $* /tmp/GET_GDM
View
66 set_gdm.py
@@ -1,66 +0,0 @@
-#! /usr/bin/env python2
-
-import sys
-import getopt
-import os
-import subprocess
-
-
-
-args = sys.argv[1:]
-
-try:
- optlist, optargs = getopt.getopt(args,'x',['GTK3_THEME=','ICON_THEME=','CURSOR_THEME=','WALLPAPER=','LOGO_ICON=','USER_LIST=','MENU_BTN=','BANNER=','BANNER_TEXT='])
-except getopt.GetoptError, err:
- print str(err)
- #usage()
- sys.exit(2)
-
-
-for o,a in optlist:
- if o == "--GTK3_THEME":
- print "GTK3_THEME = " + a
- GTK3_THEME=a
- elif o == "--ICON_THEME":
- print "ICON_THEME = " + a
- ICON_THEME = a
- elif o == "--CURSOR_THEME":
- print "CURSOR_THEME = " + a
- CURSOR_THEME = a
- elif o == "--WALLPAPER":
- print "WALLPAPER = " + a
- WALLPAPER = a
- elif o == "--LOGO_ICON":
- print "LOGO_ICON = " + a
- LOGO_ICON = a
- elif o == "--USER_LIST":
- print "USER_LIST = " + a
- USER_LIST = a
- elif o == "--MENU_BTN":
- print "MENU_BTN = " + a
- MENU_BTN = a
- elif o == "--BANNER":
- print "BANNER = " + a
- BANNER = a
- elif o == "--BANNER_TEXT":
- print "BANNER_TEXT = " + a
- BANNER_TEXT = a
- else:
- print "???"
-
-
-
-subprocess.call("gsettings set org.gnome.desktop.interface gtk-theme "+GTK3_THEME,shell=True)
-subprocess.call("gsettings set org.gnome.desktop.interface icon-theme "+ICON_THEME,shell=True)
-subprocess.call("gsettings set org.gnome.desktop.interface cursor-theme "+CURSOR_THEME ,shell=True)
-subprocess.call("gsettings set org.gnome.desktop.background picture-uri 'file://"+WALLPAPER+"'",shell=True)
-
-subprocess.call("gconftool-2 --type string --set /desktop/gnome/peripherals/mouse/cursor_theme '"+CURSOR_THEME+"'",shell=True)
-subprocess.call("gconftool-2 --type string --set /apps/gdm/simple-greeter/logo_icon_name '"+LOGO_ICON+"'",shell=True)
-subprocess.call("gconftool-2 --type bool --set /apps/gdm/simple-greeter/disable_user_list "+USER_LIST,shell=True)
-subprocess.call("gconftool-2 --type bool --set /apps/gdm/simple-greeter/disable_restart_buttons "+MENU_BTN,shell=True)
-subprocess.call("gconftool-2 --type bool --set /apps/gdm/simple-greeter/banner_message_enable "+BANNER,shell=True)
-subprocess.call("gconftool-2 --type string --set /apps/gdm/simple-greeter/banner_message_text "+BANNER_TEXT,shell=True)
-subprocess.call("gconftool-2 --type string --set /apps/gdm/simple-greeter/banner_message_text_nochooser "+BANNER_TEXT,shell=True)
-
-
View
86 set_gdm.sh
@@ -1,8 +1,90 @@
-#! /bin/sh
+#! /bin/bash
#
#
`dbus-launch | sed "s/^/export /"`
-set_gdm.py $*
+echo "|$LANG|"
+parameter_name=""
+parameter_value=""
+
+function print_help {
+ echo " using :"
+ echo " set_gdm.sh -n {name} -v {value}, to set a gdm3 parameter "
+ echo " or set_gdm.sh -h, to print this the help"
+}
+
+echo ""
+while getopts "v:n:h" opt; do
+ case $opt in
+ n)
+ parameter_name=$OPTARG
+ ;;
+ v)
+ parameter_value=$OPTARG
+ ;;
+ h)
+ print_help
+ exit
+ ;;
+ \?)
+ print_help
+ exit
+ ;;
+ esac
+done
+
+if [ "$parameter_name" = "" ] || [ "$parameter_value" = "" ]
+then
+ echo Syntax Error
+
+else
+
+ case $parameter_name in
+ GTK_THEME)
+ echo "$parameter_name = $parameter_value"
+ gsettings set org.gnome.desktop.interface gtk-theme "$parameter_value"
+ ;;
+ ICON_THEME)
+ echo "$parameter_name = $parameter_value"
+ gsettings set org.gnome.desktop.interface icon-theme "$parameter_value"
+ ;;
+ CURSOR_THEME)
+ echo "$parameter_name = $parameter_value"
+ gsettings set org.gnome.desktop.interface cursor-theme
+ gconftool-2 --type string --set /desktop/gnome/peripherals/mouse/cursor_theme "$parameter_value"
+ ;;
+ WALLPAPER)
+ echo "$parameter_name = $parameter_value"
+ gsettings set org.gnome.desktop.background picture-uri "'file://"$parameter_value"'"
+ ;;
+ LOGO_ICON)
+ echo "$parameter_name = $parameter_value"
+ gconftool-2 --type string --set /apps/gdm/simple-greeter/logo_icon_name "$parameter_value"
+ ;;
+ USER_LIST)
+ gconftool-2 --type bool --set /apps/gdm/simple-greeter/disable_user_list $parameter_value
+ ;;
+ MENU_BTN)
+ echo "$parameter_name = $parameter_value"
+ gconftool-2 --type bool --set /apps/gdm/simple-greeter/disable_restart_buttons $parameter_value
+ ;;
+ BANNER)
+ echo "$parameter_name = $parameter_value"
+ gconftool-2 --type bool --set /apps/gdm/simple-greeter/banner_message_enable $parameter_value
+ ;;
+ BANNER_TEXT)
+ echo "$parameter_name = $parameter_value"
+ gconftool-2 --type string --set /apps/gdm/simple-greeter/banner_message_text "$parameter_value"
+ gconftool-2 --type string --set /apps/gdm/simple-greeter/banner_message_text_nochooser "$parameter_value"
+ ;;
+ *)
+ echo "Uknown GDM3 Parameter !"
+ ;;
+ esac
+
+fi
+
+
+kill -SIGTERM $DBUS_SESSION_BUS_PID
View
14 start-gdm3setup-daemon
@@ -0,0 +1,14 @@
+#! /bin/bash
+#
+#
+. /etc/rc.conf 2>/dev/null
+
+if [ "$LOCALE" != "" ]
+then
+ export LANG="$LOCALE"
+else
+ export LANG="en_US.utf8"
+fi
+
+gdm3setup-daemon.py &
+

0 comments on commit 86ccef1

Please sign in to comment.