LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-18-2008, 12:36 PM   #1
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Rep: Reputation: 56
how to show emergency pop up message to user? (on X)


Hi there

I need a surefire way to inform a user logged in on a remote desktop on his X session (Gnome or KDE).

I have root access to his machine and log in remotely and have to be able to tell him that the file server is not available at the moment or such.

So far no luck, wall does only work for command line and is quite outdated in a time where people don't do their word processing in the CLI anymore.
It has to generate a pop up window in the X session of the user logged in on a computer or better ANY user logged in.

kdialog also does not work, since I cannot get it to display on the remote machine while logged in on SSH.
xhost + is really acting wierd since it is supposed to give all hosts access to the xserver of the remote machine and instead, it tries to open a X display, which it cannot (why is it doing that in the first place? xhost is a access restricting / granting program, not anything that opens or uses a x screen)

logger is a program that might work, it generates log messages for the system log, but I guess if you can generate a message of enough severity, it might (or must) pop up on the user screen, no matter in which way the person is logged in.

logger -p kern.emerg "this is urgent, act now"
unfortunately does not do a thing. A kernel emergency should trigger a pop up like that, shouldn't it?

Anyone know a severity of log entry that will get out on all channels available to a machine? I know that shutdown messages do and they have to do that somehow...

grateful for any pointers

Markus
 
Old 04-18-2008, 01:16 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
You might try the -k option of the shutdown command. The -k option says to not really shutdown, just send the warning message to all users. See:

man shutdown

---------------------
Steve Stites
 
Old 04-18-2008, 01:18 PM   #3
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Original Poster
Rep: Reputation: 56
hihihi, THAT is what I call creative!

If you cannot use a pidgeon to deliver a message, use a duck or a horse, if you can make it fly and it flies further then.

;-)

I will try it pronto.

thanx

Markus
 
Old 04-18-2008, 01:46 PM   #4
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
In a Freedesktop compliant desktop (gnome, kde), the service/usr/libexec/notification-daemon from notification-daemon package and the associated utility /usr/bin/notify-send from libnotify package (in a fedora8 distro) may be what you are looking for.

I use gnome and in a script that takes a long time to finish, I use this to notify me about the progress.

Code:
...
# a milestone has reached
/usr/bin/notify-send -t 0 "Results" "Phase 3 has completed."
...

# starting phase 4
...
as result, I got a small box on the right corner about the progress.
"/usr/bin/notify-send --help" to get details about the several options.

The box is the same the gnome uses to display several informational messages you may already seen.

pretty cool....

Last edited by marozsas; 04-18-2008 at 02:11 PM.
 
Old 04-18-2008, 01:58 PM   #5
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
xmessage

xmessage -button ok -center file - "shutting you down in 1 minute"

Pops up a message box in the center of the screen on top of any other open windows, and gives the message in quotes.
 
1 members found this post helpful.
Old 04-18-2008, 02:50 PM   #6
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Original Poster
Rep: Reputation: 56
shutdown unfortunately does not show any message. I was wrong about that, very strange. The user should know when the machine is shutting down.
This is on Ubuntu (with KDE), so it might be a Ubuntu bug.

Markus
 
Old 04-18-2008, 03:54 PM   #7
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
You may tweak your syslog config file to create a new message type and bind it to a named pipe.
Then you need to create a script that receive input from that named pipe and output the message using notify-send, osd_cat, xmessage, whatever, on the user's X-display. This script runs with the user session and there is no xhost issues.

When you want to inform the user about anything, you can use logger as root or any other local user, with the appropriated message type and it will trigger your named pipe and output program.
 
Old 11-04-2008, 04:01 AM   #8
felixhummel
LQ Newbie
 
Registered: Mar 2007
Posts: 2

Rep: Reputation: 0
KDE makes it easy

KDE's kdialog can display messages remotely, e.g.
Code:
ssh localhost 'kdialog --display :0 --msgbox "Test"'
Gnome has gdialog - I did not test it, but it should work alike.

osdsh provides OSD-Like behaviour:
Code:
# osdsh has to be running on the client - put it in ~/.xsession:
osdsh
ssh localhost 'osdctl -s "Test"'
(tested on Kubuntu 8.04)
 
Old 11-05-2008, 09:50 AM   #9
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Have you tried kdialog with the --display option?
 
Old 11-05-2008, 12:34 PM   #10
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Me: KDE 3.5.10, kubuntu 8.04.1, kernel 2.6.24-21-generic (& I love it!)

