New Session Manager
Posted in Programming and Technical, Ubuntu on July 7th, 2011 by doctormoFor community centers we need to present to the user the amount of time that their session has left and at the same time log the user off when the session timer runs out. As a nice touch we want to warn the user as the session nears it’s end.
To achieve this we use an app indicator with a menu item with the amount of time left.

For the warnings we use the libnotify and change the icon of the app indicator too:

We also want to notify the user of how much time they have, so we add a welcome:

If the program exits or is killed, the gnome pid is also killed so the user logs off.
All of this is configurable so we can say what users should have what kind of session and what warnings:
logs: /var/log/sessions/
limit_by_group:
admin: ''
users: 01:00:00
testing: false
warnings:
- message: Welcome!
description: You have %(remains)d minutes in your session.
icon: application-community
from: session-start
times: [ '00:01' ]
- message: Session Running Out
description: Your session is about to end automatically, please save all your work. %(time)d minutes remaining.
icon: gtk-quit
from: session-end
times: ['10:00', '05:00', '01:00']
For reporting we also want to log sessions, when they start, when they end and on what machine:
events:
- {date: '2011-07-07T15:36:02.734579', message: log-started}
- &id002 {date: '2011-07-07T15:36:02.763812', message: login, session-pid: 1830, tag: started}
- &id001 {date: '2011-07-07T15:36:51.898611', message: forced, tag: end}
meta: {hostname: delen, username: doctormo}
We add the program’s .desktop file to the /etc/adg/autostart directory so it launches when gnome starts.


