1 |
dpavlin |
171 |
package x11; |
2 |
|
|
|
3 |
|
|
use warnings; |
4 |
|
|
use strict; |
5 |
|
|
|
6 |
|
|
my @cols; |
7 |
|
|
|
8 |
|
|
my $last_col = ''; |
9 |
|
|
open(my $rgb, '<', '/etc/X11/rgb.txt'); |
10 |
|
|
while(<$rgb>) { |
11 |
|
|
chomp; |
12 |
|
|
my (undef,$col) = split(/\s\s+/,$_,2); |
13 |
|
|
next unless $col =~ m{Light}; |
14 |
|
|
push @cols, $col if $last_col ne $col; |
15 |
|
|
$last_col = $col; |
16 |
|
|
} |
17 |
|
|
close($rgb); |
18 |
|
|
|
19 |
|
|
sub xterm { |
20 |
|
|
my ( $name, $cmd ) = @_; |
21 |
|
|
|
22 |
|
|
my $fg = $cols[ unpack('C*', $name) % $#cols ]; |
23 |
|
|
my $exec = "xterm -fg $fg -T '$name' -n '$name' -e '$cmd || $server::base_dir/bin/beep.sh'"; |
24 |
|
|
warn "exec $exec"; |
25 |
|
|
exec $exec; |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
1; |