Navigation Menu

Skip to content

Commit

Permalink
new: @available_browsers
Browse files Browse the repository at this point in the history
new: _debian_browser
moved lynx/w3m code to open_in_terminal
internal htmlview only for linux (because of paths)
  • Loading branch information
eserte committed Sep 7, 2006
1 parent f9544ae commit 1093599
Showing 1 changed file with 56 additions and 27 deletions.
83 changes: 56 additions & 27 deletions WWWBrowser.pm
Expand Up @@ -2,10 +2,10 @@
# -*- perl -*-

#
# $Id: WWWBrowser.pm,v 2.31 2006/02/26 10:28:51 eserte Exp $
# $Id: WWWBrowser.pm,v 2.32 2006/09/07 23:36:52 eserte Exp $
# Author: Slaven Rezic
#
# Copyright (C) 1999,2000,2001,2003,2005 Slaven Rezic. All rights reserved.
# Copyright (C) 1999,2000,2001,2003,2005,2006 Slaven Rezic. All rights reserved.
# This package is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
Expand All @@ -16,19 +16,22 @@
package WWWBrowser;

use strict;
use vars qw(@unix_browsers $VERSION $VERBOSE $initialized $os $fork
use vars qw(@unix_browsers @available_browsers
$VERSION $VERBOSE $initialized $os $fork
$got_from_config $ignore_config);

$VERSION = sprintf("%d.%02d", q$Revision: 2.31 $ =~ /(\d+)\.(\d+)/);
$VERSION = sprintf("%d.%02d", q$Revision: 2.32 $ =~ /(\d+)\.(\d+)/);

@unix_browsers = qw(_internal_htmlview
_default_gnome _default_kde
htmlview
mozilla galeon konqueror netscape Netscape kfmclient
dillo w3m lynx
mosaic Mosaic
chimera arena tkweb
explorer) if !@unix_browsers;
@available_browsers = qw(_debian_browser _internal_htmlview
_default_gnome _default_kde
htmlview
mozilla firefox galeon konqueror netscape Netscape kfmclient
dillo w3m lynx
mosaic Mosaic
chimera arena tkweb
explorer);

@unix_browsers = @available_browsers if !@unix_browsers;

init();

Expand Down Expand Up @@ -92,20 +95,7 @@ sub start_browser {
foreach my $browser (@browsers) {
next if ($browser !~ /^_/ && !is_in_path($browser));
if ($browser =~ /^(lynx|w3m)$/) { # text-orientierte Browser
if (defined $ENV{DISPLAY} && $ENV{DISPLAY} ne "") {
foreach my $term (qw(xterm kvt gnome-terminal)) {
if (is_in_path($term)) {
exec_bg($term,
($term eq 'gnome_terminal' ? '-x' : '-e'),
$browser, $url);
return 1;
}
}
} else {
# without X11: not in background!
system($browser, $url);
return 1;
}
return 1 if open_in_terminal($browser, $url, %args);
next;
}

Expand Down Expand Up @@ -171,6 +161,20 @@ sub start_browser {
} else {
return 1;
}
} elsif ($browser eq '_debian_browser') {
if ($ENV{DISPLAY}) {
if (-x "/etc/alternatives/gnome-www-browser") { # usually firefox or mozilla
exec_bg($browser, $url); # use additional args if mozilla, learn args for firefox
return 1;
} elsif (-x "/etc/alternatives/x-www-browser") { # usually dillo
exec_bg($browser, $url);
return 1;
}
} else {
if (-x "/etc/alternatives/www-browser") {
return 1 if open_in_terminal("/etc/alternatives/www-browser", $url, %args);
}
}
} else {
exec_bg($browser, $url);
return 1;
Expand Down Expand Up @@ -319,6 +323,7 @@ sub get_from_config {
my @browser;
while(<CFG>) {
chomp;
next if /^\s*\#/;
push @browser, $_;
}
close CFG;
Expand All @@ -340,7 +345,9 @@ sub _guess_and_expand_url {
}
}

# A port of htmlview to perl
# A port of htmlview to perl.
#
# This may work on linux, but not on *BSD because of different paths.
sub htmlview {
#!/bin/bash
#
Expand Down Expand Up @@ -370,6 +377,8 @@ sub htmlview {
#XXX[ -e /etc/htmlview.conf ] && source /etc/htmlview.conf
#XXX[ -e ~/.htmlviewrc ] && source ~/.htmlviewrc

return 0 if $^O ne "linux";

my(@args) = @_;

my @TERMS_KDE = qw(/usr/bin/konsole /usr/bin/kvt);
Expand Down Expand Up @@ -466,6 +475,26 @@ sub htmlview {

}

sub open_in_terminal {
my($browser, $url, %args) = @_;

if (defined $ENV{DISPLAY} && $ENV{DISPLAY} ne "") {
foreach my $term (qw(xterm kvt gnome-terminal)) {
if (is_in_path($term)) {
exec_bg($term,
($term eq 'gnome_terminal' ? '-x' : '-e'),
$browser, $url);
return 1;
}
}
} else {
# without X11: not in background!
system($browser, $url);
return 1;
}
0;
}

# REPO BEGIN
# REPO NAME file_name_is_absolute /home/e/eserte/src/repository
# REPO MD5 89d0fdf16d11771f0f6e82c7d0ebf3a8
Expand Down

0 comments on commit 1093599

Please sign in to comment.