/usr/lib/perl5/Video/XawTV.pm is in libvideo-capture-v4l-perl 0.902-3ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | package Video::XawTV;
=head1 NAME
Video::XawTV - read, create and edit .xawtvrc's.
=head1 SYNOPSIS
use Video::XawTV;
$rc = new Video::XawTV;
# - or -
$rc = new Video::XawTV "$HOME{ENV}/.xawtv";
$rc->load("otherrcfile");
$rc->save;
$rc->save("filename");
$source = $rc->opt('source');
$rc->opt('source') = "Television";
@channels = $rc->channels;
$rc->channels(@channels);
print $channels[0]{name}; # Arte
print $channels[0]{channel}; # E4
=head1 DESCRIPTION
Pardon? Ha! Haa! Hahahahahaha!!!
=cut
$VESRSION = 0.1;
use Carp;
sub new {
my $self = bless {}, shift;
$self->load(shift) if @_;
$self;
}
my %std_global = (
norm => 1,
capture => 1,
source => 1,
color => 1,
bright => 1,
hue => 1,
contrast => 1,
fullscreen => 1,
wm-off-by => 1,
freqtab => 1,
pixsize => 1,
'jpeg-quality'=> 1,
mixer => 1,
lauch => 1,
);
my %std_channel = (
channel => 1,
fine => 1,
norm => 1,
key => 1,
capture => 1,
source => 1,
color => 1,
bright => 1,
hue => 1,
contrast => 1,
);
sub load {
my $self = shift;
my $fn = shift;
local $_;
open FN, "<$fn" or croak "unable to open '$fn': $!";
$self->{fn} = $fn;
$self->{channels} = [];
my $channel = $self->{global} = {};
my $std = \%std_global;
while (<FN>) {
if (/^#Video::XawTV=#\s*(\S+)\s*=\s*(.*)\s*$/) {
$channel->{lc $1} = $2;
} elsif (/^\s*#(.*)$/) {
# comments are being reordered, but.. my!
$channel->{"#$1"} = 1;
} elsif (/^\s*(\S+)\s*=\s*(.*)\s*$/) {
$channel->{lc $1} = $2;
$std->{lc $1}++;
} elsif (/\s*\[(.*)\]\s*$/) {
push @{$self->{channels}}, $channel = { name => $1 };
$std = \%std_channel;
} elsif (/\S/) {
chomp;
croak "unparsable statement in '$fn': '$_'";
}
}
close FN;
}
sub save_hash {
my ($fh, $hash, $std) = @_;
while (my ($k,$v) = each %$hash) {
next if $k eq 'name';
if ($k =~ /^#/) {
print $fh $k, "\n";
} else {
print $fh "#Video::XawTV=#" unless $std->{lc $k};
print $fh "$k = $v\n";
}
}
print $fh "\n";
}
sub save {
my $self = shift;
my $fn = shift || $self->{fn};
open FN,">$fn~" or croak "unable to open '$fn~' for writing: $!";
save_hash(*FN, $self->{global}, \%std_global);
for (@{$self->{channels}}) {
print FN "[", $_->{name}, "]\n";
save_hash(*FN, $_, \%std_channel);
}
close FN;
rename "$fn~", $fn or croak "unable to replace '$fn': $!";
}
sub opt {
my $self = shift;
my $opt = shift;
$self->{global}{$opt} = shift if @_;
$self->{global}{$opt};
}
sub channels {
my $self = shift;
if (@_) {
$self->{channels} = ref $_[0] eq "ARRAY" ? $_[0] : [@_];
}
wantarray ? @{$self->{channels}} : $self->{channels};
}
1;
|