LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-24-2002, 03:44 PM   #1
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Question graphical wall?


Gidday guys!

Is there a tool out there that will popup a dialog in X
when I issue a message from, say, shutdown(1)?
The kids at home miss out on me doing maintenance
work (or the messages the server issues from cron-jobs)
because they usually don't use terminals... :\

Cheers,
Tink
 
Old 11-24-2002, 06:09 PM   #2
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
Well. . . You can do it, but it'll take a bit of scripting. Basically, you
would need to figure out who is logged in, become them, give root access
to the X display, then display your message using whatever (xv,
maybe?). As far as I know, there are no programs that will accomplish
this. X is designed to keep the display secure from others, and unless
the owner of the console specifically allows it, noone else can write to
the display.

To get you started:
man xhost
man su
man sudo
 
Old 11-24-2002, 07:29 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067

Original Poster
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by moses
Well. . . You can do it, but it'll take a bit of scripting. Basically, you
would need to figure out who is logged in, become them, give root access
to the X display, then display your message using whatever (xv,
maybe?). As far as I know, there are no programs that will accomplish
this. X is designed to keep the display secure from others, and unless
the owner of the console specifically allows it, noone else can write to
the display.

To get you started:
man xhost
man su
man sudo
G'day Moses,

and I've been down that way. However,
even becoming the other user won't help
because I still can't xhost when I'm not on
the actual X display, I've tried that ;)

Maybe I'll have to add xhost +(my workstation-ip) +(server-ip)
to their login-scripts :) and go on from there ...

The reason why I was asking this question is
that I seem to recall to have seen a graphical
message on a RedHat box when it was going
down for a reboot.

Cheers!
Tink
 
Old 11-24-2002, 08:38 PM   #4
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
I really can't think of a way around "xhost +". I messed around a little
with trying to trick X into accepting from other than the tty that owns the
console and wasn't able to (with an admittedly quick, shallow attempt)
fool it.

I suppose you could write a script that just sits, waiting for a kill -HUP,
start it up when the user logs into X, write a wrapper for shutdown such
that when it is called, it changes the config file for this script, does a
kill -HUP on the script, which rereads its config file, which tells it to
spit something to the screen. . .
PERL would work well for this. . .
Your reboot/shutdown wrapper would kill -HUP the PID of a script
something like:

Code:
#!/usr/bin/perl
# catch ^C , ^Z and other signals that would otherwise
# cause us to sit in limbo.

use FileHandle;
use Shell;
use Env;
use sigtrap 'handler' => \&catch_zap, 
            qw(HUP BUS SEGV PIPE ABRT QUIT TERM INT SYS TRAP);

$lock = "/tmp/reboot";

   while (1)
{
}
 sub catch_zap
 {
   my $signame = shift;
   if (-e $lock)
   {
     xv("/boot/tux.bmp -quit");
   }
   exit;
 }
I don't have my PERL books with me, but there is a way to figure out the
script's PID, which you would output to a file so your reboot wrapper
could easily find the PID. . .

Last edited by moses; 11-24-2002 at 08:45 PM.
 
Old 11-24-2002, 08:51 PM   #5
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Here's another option...

You could setup something like root-tail to run on their desktops to display something in var log, then update that file to tell them something. I don't know how well that'd work, but it's something to think about.

example:

Say you created a file called /var/log/maintenence, then in your xinitrc you'd root-tail it:
root-tail /var/log/maintenence

Then it would show up in the background when you added new lines to it, something like:
Hey, System going down, save everything, you've got 5 min

Or something like that.

I am gonna try it later just for fun to see how well it'll work.

Anyway, it's an idea.

Cool
 
Old 11-24-2002, 09:05 PM   #6
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
Yeah, xv was just an example, you could replace xv with an xterm that
displays a message written by your wrapper script, maybe something you
sent it as a command line, whatever. . .
 
Old 11-24-2002, 09:37 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067

Original Poster
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Thanks for your suggestions guys!

Maybe I'll try to make something little,
like xbiff, and have a dialogbox in it :}

Cheers,
Tink
 
Old 11-24-2002, 10:51 PM   #8
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
Hey, post back once you get it done!
 
