Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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... :\
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152
Rep:
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.
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.
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152
Rep:
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. . .
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.
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152
Rep:
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. . .
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.
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.
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152
Rep:
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;
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.