Ticket #140 (accepted defect)

Opened 15 years ago

Last modified 14 years ago

Screen saver doesn't say how long you've been idle

Reported by: geofft Owned by: jdreed
Priority: low Milestone: The Distant Future
Component: -- Keywords: hackathon
Cc: Fixed in version:
Upstream bug:

Description

xscreensaver on Athena 9 would tell you if the person you were considering logging out had been idle for 3 minutes or 3 days. It'd be nice to have this on Debathena too.

One cheesy option is to add a button that pops up finger | zenity --text-info or some equivalent.

Change History

comment:1 Changed 15 years ago by jdreed

  • Component set to --
  • Milestone set to IAP 2010

comment:2 Changed 14 years ago by jdreed

I looked into this today, and I don't believe there's a good way to do this.

Finger (and anything that uses utmp) only report idle time on ttys. If I log in, and spend an hour typing a paper in OpenOffice?, and then walk away, then I will have been idle for an hour as far as finger is concerned, which isn't true. Really, this is something we should take up with gnome-screensaver, since that's the only source of true idle info.

Also, we can't pop up dialogs, since the screensaver grabs focus (as it should).

However, if we want to use utmp as a decent approximation, we can do horrible things with embedded_keyboard_command.

If you set /apps/gnome-screensaver/embedded_keyboard_enabled to true, and you set embedded_keyboard_command to the following python script, you get a reasonable approximation of this feature. This may or may not be a good idea.

#!/usr/bin/python -u
#
# -u required to make STDOUT unbuffered, otherwise gnome-screensaver
# can't read the plug id
#

import pygtk
pygtk.require('2.0')
import gtk
import gtk.gdk
import time
import os
import utmp
import UTMPCONST
import stat


plug = gtk.Plug(0L)
print plug.get_id()


lbl = gtk.Label()
lbl.set_use_markup(True)
lbl.set_single_line_mode(False)
lbl.set_property("justify", gtk.JUSTIFY_CENTER)
# Give it an EventBox so it has a gtk.gdk.Window
ebox = gtk.EventBox()
ebox.add(lbl) 
ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("black"))

def on_embed(widget):
    records = utmp.UtmpRecord()
    idlesince = 0
    for i in records:
        if i.ut_type == UTMPCONST.USER_PROCESS:
            idletime = os.stat("/dev/"+i.ut_line)[stat.ST_ATIME]
            if idletime > idlesince:
                idlesince = idletime
    records.endutent()
    lbl.set_markup("<span background=\"white\" foreground=\"black\">This machine has been idle since %s\n\n(%d minute(s) ago)</span>" % (time.ctime(idlesince), (time.time() - idlesince) / 60))

plug.connect("embedded", on_embed)
plug.connect("destroy", lambda w: gtk.main_quit())

plug.add(ebox)
plug.show_all()

gtk.main()

comment:3 Changed 14 years ago by jdreed

This works:

#!/usr/bin/python -u
#
# -u required to make STDOUT unbuffered, otherwise gnome-screensaver
# can't read the plug id
#

import pygtk
pygtk.require('2.0')
import gtk
import gtk.gdk
import subprocess

plug = gtk.Plug(0L)
print plug.get_id()

lbl = gtk.Label()
lbl.set_use_markup(True)
lbl.set_single_line_mode(False)
lbl.set_property("justify", gtk.JUSTIFY_CENTER)
# Give it an EventBox so it has a gtk.gdk.Window
ebox = gtk.EventBox()
ebox.add(lbl) 
ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("black"))

def on_embed(widget):
    status = subprocess.Popen(["gnome-screensaver-command", "-t"], 
                             stdout=subprocess.PIPE).communicate()[0]
    lbl.set_markup("<span background=\"white\" foreground=\"black\">%s</span>" % (status,))

plug.connect("embedded", on_embed)
plug.connect("destroy", lambda w: gtk.main_quit())

plug.add(ebox)
plug.show_all()

gtk.main()

comment:4 Changed 14 years ago by jdreed

Currently, we set embedded_keyboard_command was a workaround for an upstream bug (gnome bugzilla 573495, see r23510 for details), but that was fixed upstream in April, so hopefully it made it into Karmic. Someone should test, and if so, we can deploy this.

comment:5 Changed 14 years ago by amu

AFAICT, you're looking for xprintidle (which I believe uses the XSCREENSAVER extension to get a more precise idle time).

comment:6 Changed 14 years ago by jdreed

If xprintidle uses XSCREENSAVER's concept of idle time, then I think it won't work, because the screensaver authentication dialog appearing appears to reset the XSCREENSAVER's concept of idle time (based on my testing).

gnome-screensaver-command -t seems to work, despite the fact that it displays only in seconds, but that can be fixed with regexps.

comment:7 Changed 14 years ago by jdreed

  • Status changed from new to accepted
  • Owner set to jdreed

This definitely got fixed in Lucid, so we can move forward if we want to. Replacing embedded_keyboard_command may not be a good idea, but OTOH we're unlikely to ever have touchscreens in the clusters.

comment:8 Changed 14 years ago by jdreed

  • Milestone changed from Summer 2010 (Lucid Deploy) to Fall 2010

comment:9 Changed 14 years ago by jdreed

  • Milestone changed from Fall 2010 to The Distant Future

comment:10 Changed 14 years ago by jdreed

  • Keywords hackathon added
Note: See TracTickets for help on using tickets.