source: trunk/debathena/debathena/kiosk/gdm-launch-kiosk @ 24213

Revision 24213, 2.4 KB checked in by rbasch, 15 years ago (diff)
In debathena-kiosk: * Add a launcher GUI for the new gdm login window. (Trac: #431) * Disable the tabs bar for Firefox 3.5. * Move non-executables to /usr/share/debathena-kiosk.
  • Property svn:executable set to *
RevLine 
[24213]1#!/usr/bin/python -Wall
2
3import gtk
4import gtk.glade
5import gobject
6import time
7import os
8import sys
9import subprocess
10from optparse import OptionParser
11
12gladeFile = "/usr/share/debathena-kiosk/gdm-launch-kiosk.glade"
13launchCommand = "/usr/lib/debathena-kiosk/launch-kiosk"
14
15class Kiosk:
16    def __init__(self):
17        try:
18            self.xml = gtk.glade.XML(gladeFile)
19        except:
20            print "Failed to create Glade XML object."
21            sys.exit(1)
22        self.kioskWindow = self.xml.get_widget('KioskWindow')
23        self.kioskDialog = self.xml.get_widget('KioskDialog')
24        self.xml.signal_autoconnect(self)
25        # Turn off all window decorations for the login screen.
26        self.kioskWindow.set_decorated(False)
27        self.kioskDialog.set_decorated(False)
28        # Position the window near the bottom of the screen, in the center.
29        self.kioskWindow.set_gravity(gtk.gdk.GRAVITY_SOUTH)
30        width, height = self.kioskWindow.get_size()
31        self.kioskWindow.move((gtk.gdk.screen_width() - width) / 2,
32                              gtk.gdk.screen_height() - height - 80)
33        self.kioskWindow.show_all()
34
35    def kioskButton_on_click(self, button):
36        self.kioskDialog.show()
37
38    def kioskDialogResponseHandler(self, dialog, response_id):
39        if response_id == 1:
40            self.launch()
41        self.kioskDialog.hide()
42
43    def launch(self):
44        pid = os.fork()
45        if pid == 0:
46            # Start a new session.
47            os.setsid();
48            # Fork another child to launch the command.
49            pid = os.fork()
50            if pid == 0:
51                # Here in the second child, exec the command.
52                try:
53                    os.execlp("sudo", "sudo", "-n", launchCommand)
54                except OSError, e:
55                    print "error: Could not run %s as root: %s" % (launchCommand, e.strerror)
56                    os._exit(255)
57            else:
58                # The first child exits immediately.
59                os._exit(0)
60        else:
61            # Here in the parent: wait for the first child to exit.
62            (pid, status) = os.waitpid(pid, 0)
63            if status != 0:
64                print "error launching command, status %d" % status
65
66
67def main():
68    if not os.access(gladeFile, os.R_OK):
69        print 'error: Unable to read glade file "' + gladeFile + '"'
70        sys.exit(1)
71    Kiosk()
72    gtk.main()
73
74if __name__ == '__main__':
75    main()
Note: See TracBrowser for help on using the repository browser.