Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

"kdialog --display=:0" option fail

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
jaja
Posts: 53
Joined: 2016-01-25 00:20
Has thanked: 1 time

"kdialog --display=:0" option fail

#1 Post by jaja »

Hello and thanks for the help;

System:
Debian 11 (all updates installed)
KDE
AMD CPU

I have a service that starts at bootup with root ownership.
If this service detects a specific condition, it sends an email to a designated user (not root).
I'd like it to also send a popup message to the display of this designated user.
So I need to direct the popup message to a display owned by someone other than root (designated user).
Everything works, except the popup message.
Redirecting the popup message to the display of the designated user fails.

Stripping the failure down, I discovered that I'm failing at the most basic level: I can't specify the display.

Here is the simplest sequence showing the failure:

Code: Select all

env                                         #get the display name: "DISPLAY=:0" (self)
kdialog --error 'Test Message'              #make sure the popup works when using the default display (default self)
kdialog --display=:0 --error 'Test Message' #now explicitly specify the display (specify self)
kdialog: Unknown option 'display'           #FAIL
The "man" page ("http://pwet.fr/man/linux/commandes/kdialog/") lists the options in three categories:
kdialog [Qt-options] [KDE-options] [options] [arg]

I discovered that only the [options] work; and that the [Qt-options] and the [KDE-options] all fail.
The "--display" option is one of the [Qt-options], hence its failure.

I assume that I need to install/configure some Qt package, but I can't find any info on which package is needed.

What am I doing wrong?
Any pointer appreciated.

Thanks for the help.

steve_v
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1396
Joined: 2012-10-06 05:31
Location: /dev/chair
Has thanked: 78 times
Been thanked: 173 times

Re: "kdialog --display=:0" option fail

#2 Post by steve_v »

jaja wrote: 2022-01-20 08:11I discovered that only the [options] work; and that the [Qt-options] and the [KDE-options] all fail.
Indeed, those options don't work for me either.

Code: Select all

DISPLAY=:0 kdialog --error 'Test Message'
works for me when run in a root TTY, assuming the target xserver accepts local connections i.e.

Code: Select all

xhost local:
or

Code: Select all

xhost si:localuser:root
has been run as the user receiving the message.
Alternatively, having your script launch the notification command with su (or sudo) to the user in question should skip the xhost bit, like so:

Code: Select all

DISPLAY=:0 su steve -c "kdialog --error 'Test Message'"
Using kdialog for this seems a bit kludgy to me TBH, would it be better to investigate dbus / notify-send etc? A cursory web search has plenty of hits for notify-send from root scripts.
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

jaja
Posts: 53
Joined: 2016-01-25 00:20
Has thanked: 1 time

Re: "kdialog --display=:0" option fail

#3 Post by jaja »

Hello steve_v;
Thank you for the working example and for the pointer to "notify-send".
That's the information that I needed.
Again, thanks!

Post Reply