summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakhelp
blob: d4e9d264d7e81902857ec1ae7f53f1410b0e0a30 (plain)
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
#!/usr/bin/perl

use strict;
use diagnostics;
use lib qw(/usr/lib/libDrakX);

use standalone;     #- warning, standalone must be loaded very first, for 'explanations'

use interactive;
use common;
use lang;
use any;

die "Usage: drakhelp <help_path>" if @ARGV != 1;

my $in = interactive->vnew;

my $locale = lang::read('', $>);
printf("lang is %s\n",$locale->{lang});
$locale->{lang} = 'en' unless member($locale->{lang}, qw(en es fr));
my $path2help = "/usr/share/doc/mandrake/" . $locale->{lang} . "/";
my $path = $ARGV[0] =~ /^http|^www/ ? $ARGV[0] : $path2help . $ARGV[0];

-e $path or $in->do_pkgs->install('mandrake_doc-drakxtools-' . $locale->{lang});
-e $path or $in->ask_warn('Mandrake Help Center', N("%s cannot be displayed \n. No Help entry of this type\n", $path));

my $wm = any::running_window_manager();
my %launchhelp = (
		  'kwin' => sub { system("mdklaunchhelp " . $path . "&") },
		  'gnome-session' => sub { system("yelp ghelp://" . $path . "&") },
		  'other' => sub { my $browser = $ENV{BROWSER} || find { -x "/usr/bin/$_" } qw(mozilla konqueror galeon) or $in->ask_warn('drakhelp', N("No browser is installed on your system, Please install one if you want to browse the help system"));
				    standalone::explanations("Connection to help system at $path");
				    system("$browser " . $path . "&") 
				}
		 );
member($wm, 'kwin', 'gnome-session') or $wm = 'other';
-e $path and eval { $launchhelp{$wm}->() };