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 = ''; |
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'"; |
|
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 |
|
my $fg = $cols[ unpack('C*', $name) % $#cols ]; |
51 |
|
$exec = "xterm -fg $fg -T '$name' -n '$name' -e '$screen'"; |
52 |
|
} else { |
53 |
|
warn "system $screen"; |
54 |
|
system $screen; |
55 |
|
return; |
56 |
|
} |
57 |
|
|
58 |
warn "exec $exec"; |
warn "exec $exec"; |
59 |
exec $exec; |
exec $exec; |
60 |
} |
} |