[Solved] How do I make a clickable desktop notification?

Contribute code to SolydXK and make it even better.
Deleted User 2764

[Solved] How do I make a clickable desktop notification?

Postby Deleted User 2764 » 26 Sep 2014 21:49

I have a perl script that will give a desktop notification. That part I got working ok. I'm not too familiar with desktop functions even though I'm very familiar with Perl at the console level.

How do I get it so that when the notification pops up, if I click on it, it will load and display text in the system's default GUI text editor? Or run some other program that takes parameters?

Deleted User 2764

[Solved] Re: How do I make a clickable desktop notification?

Postby Deleted User 2764 » 27 Sep 2014 16:04

I finally found the solution. So I'll post it here in case others may have this issue. There still is a problem which I don't know how to get rid of the error referenced in the comments in the code. But otherwise it does work.

Code: Select all

#!/usr/bin/perl
# Distro: SolydK (Debian Testing (Jesse) based)
# KDE 4.13.3

# Depenencies installed:
# libgtk2-notify-perl

# This works, but still there's this error in the console:
#QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.

use Gtk2::Notify -init, 'Multi Actions';

my $popupnote = Gtk2::Notify->new(
        'A new message!',
        'This is a new message.'
);
$popupnote->add_action('list', 'See List', \&do_action);
$popupnote->show;

Gtk2->main;

sub do_action {
    my ($popup, $action) = @_;
    system("kate ~/Temp/Test.txt");
    $popup->close;
    Gtk2->main_quit;
}

Deleted User 2764

Re: [Solved] How do I make a clickable desktop notification?

Postby Deleted User 2764 » 27 Sep 2014 16:42

I just found more information on the QDBusConnection errors:

http://www.archivum.info/ubuntu-bugs@li ... ehave.html

Basically it seems like it's only a warning that is in the console and can safely be ignored.


Return to “Code”

Who is online

Users browsing this forum: No registered users and 1 guest