Show class and resource name in window title.
#!/usr/bin/perl -w
use lib `fvwm-perllib dir`;
use FVWM::Module;
use General::Parse;
use Net::DBus;
# dbus-send --dest=ru.gentoo.KbddService /ru/gentoo/KbddService ru.gentoo.kbdd.set_layout uint32:1
# Net::DBus
my $bus = Net::DBus->session();
# Net::DBus::RemoteService
my $service = $bus->get_service("ru.gentoo.KbddService");
# Net::DBus::RemoteObject
my $object = $service->get_object("/ru/gentoo/KbddService");
my $module = new FVWM::Module(
Name => "FvwmKbdd",
Mask => M_STRING,
Debug => 1,
);
sub kbdd {
my ($module, $event) = @_;
my ($action, @args) = get_tokens($event->_text);
if ($action eq "hello") {
$module->send("Echo Hello from Kbdd...");
} elsif ($action eq "hel") {
$module->send("Echo xxx...");
} elsif ($action eq "kbdd") {
my $no = $args[0];
if ((0 <= $no) && ($no < 4)) {
$object->set_layout(Net::DBus::dbus_uint32($no));
} else {
$module->send("Echo Error: Kbdd no " . $no . "is not in 1..4 range");
}
} elsif ($action eq "stop") {
$module->send("Echo Kbdd exit...");
$module->terminate;
} else {
$module->send("Echo Kbdd unknown action: " . $action);
}
}
$module->addHandler(M_STRING, \&kbdd);
$module->send("Echo Kbdd loaded...");
# Terminate itself after 5 sec.
# my $scheduler = $module->track('Scheduler');
# $scheduler->schedule(5, sub { $module->terminate; });
$module->event_loop;