/[pxelator]/lib/PXElator/x11.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/x11.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 171 by dpavlin, Thu Aug 6 22:15:09 2009 UTC revision 226 by dpavlin, Sun Aug 16 21:10:42 2009 UTC
# Line 3  package x11; Line 3  package x11;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6    use log;
7    use File::Slurp;
8    
9  my @cols;  my @cols;
10    
11  my $last_col = '';  my $last_col = '';
12  open(my $rgb, '<', '/etc/X11/rgb.txt');  open(my $rgb, '<', '/etc/X11/rgb.txt');
13  while(<$rgb>) {  while(<$rgb>) {
14          chomp;          chomp;
15          my (undef,$col) = split(/\s\s+/,$_,2);          my $col = $1 if m{(\S+)\s*$};
16          next unless $col =~ m{Light};          next unless $col =~ m{Light};
17          push @cols, $col if $last_col ne $col;          push @cols, $col if $last_col ne $col;
18          $last_col = $col;          $last_col = $col;
# Line 19  close($rgb); Line 22  close($rgb);
22  sub xterm {  sub xterm {
23          my ( $name, $cmd ) = @_;          my ( $name, $cmd ) = @_;
24    
25          my $fg = $cols[ unpack('C*', $name) % $#cols ];          my $screenrc = "/tmp/$name.screenrc";
26          my $exec = "xterm -fg $fg -T '$name' -n '$name' -e '$cmd || $server::base_dir/bin/beep.sh'";          $screenrc =~ s{\s+}{-}g;
27    
28            my ($autodetach,$detach) = $ENV{DISPLAY} ? ('off','') : ( 'on', 'detach' );
29    
30            write_file $screenrc, qq|
31    
32    autodetach $autodetach
33    altscreen off
34    defscrollback 10000
35    startup_message off
36    
37    sessionname $name
38    
39    screen -t $name $cmd
40    logfile $log::dir/$name.log
41    log on
42    
43    $detach
44    
45    |;
46    
47            my $screen = "screen -R $name -c $screenrc";
48            my $exec;
49    
50            if ( $ENV{DISPLAY} ) {
51                    my $hash;
52                    $hash += ord($_) foreach ( split //, $name );
53                    my $fg = $cols[ $hash % $#cols ];
54                    $exec = "xterm -fg $fg -T '$name' -n '$name' -e '$screen'";
55    warn "XXXX $exec";
56            } else {
57                    warn "system $screen";
58                    system $screen;
59                    return;
60            }
61    
62          warn "exec $exec";          warn "exec $exec";
63          exec $exec;          exec $exec;
64  }  }

Legend:
Removed from v.171  
changed lines
  Added in v.226

  ViewVC Help
Powered by ViewVC 1.1.26