Bug 341142 - Provide a way to display (passive) notifications from KWin scripts
Summary: Provide a way to display (passive) notifications from KWin scripts
Status: RESOLVED INTENTIONAL
Alias: None
Product: kwin
Classification: Plasma
Component: scripting (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: 5
Assignee: KWin default assignee
URL: https://git.reviewboard.kde.org/r/121...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-21 01:09 UTC by Stefán Freyr Stefánsson
Modified: 2025-06-01 13:53 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:
mgraesslin: ReviewRequest+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefán Freyr Stefánsson 2014-11-21 01:09:16 UTC
After much searching I haven't been able to figure out how I could display a passive notification from a kwin script.

What I want to achieve is the same thing as when I run:

kdialog --title "This is a passive popup" --passivepopup "It will disappear in about 10 seconds"

I had dbus-monitor running and saw what message was coming across when I ran the above command but I was never able to get it exactly right using the callDBus function in my kwin script.

I did manage to get the message looking exactly like it did when it came from kdialog using dbus-send:

dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.Notify string:'kdialog' uint32:0 string:'dialog-information' string:'passive popup' string:'will disappear in 2 seconds' array:string:"" array:string:"" int32:2000

However, no notification was displayed.

But to summarize, the main problem is that I would just like to be able to show some sort of a notification to the user in my kwin script.
Comment 1 Thomas Lübking 2014-11-21 15:45:15 UTC
The problematic part is the VariantMap for the hints - it doesn't work w/ qdbus either (at least I didn't figure how to)

What's the background on this?
Eventually you'd rather want to invoke KNotify (configurable action, sound, dialog, random executable)?

---
org.freedesktop.Notifications.Notify(QString appName, uint replacesId, QString appIcon, QString summary, QString body, QStringList actions, QVariantMap hints, int timeout)
Comment 2 Stefán Freyr Stefánsson 2014-11-21 16:05:22 UTC
There's not really any background here. I wanted to create my first KWin script and the first thing I thought of was to have some way to display information to the user. To begin with I was just going to use that to display "debug" information to myself even.

So basically I just want a way to display these notifications with the eventual goal of it being the main source of displaying "passive information" but yes, also errors or whatever I may want to present to them, from a kwin script.

If there is a way to invoke random executables that would be just fine with me... then I could use my kdialog command line to do exactly what I want. But basically I just don't have any clue how to do this. After searching through forums and asking for help on IRC I concluded that this was not possible, and so I filed this bug.

By all means, please correct me if I'm wrong and this is possible to do somehow. I'm not really hung up on having to do it through dbus at all (although I do consider it a bug if you can't pass certain types of data structures to dbus... but that probably belongs in a bug of its own).
Comment 3 Thomas Lübking 2014-11-21 21:33:20 UTC
(In reply to Stefán Freyr Stefánsson from comment #2)

> information to the user. To begin with I was just going to use that to
> display "debug" information to myself even.
You can also "print" and run "kwin --replace&" from konsole for this particular case.

> If there is a way to invoke random executables that would be just fine with
> me...
No, that's a misunderstanding. The KNotify system allows to configure various actions for a notification (including a passive dialog or running a random binary)
Just to display a message, it's however "overhead" (and not portable on other environments than KDE)
Comment 4 Stefán Freyr Stefánsson 2014-11-25 20:33:14 UTC
>> If there is a way to invoke random executables that would be just fine with 
>> me... 
>No, that's a misunderstanding. The KNotify system allows to configure various 
>actions for a notification (including a passive dialog or running a random 
>binary) Just to display a message, it's however "overhead" (and not portable on 
>other environments than KDE)

Not quite sure what you mean here.

Basically I just want to know the following:

Is it a misunderstanding on my behalf that I can't display a "passive notification" to the user from a kwin script? If that is the case, how would I display such a notification (a code snipped would be much appreciated)?

I think you may have thought that I wanted to do that by running the "random binary" (for example by running the kdialog command above to do this). This is not the case, I want some sort of a "native" way to display this notification from within my kwin script. But since there doesn't seem to be such a way I was saying that I'd accept any workaround if one exists... including running some executable that would do it for me (such as kdialog).

I hope I'm making myself clearer now.

Thanks for the debugging tip... that makes perfect sense.
Comment 5 Thomas Lübking 2014-11-25 20:54:06 UTC
(In reply to Stefán Freyr Stefánsson from comment #4)

> Not quite sure what you mean here.
There's an fdo notification daemon (for popup messages only) that can be accessed via dbus as well as a KDE notification daemon (that can also play sound or execute random binaries on events)
 
> Is it a misunderstanding on my behalf
Probably: No.

> that I can't display a "passive notification" to the user from a kwin script?
You -probably- can't: see patch.

You *could* access the fdo notification dameon (dbus calls *are* supported by KWin scripts), but this would require to create a QVariantMap object in the script - and I don't know whether that's possible.

> I think you may have thought that I wanted to do that by running the "random
> binary"
No, didn't =)
Comment 6 Martin Flöser 2014-11-26 07:46:32 UTC
> You *could* access the fdo notification dameon (dbus calls *are* supported
> by KWin scripts), but this would require to create a QVariantMap object in
> the script - and I don't know whether that's possible.

a structure like:
{
key: value,
otherKey: value
};

should(TM) be convertable to QVariantMap
Comment 7 Ilya V. Portnov 2015-06-15 18:00:37 UTC
So. Any updates?