-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi,
On 29.08.2010 17:22, Marc Lehmann wrote: > On Sun, Aug 29, 2010 at 03:07:03PM +0200, Jochen Keil > <[email protected]> wrote: >>> You have to set reverse video mode (e.g. by outputting the >>> relevant command sequence or manipulating the rendset). >> How would i do that? Sorry for being ignorant, but i thought >> scr_xor_span would do just that. :) > > See urxvt(7) for all command sequences. thanks for the hint. Cmd_parse("\033[?5h") respectively cmd_parse("\033[?5l") do the trick for me. However i'm having a problem with $self->refresh(). It doesn't happen instantly. The terminal only gets refreshed if I hit a key (it is not necessary that the terminal is focused though). I also tried cmd_parse("\033[7;7t") but I'm not sure about that. Maybe you could give me a short explanation on how to understand this: "ESC [ Ps;Pt t" Window Operations Ps = 7 Refresh screen once >>> Just swap foreground and background colours, thats how uxvt does >>> it - no rvid at all, which is not what you seem to want though. >> OK, so i tried this: > > No, I mean, swap the colours, not the indices. You can do this easily > from a shellscript by using the OSC 10/11 sequences for example (look > for "XTerm Operating System Commands"). > >> It's basically a listener on dbus for the 'BrightnessChanged' >> signal and then unlocks a barrier. It's not yet done, just for you >> to get an idea what i'm trying to do. > > Yes, this makes it very clear. > > Hint: if you want to make the plug-in portable, don't use the windows > process emulation code (so called "threads" in perl, even though they > have nothing to do with threads) - it makes no sense to use it under > unix, and is often disabled because of the very large overhead it > causes. I'm using this perl version: $ perl --version This is perl 5, version 12, subversion 1 (v5.12.1) built for i686-linux-thread-multi The plugin works so far (for me), but I don't know how it would behave without threads. Writing it without threads would be tedious though since I'd have to use pipes (would a pipe in /tmp be portable anyway?). Any suggestions on how to do it better are welcome. I'm not a perl hacker (honestly these are my first steps with perl..) but I have enough experience with other languages (e.g. tcl which is quite comparable). > And last not least, keep in mind that urxvt does not support the > windows process emulation code, so you have to fix the race > conditions that ensue somehow (e.g. by not calling urxvt functions > from any other "thread" than the urxvt one). My plugin now isn't dependant on locks anymore.. yet there is still the problem with refreshing. I could set a 1s timer but I'm not to fond of polling. I've attached the improved version of the plugin for you. I'm using async now because the block is turned into a closure (at least the doc says so :) ). Kind regards, Jochen -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAkx9FAkACgkQtVwvsA+W4CA8dgCfRFW6jxNKM3yXD1SvDbvbvb6N +8sAn2CxrVJ6DF+ilvxl9rD6DOrM6/7e =1yVF -----END PGP SIGNATURE-----
#! perl
use threads;
use threads::shared;
use Net::DBus;
use Net::DBus::Reactor;
my $exit_signal : shared;
sub on_start {
my ($self) = @_;
async {
my $reversed = 0;
my $term = $self->{term};
my $bus = Net::DBus->session;
my $upower = $bus->get_service('org.gnome.PowerManager');
my $object = $upower->get_object(
'/org/gnome/PowerManager/Backlight',
'org.gnome.PowerManager.Backlight');
if ($object->GetBrightness() < 80) {
$term->cmd_parse("\033[?5h");
$term->cmd_parse("\033[7;7t");
$term->want_refresh();
$reversed = 1;
}
$object->connect_to_signal('BrightnessChanged',
sub {
my $brightness = (shift);
if ($brightness >= 80 && $reversed == 1) {
$term->cmd_parse("\033[?5l");
$term->cmd_parse("\033[7;7t");
$term->want_refresh();
$reversed = 0;
} elsif ($brightness < 80 && $reversed == 0) {
$term->cmd_parse("\033[?5h");
$term->cmd_parse("\033[7;7t");
$term->want_refresh();
$reversed = 1;
}
});
my $reactor = Net::DBus::Reactor->main();
async {
lock($exit_signal);
cond_wait($exit_signal);
$reactor->shutdown();
};
$reactor->run();
};
()
}
sub on_destroy {
lock($exit_signal);
cond_signal($exit_signal);
()
}
rvid-on-brightnesschanged.sig
Description: PGP signature
_______________________________________________ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
