[26580] in Source-Commits
/svn/athena r25634 - trunk/debathena/config/lightdm-config/debian
daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Wed Jul 11 16:27:29 2012
Date: Wed, 11 Jul 2012 16:27:27 -0400
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201207112027.q6BKRRIn002233@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Author: jdreed
Date: 2012-07-11 16:27:27 -0400 (Wed, 11 Jul 2012)
New Revision: 25634
Added:
trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.ini
Modified:
trunk/debathena/config/lightdm-config/debian/changelog
trunk/debathena/config/lightdm-config/debian/debathena-lightdm-config.install
trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter
trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.desktop
trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.ui
Log:
In lightdm-config:
* Display a MOTD on the login screen (Trac: #793)
* Add support for a config file
* Un-break logo animation, which was broken when the timer callback only
conditionally returned True
* Deal more gracefully with a missing background image
* Move greeter to /usr/lib/debathena-lightdm-config
Modified: trunk/debathena/config/lightdm-config/debian/changelog
===================================================================
--- trunk/debathena/config/lightdm-config/debian/changelog 2012-07-10 21:47:32 UTC (rev 25633)
+++ trunk/debathena/config/lightdm-config/debian/changelog 2012-07-11 20:27:27 UTC (rev 25634)
@@ -5,8 +5,14 @@
* Support basic accessibility options (read: a High Contrast Theme)
* Drop a separate panel window and actually implement a real menubar on
the background window for the top "panel"
+ * Display a MOTD on the login screen (Trac: #793)
+ * Add support for a config file
+ * Un-break logo animation, which was broken when the timer callback only
+ conditionally returned True
+ * Deal more gracefully with a missing background image
+ * Move greeter to /usr/lib/debathena-lightdm-config
- -- Jonathan Reed <jdreed@mit.edu> Tue, 10 Jul 2012 17:34:21 -0400
+ -- Jonathan Reed <jdreed@mit.edu> Wed, 11 Jul 2012 16:04:05 -0400
debathena-lightdm-config (1.3) unstable; urgency=low
Modified: trunk/debathena/config/lightdm-config/debian/debathena-lightdm-config.install
===================================================================
--- trunk/debathena/config/lightdm-config/debian/debathena-lightdm-config.install 2012-07-10 21:47:32 UTC (rev 25633)
+++ trunk/debathena/config/lightdm-config/debian/debathena-lightdm-config.install 2012-07-11 20:27:27 UTC (rev 25634)
@@ -1,5 +1,5 @@
debian/background.jpg usr/share/debathena-lightdm-config
-debian/debathena-lightdm-greeter usr/sbin
+debian/debathena-lightdm-greeter usr/lib/debathena-lightdm-config
debian/debathena-lightdm-greeter.ui usr/share/debathena-lightdm-config
debian/debathena.png usr/share/debathena-lightdm-config
debian/debathena1.png usr/share/debathena-lightdm-config
@@ -14,3 +14,4 @@
debian/lightdm.conf.debathena etc/lightdm
debian/debathena-lightdm-session-setup usr/lib/debathena-lightdm-config
debian/debathena-lightdm-session-cleanup usr/lib/debathena-lightdm-config
+debian/debathena-lightdm-greeter.ini etc
Modified: trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter
===================================================================
--- trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter 2012-07-10 21:47:32 UTC (rev 25633)
+++ trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter 2012-07-11 20:27:27 UTC (rev 25634)
@@ -16,22 +16,19 @@
import time
import os.path
from optparse import OptionParser
+import ConfigParser
+import io
-# TODO: ConfigParser
-MIN_UID=1
-NOLOGIN_FILE="/var/run/athena-nologin"
+KIOSK_LAUNCH_CMD="/usr/lib/debathena-kiosk/lightdm-launch-kiosk"
UI_FILE="/usr/share/debathena-lightdm-config/debathena-lightdm-greeter.ui"
-BG_IMG_FILE="/usr/share/debathena-lightdm-config/background.jpg"
-DEBATHENA_LOGO_FILES=["/usr/share/debathena-lightdm-config/debathena.png",
- "/usr/share/debathena-lightdm-config/debathena1.png",
- "/usr/share/debathena-lightdm-config/debathena2.png",
- "/usr/share/debathena-lightdm-config/debathena3.png",
- "/usr/share/debathena-lightdm-config/debathena4.png",
- "/usr/share/debathena-lightdm-config/debathena5.png",
- "/usr/share/debathena-lightdm-config/debathena6.png",
- "/usr/share/debathena-lightdm-config/debathena7.png",
- "/usr/share/debathena-lightdm-config/debathena8.png"]
-KIOSK_LAUNCH_CMD="/usr/lib/debathena-kiosk/lightdm-launch-kiosk"
+CONFIG_FILE="/etc/debathena-lightdm-greeter.ini"
+CONFIG_DEFAULTS={"minimum_uid": 1,
+ "nologin_file": "/var/run/athena-nologin",
+ "background_image": "/usr/share/debathena-lightdm-config/background.jpg",
+ "base_logo_file": "/usr/share/debathena-lightdm-config/debathena.png",
+ "extra_logo_frames": 8,
+ "motd_filename": "/afs/athena.mit.edu/system/config/motd/login.94",
+ "time_pedantry": "true"}
# See below, and then go cry.
_OBJS_TO_RENAME=["miShutdown", "miRestart", "miSuspend", "miHibernate"]
@@ -47,7 +44,7 @@
else:
print >> sys.stderr, "D: ", args[0]
- def __init__(self, options):
+ def __init__(self, options, config):
self.debugMode = options.debug
if self.debugMode:
# Sigh. In theory, APPMENU_DISPLAY_BOTH=1 should give me both
@@ -56,8 +53,35 @@
# QT_X11_NO_NATIVE_MENUBAR=1 is the KDE equivalent
self._debug("Attempting to turn off appmenu...")
os.putenv('UBUNTU_MENUPROXY', '')
- self.timePedantry = True
+ # Load the configuration, with type checking
+ try:
+ self.timePedantry = config.getboolean('Greeter', 'time_pedantry')
+ except:
+ self.timePedantry = config.getboolean('DEFAULT', 'time_pedantry')
+
+ try:
+ self.minimumUID = config.getint('Greeter', 'minimum_uid')
+ except:
+ self.minimumUID = config.getint('DEFAULT', 'minimum_uid')
+
+ try:
+ extraLogoFrames = config.getint('Greeter', 'extra_logo_frames')
+ except:
+ extraLogoFrames = config.getint('DEFAULT', 'extra_logo_frames')
+
+ baseFile = config.get('Greeter', 'base_logo_file')
+ self.logoFiles = [baseFile, ]
+ fileName, fileExt = os.path.splitext(baseFile)
+ if extraLogoFrames > 0:
+ for i in range(1,extraLogoFrames + 1):
+ self.logoFiles.append("%s%d%s" % (fileName, i, fileExt))
+
+ # No need to check these, they get checked later.
+ self.backgroundImageFile = config.get('Greeter', 'background_image')
+ self.motdFilename = config.get('Greeter', 'motd_filename')
+ self.nologinFile = config.get('Greeter', 'nologin_file')
+
# Set up and connect to the greeter
self.greeter = LightDM.Greeter()
self.greeter.connect("authentication-complete",
@@ -152,6 +176,7 @@
self.winLogin.show()
self.initBackgroundWindow()
self.initBrandingWindow()
+ self.initMotdWindow()
# Connect Gtk+ signal handlers
self.builder.connect_signals(handlers)
# GNOME 3 turns off button images by default. Turn it on
@@ -162,7 +187,7 @@
# Set a cursor for the root window, otherwise there isn't one
rw = Gdk.get_default_root_window()
rw.set_cursor(Gdk.Cursor(Gdk.CursorType.LEFT_PTR))
- self.noLoginMonitor = Gio.File.new_for_path(NOLOGIN_FILE).monitor_file(Gio.FileMonitorFlags.NONE, None)
+ self.noLoginMonitor = Gio.File.new_for_path(self.nologinFile).monitor_file(Gio.FileMonitorFlags.NONE, None)
self.noLoginMonitor.connect("changed", self._file_changed)
if not os.path.exists(KIOSK_LAUNCH_CMD):
@@ -170,13 +195,50 @@
# Setup the login window for first login
self.resetLoginWindow()
+ def initMotdWindow(self):
+ self.winMotd = self.builder.get_object("winMotd")
+ motdFile=None
+ try:
+ motdFile = open(self.motdFilename, "r")
+ except IOError, e:
+ print >>sys.stderr, "Can't open MOTD file %s: %s" % (self.motdFilename, str(e))
+ motdTxt = ''
+ # Avoid huge files messing up the greeter
+ # At most 10 lines of 80 characters per line
+ # Pango ellipsizing and geometry hints won't accomplish this
+ if motdFile:
+ lines=0
+ while lines <= 10:
+ line = motdFile.readline()
+ if not line:
+ break
+ lines += 1
+ if len(line) > 80:
+ line = line[:74] + " [...]\n"
+ motdTxt += line
+ if motdFile.read():
+ motdTxt += "[...]\n"
+ motdFile.close()
+ if motdTxt:
+ self.builder.get_object('lblMotd').set_markup(motdTxt.strip())
+ width, height = self.winMotd.get_size()
+ self.winMotd.set_gravity(Gdk.Gravity.SOUTH)
+ self.winMotd.move((self.screenSize[0] - width )/ 2, self.screenSize[1] - height - 10)
+ self.winMotd.show_all()
+
def initBackgroundWindow(self):
# The background image
self.winBg = self.builder.get_object("winBg")
self.imgBg = self.builder.get_object("imgBg")
- bg_pixbuf = GdkPixbuf.Pixbuf.new_from_file(BG_IMG_FILE)
- bg_scaled = bg_pixbuf.scale_simple(self.screenSize[0], self.screenSize[1], GdkPixbuf.InterpType.BILINEAR)
+ try:
+ bg_pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.backgroundImageFile)
+ bg_scaled = bg_pixbuf.scale_simple(self.screenSize[0], self.screenSize[1], GdkPixbuf.InterpType.BILINEAR)
+ except GLib.GError, e:
+ print >> sys.stderr, "Glib Error while loading background image:", e
+ # Just a plain black background
+ bg_scaled = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, False, 8, self.screenSize[0], self.screenSize[1])
self.imgBg.set_from_pixbuf(bg_scaled)
+
# The menubar
# LightDM checks with PolKit for the various "get_can_foo()" functions
# We call .set_name() here because of a GtkBuilder bug
@@ -358,7 +420,7 @@
self.startOver()
return True
# There's probably a better way
- if passwd.pw_uid < MIN_UID:
+ if passwd.pw_uid < self.minimumUID:
self.errDialog("Logging in as '%s' disallowed by configuation" % (currUser))
self.startOver()
return True
@@ -465,7 +527,8 @@
self.logo_pixbufs = []
num_pixbufs = 0
# Eyes go closed.
- for img in DEBATHENA_LOGO_FILES:
+
+ for img in self.logoFiles:
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_file(img)
self.logo_pixbufs.append(pixbuf.scale_simple(int(pixbuf.get_width() * logoScale), int(pixbuf.get_height() * logoScale), GdkPixbuf.InterpType.BILINEAR))
@@ -490,12 +553,11 @@
if not self.animate:
self._debug("Owl loading failed, ending update_owl timer")
return False
-
self.img_idx = (self.img_idx + 1) % self.animation_loop_frames
pixbuf = self.logo_pixbufs[self.img_idx]
if pixbuf is not None:
self.imgDebathena.set_from_pixbuf(pixbuf)
- return True
+ return True
def get_workstation_information(self):
@@ -517,10 +579,18 @@
parser.add_option("--debug", action="store_true", dest="debug")
parser.add_option("--ui", action="store", type="string",
default=UI_FILE, dest="ui_file")
+ parser.add_option("--cfg", action="store", type="string",
+ default=CONFIG_FILE, dest="config_file")
(options, args) = parser.parse_args()
+ config = ConfigParser.RawConfigParser(CONFIG_DEFAULTS)
+ # Hack to create a 'Greeter' section so that we can just use that
+ # in any calls
+ config.readfp(io.BytesIO("[Greeter]\n"))
+ config.read(options.config_file)
+ print >>sys.stderr, config.get('Greeter', 'time_PEDANTRY')
Gtk.init(None);
main_loop = GObject.MainLoop ()
- dagreeter = DebathenaGreeter(options)
+ dagreeter = DebathenaGreeter(options, config)
# Add a timeout for the owl animation
GObject.timeout_add(50, dagreeter.update_owl)
# Add a timeout for the clock in the panel
Modified: trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.desktop
===================================================================
--- trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.desktop 2012-07-10 21:47:32 UTC (rev 25633)
+++ trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.desktop 2012-07-11 20:27:27 UTC (rev 25634)
@@ -1,5 +1,5 @@
[Desktop Entry]
Name=Debathena Greeter
Comment=Debathena greeter for LightDM
-Exec=debathena-lightdm-greeter
+Exec=/usr/lib/debathena-lightdm-config/debathena-lightdm-greeter
Type=Application
Added: trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.ini
===================================================================
--- trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.ini (rev 0)
+++ trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.ini 2012-07-11 20:27:27 UTC (rev 25634)
@@ -0,0 +1,24 @@
+# Config file for debathena-lightdm-greeter
+# Any invalid values will be overridden with compile-time defaults
+[Greeter]
+# Minimum uid required to log in (integer)
+minimum_uid=1
+# File whose presence determines that logins should be disabled
+nologin_file=/var/run/athena-nologin
+# Background Image
+# Must be in a format supported by gdk_pixbuf_new_from_file()
+# Will be scaled to the background size using bilinear interpolation
+background_image=/usr/share/debathena-lightdm-config/background.jpg
+# Logo frames are constructed from the base file, and
+# extra_logo_frames additional files. Additional filenames are
+# constructed by adding an integer (1..extra_logo_frames) to the end
+# of the base portion of the filename. Extensions, if any, are
+# stripped off before adding the integer.
+# e.g. debathena.png, debathena1.png, debathena2.png, etc
+base_logo_file=/usr/share/debathena-lightdm-config/debathena.png
+extra_logo_frames=8
+# A MOTD file to display at the bottom of the greeter
+# Will be truncated to 10 lines, 80 characters per line
+motd_filename=/afs/athena.mit.edu/system/config/motd/login.94
+# Do you require your time to be measured in seconds? (boolean)
+time_pedantry=true
Modified: trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.ui
===================================================================
--- trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.ui 2012-07-10 21:47:32 UTC (rev 25633)
+++ trunk/debathena/config/lightdm-config/debian/debathena-lightdm-greeter.ui 2012-07-11 20:27:27 UTC (rev 25634)
@@ -469,4 +469,26 @@
</object>
</child>
</object>
+ <object class="GtkWindow" id="winMotd">
+ <property name="can_focus">False</property>
+ <property name="resizable">False</property>
+ <property name="skip_taskbar_hint">True</property>
+ <property name="skip_pager_hint">True</property>
+ <property name="accept_focus">False</property>
+ <property name="focus_on_map">False</property>
+ <property name="decorated">False</property>
+ <property name="has_resize_grip">False</property>
+ <child>
+ <object class="GtkLabel" id="lblMotd">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">5</property>
+ <property name="margin_right">5</property>
+ <property name="margin_top">5</property>
+ <property name="margin_bottom">5</property>
+ <property name="label" translatable="yes">[motd]</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
</interface>