Before you login you must answer me these questions 3?

The following is tested with Ubuntu 13.04 and system's Python, using Gtk bindings (PyGobject).

Here is one way a bit dirty though and it needs more investigation:

Summary

  • Add a .desktop file at /usr/share/xsessions we will name it custom

  • Add an .xsession file at the user in question (your kids) we will name their user as kid

  • Create the Python GUI application for the math puzzle and run it from .xsession, we will name it as puzzle.py

Details

  • sudo vi /usr/share/xsessions/custom.desktop

Add the following in the file:

[Desktop Entry]
Name=Custom
Comment=This session logs you into your managed desktop environment
Exec=/etc/X11/Xsession
X-Ubuntu-Gettext-Domain=gnome-session-3.0
  • vi /home/kid/.xsession

Add the following in the file:

#!/bin/bash
lightdm &
exec /home/kid/puzzle.py
  • vi /home/kid/puzzle.py

Add the following in the file:

#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
import random
from gi.repository import Gtk


#----------------------------------------------------------------------
class PuzzleWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="Math Puzzle", resizable=False)

        super(PuzzleWindow, self).set_position(Gtk.WindowPosition.CENTER)
        super(PuzzleWindow, self).maximize()

        self.a_number = random.randint(1, 5)
        self.b_number = random.randint(1, 5)
        self.result = self.a_number + self.b_number

        self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)

        self.label = Gtk.Label("What is the sum of the numbers bellow?")
        self.number_label = Gtk.Label("{num_a} + {num_b}".format(
            num_a=self.a_number, num_b=self.b_number))

        self.entry = Gtk.Entry()
        self.button = Gtk.Button(label="Check answer!")
        self.button.connect("clicked", self.on_button_clicked)

        self.vbox.pack_start(self.label, True, True, 0)
        self.vbox.pack_start(self.number_label, True, True, 0)
        self.vbox.pack_start(self.entry, True, True, 0)
        self.vbox.pack_start(self.button, True, True, 0)
        self.add(self.vbox)

    def on_button_clicked(self, widget):

        if int(self.entry.get_text()) == self.result:
            subprocess.call("unity &", shell=True)
        else:
            self.label.set_text("Wrong answer, try again.")
#----------------------------------------------------------------------
def main():
    """Application's entry point"""
    win = PuzzleWindow()
    win.connect("delete-event", Gtk.main_quit)
    win.show_all()
    Gtk.main()

if __name__ == "__main__":
    main()

Results:

  • If you logout, at the login screen you will see a new session named Custom.
  • By choosing the custom session and after successful login you will presented by a small PyGtk (using pygobject) window asking for a math puzzle. There will be no top bar, launcher and the rest of the default desktop widgets:

Custom access to Unity

  • If you answer correctly, Unity will load...

It needs further research though but i hope that it helps as a starting point.


It can be done, but would take a lot of technical knowhow. The simplest way to do this by writing a script that is run as root that:

  • changes their password(s) automatically to the answer of a given question,
  • changes their desktop wallpaper to show the question they are trying to answer

You would likely need to keep the list of math problems in a text file (or database), and use the imagemagick command line tools to add the problem text to the desktop wallpaper. Use cron to schedule that script to run every so often (daily?).

Getting the login screen to ask for 3 different questions would require a lot of custom hacking and would probably involve replacing large parts of your system, so it not recommended. Even the "simple" script above requires a lot of skill and knowledge, and could potentially break your system if done wrong.