kdialog is nice, but will not send output to a screen that is owned by someone else.
For example, tred is on display :0 and user is on :1
Code:
tred@vaio:~$ kdialog --display :0 --msgbox "Test"   It works
tred@vaio:~$ kdialog --display :1 --msgbox "Test"
No protocol specified
kdialog: cannot connect to X server :1
# OK, let's try it as the user "user" ....
tred@vaio:~$ su - user
Password:
user@vaio:~$ sleep 20; kdialog --display :1 --msgbox "Test"
# Press CTRL-ALT-F8 to switch to display :1, wait.... It works! Switch
# back to :0 with CTRL-ALT-F7
# Maybe root can do it .....
user@vaio:~$ exit
tred@vaio:~$ sudo -i
Password:
root@vaio:~# kdialog --display :1 --msgbox "Test2"
No protocol specified
kdialog: cannot connect to X server :1
root@vaio:~# 
# Grrrrrrrr.
I am trying to find kubuntu's equivalent of /usr/bin/notify-send ...
Found it, it's in the package libnotify-bin
But:
Code:
tred@vaio:~$ /usr/bin/notify-send -t 0 "Results" "Phase 3 has completed."
libnotify-Message: Unable to get session bus: Failed to execute dbus-launch to autolaunch D-Bus session
tred@vaio:~$
What kind of error is that? dbus is running (but I don't have a dbus-launch executable in my path) I installed dbus-x11 and kdbus.
Now the command executes:
Code:
tred@vaio:~$ /usr/bin/notify-send -t 0 "Results" "Phase 3 has completed."
tred@vaio:~$
but nothing happens to the screen.

osdsh works the same way as kdialog; it won't send to a screen not owned by the invoker.

I am really surprised that the OP's Q (Which is, basically, "How do I notify all users, who are running X of something important, like an imminent reboot?") hasn't been answered yet. I will be very interested in the answer. There has to be one. Please?
 
Old 11-12-2008, 05:21 PM   #11
tlhonmey
LQ Newbie
 
Registered: Nov 2008
Posts: 18

Rep: Reputation: 5
There *is* a popup notification standard in the Freedesktop standard. However, so far as I have found, nobody has written a simple program to make use of it. The best I can find are Python bindings for the library...

But, if you wish a simple workaround, and you have root privileges on the machine in question, then it's pretty easy.

su -c "xhost +" <username> will disable authentication on whatever display <username> happens to be using. Then *anyone* can send graphical outputs to their screen. (So be sure to turn it back on with xhost - when you're done.)

After that, just use xmessage, zenity, or whatever other popup generator program you want. You can even dump the message to a file and open it in a graphical text editor if that suits your sense of style...
 
Old 11-13-2008, 10:22 AM   #12
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Original Poster
Rep: Reputation: 56
Cool

Yes, this is very interesting. And there must be an answer. I have not tried the last post before this one, but xhost + so far has given me hard trouble. It always tells me "cannot open display". xhost is not a graphical application, it does not use or open a display, it sets permissions. Is there a bug in there? Why does it tell me "cannot open display" when I use it with "give permission to all"?

Well, I am sure we will crack that nut and as life sometimes puts you the right things in the way, I am learning Python at the moment and love it.

So taking a look at these bindings will be fun.

But honestly: am I the only one that is very bothered by the stupid Xserver thing that root is powerless to influence users screens? Root can do ANYTHING, it does not need permission to use a screen, it should be all powerful about everything in the system.

One of the biggest bothers for me is that when I go
su -
on the CLI that then I cannot start GUI tools anymore, "cannot open display", without giving Root permission.
What sense does that make? None!

I love Linux for all the great things that it make so much sense in. Coming from Windows some long time ago, I am hardly getting upset, since things are well designed in Linux. In Windows, there is no end to stupidity in what Microsoft cooked up and how lame and inconsistent it is. The guys that designed / and still are designing Linux (and Unix before) really know what they are doing.

But in this case above, I fail to see it. I wish this could be changed, because it does really not serve any purpose. Being root must bring total power with it. Does anybody know a xhost statement that will enable root to use all displays? (but not everybody else, since xhost + is a aweful security hole)

So far my harsh, but constructive critizism

Markus
 
Old 12-05-2008, 11:00 AM   #13
brood1
LQ Newbie
 
Registered: Dec 2008
Posts: 8

Rep: Reputation: 0
Hello all,

I just wanted to tag this thread, seeing as I am in the same boat as everyone. I have an app that runs headless as root (it's a daemon service) that needs to output notifications to all users if something bad happens. I have tried everything above as well, and I was thinking there must be a way to tap into the notifications that pop up from the system? You know the ones that pop up from Aptitude or its equivalent in KDE.

Just a thought, I will be continually digging.

=)
 
Old 12-06-2008, 11:34 PM   #14
bugman
LQ Newbie
 
Registered: Dec 2000
Posts: 11

Rep: Reputation: 1
As root type:
write <username> - press enter
type the message
press CTRL-D

man write for more info
 
Old 12-07-2008, 07:12 AM   #15
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
As root type:
write <username> - press enter
Thank you. BUT:

This only works writing to a proper terminal - the <CTRL><ALT><F2> type.
You don't need to be root, but you must both have enabled messaging with mesg y beforehand.

It it will not pop up a message window if the other user is logged into a GUI and it will not write to an xterm window either.


@tlhonmey,
Your suggestion doesn't seem to work either:
Code:
tred@vaio:~$ who
testuser tty2         2008-12-07 12:36
tred     :0           2008-12-07 09:25
testuser :1           2008-12-07 12:30
tred@vaio:~$ kdialog --display :0 --msgbox "Test"  #It works, on my display which is :0
tred@vaio:~$ kdesu -c "xhost +"
access control disabled, clients can connect from any host
tred@vaio:~$ kdialog --display :1 --msgbox "Test"  #Fails to work:
No protocol specified
kdialog: cannot connect to X server :1
tred@vaio:~$ kdesu -c "kdialog --display :1 --msgbox "Test""
No protocol specified

kdialog: cannot connect to X server :1
tred@vaio:~$ sudo -i
root@vaio:~# kdialog --display :1 --msgbox "Test"  #Fails to work:
No protocol specified
kdialog: cannot connect to X server :1
root@vaio:~# xhost -
access control enabled, only authorized clients can connect
root@vaio:~# exit
tred@vaio:~$
But thanks for trying.
So it looks like this thread is still "not solved".
 
  


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
Emergency : accidently deleted my user directory Vassos Linux - Newbie 4 11-20-2007 05:33 PM
how to show message to user denied to print I_like_TUX Linux - Newbie 3 10-19-2007 06:16 PM
POP-UP ERROR MESSAGE in RHWS4.0 jayfoo Linux - Software 0 09-27-2005 01:36 PM
Error message pop to the screen ust Linux - Distributions 3 04-13-2005 10:12 PM
Message Pop Up App netkepala Linux - Software 8 04-11-2004 08:38 AM

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

All times are GMT -5. The time now is 12:50 AM.

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