summaryrefslogtreecommitdiff
path: root/support/acroread_new
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/acroread_new
Initial commit
Diffstat (limited to 'support/acroread_new')
-rwxr-xr-xsupport/acroread_new/acroread_new.pl126
1 files changed, 126 insertions, 0 deletions
diff --git a/support/acroread_new/acroread_new.pl b/support/acroread_new/acroread_new.pl
new file mode 100755
index 0000000000..bbca000d68
--- /dev/null
+++ b/support/acroread_new/acroread_new.pl
@@ -0,0 +1,126 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
+ if 0;
+use strict;
+$^W=1; # turn warning on
+#
+# acroread_new
+#
+# Copyright (C) 2002 Heiko Oberdiek.
+#
+# This program may be distributed and/or modified under the
+# conditions of the LaTeX Project Public License, either version 1.2
+# of this license or (at your option) any later version.
+# The latest version of this license is in
+# http://www.latex-project.org/lppl.txt
+# and version 1.2 or later is part of all distributions of LaTeX
+# version 1999/12/01 or later.
+#
+# This file "acroread_new.pl" may be renamed to "acroread_new"
+# for installation purposes.
+#
+# Documentation: acroread_new --help
+#
+my $file = "acroread_new.pl";
+my $program = uc($&) if $file =~ /^([\w_]+)/;
+my $version = "1.0";
+my $date = "2002/01/10";
+my $author = "Heiko Oberdiek";
+my $copyright = "Copyright (c) 2002 by $author.";
+#
+# History:
+# 2002/01/10 v1.0: First version.
+#
+
+my $tempdir = "/tmp";
+my $basename = "\L$program\E_$$";
+
+my @acroreadoptions = ();
+foreach(@ARGV) {
+ if (/^--tempdir=(.*)$/) {
+ $tempdir = $1;
+ next;
+ }
+ if (/^--basename=(.*)$/) {
+ $basename = $1;
+ next;
+ }
+ if (/^--help$/) {
+ print <<"END_OF_HELP";
+$program $version, $date - $copyright
+
+Function: If acroread is started again, it will use
+ a previously started instance. Exiting acroread will
+ close all windows that belongs to that instance.
+ This script runs acroread with a changed name, so
+ several instances of acroread can be started
+ independently from each other.
+
+Caution: ~/.acrorc is read and written by each
+ acroread instance. That can cause problems,
+ if several instances are closed at the same
+ time, for example.
+
+Syntax: \L$program\E [options] [arguments for acroread]
+
+Options:
+ --help print usage
+ --tempdir=<name> directory <name> for temporary files ($tempdir)
+ --basename=<name> basename of the acroread instance ($basename)
+
+The help screen of acroread is available by option "-help".
+
+END_OF_HELP
+ exit 0;
+ }
+ push(@acroreadoptions, $_);
+}
+$tempdir .= "/" unless $tempdir eq "" or $tempdir =~ /\/$/;
+
+my $acroread_org = `which acroread`;
+my $acroread_new = "$tempdir$basename.sh";
+my $cmd_new = "$tempdir$basename.bin";
+
+sub clean {
+ unlink($acroread_new);
+ unlink($cmd_new);
+}
+
+$SIG{__DIE__} = \&clean;
+$SIG{'HUP'} = \&clean;
+$SIG{'QUIT'} = \&clean;
+$SIG{'TERM'} = \&clean;
+
+open(IN, $acroread_org) or
+ die "!!! Error: Cannot open `$acroread_org'!\n";
+open(OUT, ">$acroread_new") or
+ die "!!! Error: Cannot write `$acroread_new'!\n";
+
+while (<IN>) {
+ print OUT;
+ if (/^ACRO_EXEC_CMD=/) {
+ print OUT <<"ENDMARK";
+
+\#
+\# [$program] Make link for new acroread instance.
+\#
+ACRO_EXEC_CMD_NEW="$cmd_new"
+ln -s "\$ACRO_EXEC_CMD" "\$ACRO_EXEC_CMD_NEW"
+if [ -h "\$ACRO_EXEC_CMD_NEW" ] ; then
+ ACRO_EXEC_CMD="\$ACRO_EXEC_CMD_NEW"
+else
+ echo "ERROR: Creation of symbolic link '\$ACRO_EXEC_CMD_NEW' failed."
+ exit 1
+fi
+
+ENDMARK
+ }
+}
+close(IN);
+close(OUT);
+chmod('0500', $acroread_new);
+
+system("$acroread_new @acroreadoptions");
+
+clean();
+
+__END__