-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello Marc,

On 29.08.2010 14:04, Marc Lehmann wrote:
> On Sun, Aug 29, 2010 at 10:23:03AM +0200, Jochen Keil
> <[email protected]> wrote:
>> I am trying to set the rendition bit RS_RVid to make the colors of
>> a terminal permanently reversed. For now I've tried using this:
>
> Are you sure this is really what you want to do? Could you describe
> what you are *really* trying to do, maybe there is a better solution
> for your problem? Or a solution at all, as what you are trying to do
> cannot be done.
What i like to do is this: invert (or swap fore/background) colours so
that my terminal appears brighter (i have a dark background by default)
when i'm in a bright environment.

>> $term->scr_xor_span(0, 0, $term->nrow-1, $term->ncol-1,
>> urxvt::RS_RVid);
>>
>> Unfortunately this doesn't last. On the next refresh (as soon as I
>> type something in the terminal) it will switch back to "normal"
>> colors.
>
> 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. :)

>> So how could make video permanently reversed like after starting
>> urxvt with the reverseVideo resource set?
>
> 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:

  my $rend = urxvt::DEFAULT_RSTYLE;
  my $foreground = urxvt::GET_BASEFG($rend);
  my $background = urxvt::GET_BASEBG($rend);

  $rend = urxvt::SET_FGCOLOR($rend, $background);
  $rend = urxvt::SET_BGCOLOR($rend, $foreground);
  $term->rstyle($rend);

Now the text i'm typing appears inverted but not the rest of the
terminal.. not exactly what i wanted.

> Same is true for scr_rvideo_mode, it will interfere with the visual
> bell.
>
> Same is true for inverting them in a display filter.
>
> All these will change the appearance to be reversed, but will not
> actually reverse the attributes.

I have attached a preliminary version of the plugin i'm trying to write.
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.

Best Regards,

Jochen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkx6W3cACgkQtVwvsA+W4CBIYwCcDWzj6s73A4DbLh8vNeD3l4P7
3xkAnjtPTwHeF7Z/hLiOU6Zt0gh6o7iJ
=FY6R
-----END PGP SIGNATURE-----
#! perl

use threads;
use threads::shared;

use Net::DBus;
use Net::DBus::Reactor;

my $exit_signal : shared;
my $brightness : shared = 100;
my $brightness_changed : shared;
my $reversed : shared = 0;

sub on_start {
  my ($self) = @_;

  my $term = $self->{term};
  my $rend = urxvt::DEFAULT_RSTYLE;
  my $foreground = urxvt::GET_BASEFG($rend);
  my $background = urxvt::GET_BASEBG($rend);

  my $dbus_listener_thread = threads->create("dbus_listener");
  $dbus_listener_thread->detach();

  my $rvid_thread = threads->create(sub {
      while (1) {
      lock($brightness_changed);
      cond_wait($brightness_changed);
        if (($brightness < 80) && ($reversed == 0)) {
          print "brightness < 80\n";
          $rend = urxvt::SET_FGCOLOR($rend, $background);
          $rend = urxvt::SET_BGCOLOR($rend, $foreground);
          $term->rstyle($rend);
          #$term->scr_xor_span(0, 0, $term->nrow-1, $term->ncol-1, 
urxvt::RS_RVid);
          $term->want_refresh();
          $reversed = 1;
        } elsif (($brightness >= 80) && ($reversed == 1)) {
          print "brightness >= 80\n";
          $rend = urxvt::SET_FGCOLOR($rend, $foreground);
          $rend = urxvt::SET_BGCOLOR($rend, $background);
          $term->rstyle($rend);
          #$term->scr_xor_span(0, 0, $term->nrow-1, $term->ncol-1, 
urxvt::RS_RVid);
          $term->want_refresh();
          $reversed = 0;
        }
      }
    });
  $rvid_thread->detach();

  ()
}

sub on_destroy {
  lock($exit_signal);
  cond_signal($exit_signal);
  ()
}

sub dbus_listener {
  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');

  $object->connect_to_signal('BrightnessChanged',
    sub {
      lock($brightness_changed);
      cond_broadcast($brightness_changed);
      $brightness = shift;
    });

  my $reactor = Net::DBus::Reactor->main();

  my $exit_thread = threads->create(sub {
      lock($exit_signal);
      cond_wait($exit_signal);
      print STDERR "shutdown reactor.. ";
      $reactor->shutdown();
      print STDERR "done\n";
    });
  $exit_thread->detach();

  print "start reactor\n";
  $reactor->run();
}

Attachment: rvid-on-brightnesschanged.sig
Description: PGP signature

_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode

Reply via email to