#!/usr/bin/perl -w
-# Copyright © 2008-2013 Jamie Zawinski <jwz@jwz.org>
+# Copyright © 2008-2014 Jamie Zawinski <jwz@jwz.org>
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
use strict;
my $progname = $0; $progname =~ s@.*/@@g;
-my $version = q{ $Revision: 1.6 $ }; $version =~ s/^[^\d]+([\d.]+).*/$1/;
+my ($version) = ('$Revision: 1.12 $' =~ m/\s(\d[.\d]+)\s/s);
my $verbose = 0;
}
$xlockmore_default_opts .=
"{\"-wireframe\", \".wireframe\", XrmoptionNoArg, \"true\"},\n" .
- "{\"-3d\", \".use3d\", XrmoptionNoArg, \"true\"},\n";
+ "{\"-3d\", \".use3d\", XrmoptionNoArg, \"true\"},\n" .
+ "{\"-no-3d\", \".use3d\", XrmoptionNoArg, \"false\"},\n";
+
+my $thread_default_opts =
+ "{\"-threads\", \".useThreads\", XrmoptionNoArg, \"True\"},\n" .
+ "{\"-no-threads\", \".useThreads\", XrmoptionNoArg, \"False\"},\n";
my $analogtv_default_opts = '';
foreach (qw(color tint brightness contrast)) {
$analogtv_default_opts .= "{\"-tv-$_\", \".TV$_\", XrmoptionSepArg, 0},\n";
}
+$analogtv_default_opts .= $thread_default_opts;
+
# Returns two tables:
$file = "glx/$file" unless (-f $file);
my $body = '';
- local *IN;
- open (IN, "<$file") || error ("$file: $!");
- while (<IN>) { $body .= $_; }
- close IN;
+ open (my $in, '<', $file) || error ("$file: $!");
+ while (<$in>) { $body .= $_; }
+ close $in;
$file =~ s@^.*/@@;
my $xlockmore_p = 0;
+ my $thread_p = ($body =~ m/THREAD_DEFAULTS/);
my $analogtv_p = ($body =~ m/ANALOGTV_DEFAULTS/);
$body =~ s@/\*.*?\*/@@gs;
$body =~ s@^#\s*(if|ifdef|ifndef|elif|else|endif).*$@@gm;
- $body =~ s/ANALOGTV_(DEFAULTS|OPTIONS)//gs;
+ $body =~ s/(THREAD|ANALOGTV)_(DEFAULTS|OPTIONS)(_XLOCK)?//gs;
print STDERR "$progname: $file: defaults:\n" if ($verbose > 2);
my %res_to_val;
$switch_to_res{-bg} = 'background: %';
my ($ign, $opts) = ($body =~ m/(_options|\bopts)\s*\[\]\s*=\s*{(.*?)}\s*;/s);
- if ($xlockmore_p || $analogtv_p || $opts) {
+ if ($xlockmore_p || $thread_p || $analogtv_p || $opts) {
$opts = '' unless $opts;
$opts .= ",\n$xlockmore_default_opts" if ($xlockmore_p);
+ $opts .= ",\n$thread_default_opts" if ($thread_p);
$opts .= ",\n$analogtv_default_opts" if ($analogtv_p);
foreach (split (/,\s*\n/, $opts)) {
$body =~ s/</\001</gs;
$body =~ s/\001(<option)/$1/gs;
+ my $video = undef;
+
print STDERR "$progname: $file: options:\n" if ($verbose > 2);
foreach (split (m/\001/, $body)) {
next if (m/^\s*$/s);
error ("$progname: $file: unparsable: $_") unless $type;
next if ($type =~ m@^/@);
- if ($type =~ m/^([hv]group|\?xml|command|string|file|_description|xscreensaver-(image|text))/s) {
+ if ($type =~ m/^([hv]group|\?xml|command|string|file|_description|xscreensaver-(image|text|updater))/s) {
} elsif ($type eq 'screensaver') {
my ($name) = ($args =~ m/\b_label\s*=\s*\"([^\"]+)\"/);
push @result, $val;
print STDERR "$progname: $file: name: $name\n" if ($verbose > 2);
+ } elsif ($type eq 'video') {
+ error ("$file: multiple videos") if $video;
+ ($video) = ($args =~ m/\bhref="(.*?)"/);
+ error ("$file: unparsable video") unless $video;
+ error ("$file: unparsable video URL")
+ unless ($video =~ m@^https?://www\.youtube\.com/watch\?v=[^?&]+$@s);
+
} elsif ($type eq 'number') {
my ($arg) = ($args =~ m/\barg\s*=\s*\"([^\"]+)\"/);
my ($val) = ($args =~ m/\bdefault\s*=\s*\"([^\"]+)\"/);
}
}
+# error ("$file: no video") unless $video;
+ print STDERR "\n$file: WARNING: no video\n\n" unless $video;
+
return @result;
}