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; |
22 |
sub xterm { |
sub xterm { |
23 |
my ( $name, $cmd ) = @_; |
my ( $name, $cmd ) = @_; |
24 |
|
|
25 |
|
$name =~ s{\s+}{-}g; |
26 |
my $screenrc = "/tmp/$name.screenrc"; |
my $screenrc = "/tmp/$name.screenrc"; |
27 |
|
|
28 |
my ($autodetach,$detach) = $ENV{DISPLAY} ? ('off','') : ( 'on', 'detach' ); |
my ($autodetach,$detach) = $ENV{DISPLAY} ? ('off','') : ( 'on', 'detach' ); |
48 |
my $exec; |
my $exec; |
49 |
|
|
50 |
if ( $ENV{DISPLAY} ) { |
if ( $ENV{DISPLAY} ) { |
51 |
my $fg = $cols[ unpack('C*', $name) % $#cols ]; |
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'"; |
$exec = "xterm -fg $fg -T '$name' -n '$name' -e '$screen'"; |
55 |
|
warn "XXXX $exec"; |
56 |
} else { |
} else { |
57 |
warn "system $screen"; |
warn "system $screen"; |
58 |
system $screen; |
system $screen; |