Нормальный человек проводит отпуск нормально. Я – человек не очень нормальный, потому и отпуск провожу не очень нормально. Одна из ненормальностей нынешнего отпуска – реализация уведомлений на perl-е.
Ну и собственно код, чо уж там
#!/usr/bin/perl use warnings; use strict; use Net::DBus; use Net::DBus::Service; use Net::DBus::Reactor; $ENV{"YAD_OPTIONS"} = "--sticky --fixed --on-top --undecorated --no-focus --no-buttons --borders=15 --width=250 --name=Popup --image-on-top --posx=-5 --posy=-5"; package Notifications; use base qw(Net::DBus::Object); use Net::DBus::Exporter qw(org.freedesktop.Notifications); sub new { my $class = shift; my $service = shift; my $self = $class->SUPER::new($service, "/org/freedesktop/Notifications"); bless $self, $class; return $self; } dbus_method("Notify", ["string", "uint32", "string", "string", "string", ["array", "string"], ["dict", "string", "string"], "int32"], ["uint32"]); sub Notify { my $self = shift; my $action = shift; my $id = shift; my $icon = shift; my $summary = shift; my $body = shift; my $actions = shift; my $hints = shift; my $timeout = shift; my $txt = '<span size=\\"large\\" weight=\\"bold\\">' . $summary . '</span>\n' . $body; my $cmd = 'yad --text="' . $txt .'" --image="' . $icon . '" --timeout=' . int($timeout / 100); my $pid = fork(); if (defined($pid)) { exec ($cmd) if (!$pid); } else { print "notify (fork): $!\n"; $pid = 0; } return $pid; } dbus_method("CloseNotification", ["uint32"], [], { no_return => 1 }); sub CloseNotification { my $self = shift; my $id = shift; kill('USR1', $id); } dbus_method("GetCapabilities", [], [["array", "string"]]); sub GetCapabilities { my $self = shift; return ["actions", "body", "body-hyperlinks", "body-markup", "icon-static", "persistence", "action-icons"]; } dbus_method("GetServerInformation", [], ["string", "string", "string", "string"]); sub GetServerInformation { my $self = shift; return ["Notification Daemon", "Ydesk", "1.0", "1.2"]; } package main; my $bus = Net::DBus->session(); my $service = $bus->export_service("org.freedesktop.Notifications"); my $object = Notifications->new($service); Net::DBus::Reactor->main->run();