/[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

Annotation of /lib/PXElator/x11.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26