madf: (Default)
urxvt рулить нереально.
Чисто випадково у чийомусь файлі ресурсів побачив URxvt.urlLauncher. Почав копати. Виявляється, через механізм розширень (на perl) можна кліком по URL відкривати його у браузері.
Все добре, але ні одна собака не написала як це зробити не тупо по кліку, а, скажімо, по Ctrl+Button1, як мені потрібно. Навіть у офіційній документації нічого немає. А виявляється, все просто. Треба до номеру кнопки додати префікс:
C - Ctrl;
S - Shift;
M - Meta.
Довелось зазирнути у /usr/lib/urxvt/perl/matcher, але моїх знань Perl вистачило.
URxvt.perl-ext-common:  default,matcher                                         
URxvt.urlLauncher:      firefox                                                 
URxvt.matcher.button:   C1                                                      
URxvt.colorUL:          #86a2be
madf: (Default)
my $relay_agent = join (':', map {if (length == 1) {'0' . $_} else {$_}} @agent_id);
Це прекрасно, я вважаю.

DBus

Oct. 9th, 2009 11:57 am
madf: (Default)
Тут, нещодавно, [livejournal.com profile] aceler писав про DBus, qdbus і всяке таке...
Я вирішив викласти свій скрипт now-playing для irssi. На Perl я ніколи нічого не писав, не сильно сваріть :)
use Irssi;
use Net::DBus;
use strict;

use vars qw($VERSION %IRSSI);

$VERSION = "2.00";
%IRSSI = (

    authors     => 'madf',
    name        => 'Amarok status',
    description => 'Shows now playing',
    license     => 'Public Domain'
);

my $bus = Net::DBus->session;

my $amarok = $bus->get_service('org.kde.amarok');
my $object = $amarok->get_object('/Player',
                                 'org.freedesktop.MediaPlayer');


sub cmd_song {
    my ($data, $server, $channel) = @_;
    my $title;

    if (!$server || !$server->{connected}) {

        Irssi::print("Not connected to server");
        return;
    }

    my $metadata = $object->GetMetadata();

    my $artist = $$metadata{"artist"};
    my $title = $$metadata{"title"};
    my $bitrate = $$metadata{"audio-bitrate"};
    
    my $out = 'np(AmK): \'' . $artist . ' - ' . $title . '\' with ' . $bitrate . ' kbps';
    
    if ($channel && ($channel->{type} eq "CHANNEL" || $channel->{type} eq "QUERY")) {

        $channel->command("MSG " . $channel->{name} . " " . $out);
    } else {

    }
    
}

Irssi::command_bind('amarok', 'cmd_song');




syntax highlighted by Code2HTML, v. 0.9.1

Profile

madf: (Default)
madf

April 2018

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930     

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 15th, 2025 11:01 pm
Powered by Dreamwidth Studios