/[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 430 - (hide annotations)
Sun Sep 13 16:07:33 2009 UTC (14 years, 7 months ago) by dpavlin
File size: 982 byte(s)
without display just exec command

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 228 $name =~ s{\s+}{-}g;
26 dpavlin 202 my $screenrc = "/tmp/$name.screenrc";
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 dpavlin 214 my $hash;
52     $hash += ord($_) foreach ( split //, $name );
53     my $fg = $cols[ $hash % $#cols ];
54 dpavlin 202 $exec = "xterm -fg $fg -T '$name' -n '$name' -e '$screen'";
55     } else {
56 dpavlin 430 $exec = $cmd;
57 dpavlin 202 }
58    
59 dpavlin 171 warn "exec $exec";
60     exec $exec;
61     }
62    
63     1;

  ViewVC Help
Powered by ViewVC 1.1.26