My solution is:
#!/usr/bin/perl -w
use strict;
my $session_list = `/usr/bin/ck-list-sessions`;
my = split /^Session/m,$session_list;
my $active_x;
my %x_sessions;
foreach my $session ( )
{
next if $session =~ /session-type = 'LoginWindow'/;
$session =~ /x11-display = '([^']+)'/;
my $display = $1;
if( $display )
{
$session =~ /unix-user = '([^']+)'/;
my $user = $1;
$x_sessions{$display} = $user;
next if( $session =~ /active = FALSE/);
$active_x = $display;
}
}
if( $active_x )
{
$ENV{'DISPLAY'} = $active_x;
my $uname = getpwuid( $x_sessions{$active_x} );
system( "zenity"
,"--question"
,"--text=This computer is scheduled to restart at this time. You may choose to prevent this if you wish.\n\nIf you take no action this computer will restart in one minute!"
,"--ok-label=Restart"
,"--cancel-label=NO!"
,"--title=Restart requested"
,"--timeout=10" );
if ( $? >> 8 == 1 )
{
system("logger","-t","nice-reboot","$uname chose to cancel the reboot.");
exit;
}
}
for my $display ( keys %x_sessions )
{
$ENV{'DISPLAY'} = $display;
my $uname = getpwuid( $x_sessions{$display} );
system("logger","-t","nice-reboot","Logging out $uname.");
system("sudo","-u",$uname,"gnome-session-save", "--force-logout");
}
sleep 30;
system("logger","-t","nice-reboot","Rebooting now");
system("reboot");
This gets scheduled to run as root at some time.
While I suspect that this same thing can be triggered in Gnome Power Manager via a DBUS call, that elegant solution may have to wait.