Old 11-24-2002, 11:18 PM   #9
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
I just tried the root-tail thing, it works just fine. Here's a screenshot:
ftp://masterc.no-ip.org/pics/root-tail.png

I said "Hello" to me I simply typed Hello into my /var/log/xferlog (which I have setup in my xinitrc to show up in white using root-tail) and it displayed it as such.

Pretty cool!

Cool
 
Old 11-25-2002, 12:58 AM   #10
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
That's kind of cool. =-}
What happens when the users have the desktop covered with windows?
 
Old 11-25-2002, 08:58 AM   #11
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
They miss out on the message Didn't think about that...

Cool
 
Old 11-26-2002, 06:01 AM   #12
Flibble
Member
 
Registered: Mar 2002
Distribution: Redhat 9.0, Debian, Knoppix, YellowDog
Posts: 142

Rep: Reputation: 15
Have you tried a "focus -force window" ?

Tcl command.

Flibble
 
Old 11-26-2002, 10:11 AM   #13
DaFrEQ
Member
 
Registered: Mar 2002
Location: Earth... for now
Distribution: SuSE9.2 AMD64; LFS; GentooAMD64; Ubuntu10.04; RHEL 5.5; Solaris10(SPARC)
Posts: 418

Rep: Reputation: 30
couldn't you just make a simple widget type proggie that when run, will thread to all users logged in, run the app, pop the window and be done with it?

plus if you make it simple... modal, then they'll have to do something with it even if desktop is covered with other windows.

L8rz
 
Old 11-28-2002, 07:41 PM   #14
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
Code:
#!/usr/bin/env perl
# simple Gtk-PERL script to pop up a dialog box telling a user that the
# system is about to be shutdown.  This script would be run from their
# .login, and will just wait for a kill signal.  It's pretty worthless
# by itself, but if you wrap your /sbin/halt, reboot, etc. scripts,
# it can be useful.  Simply have your script fill /tmp/reboot with a
# message you would like your user to see when this button pops up.
# MPM 27 Nov 2002
#   implemented due to a thread on linuxquestions.org about telling
#   users that the system is about to be shut down by a remote root
#   This software is completely free, and has no restrictions, guarantees,
#   or anything else.  If you can actually get someone to pay you for this,
#   you are quite a business person and probably deserve the money (but,
#   you'll probably also rot in hell for all your underhanded dealings).

use FileHandle;
use Shell;
use Env;
use sigtrap 'handler' => \&catch_zap,
            qw(HUP BUS SEGV PIPE ABRT QUIT TERM INT SYS TRAP);
use Gtk '-init';

$pidfile = "/tmp/xreboot";

$pid = getppid();
open(OUTFILE, ">$pidfile");
print OUTFILE $pid;
close OUTFILE;

$reboot = "/tmp/reboot";

while (1) { }

sub catch_zap
{
   my $signame = shift;
   if (-e $reboot)
   {
     open(INFILE, $reboot);
     my @message = <INFILE>;
     close INFILE;
     my $window = new Gtk::Window;
     my $button = new Gtk::Button(@message);
     $window->add($button);
     $window->show_all;
     $button->signal_connect("clicked", sub
              {
              Gtk-exit(0);
              });
     Gtk->main;
   }
   rm($pidfile);
   exit;
}

Last edited by moses; 11-29-2002 at 01:53 AM.
 
Old 11-28-2002, 09:29 PM   #15
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067

Original Poster
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Geeee :}

Thanks Moses!

Cheers,
Tink *d/ling more Perl-Stuff than he ever bargained for :D
*loathing his shared 56K connection :D

Last edited by Tinkster; 11-28-2002 at 09:44 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wall messages under X Artanicus Linux - Software 6 06-28-2005 08:59 PM
fire wall berrance Red Hat 2 08-21-2004 11:55 AM
[C++] -Wall Output noir911 Programming 2 08-01-2004 07:17 AM
kwrited and wall with 9.2 or 10.0? tld Mandriva 4 04-28-2004 09:15 AM
A guified wall? WeNdeL Linux - Software 0 10-10-2003 11:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration