in reply to Re: LWP to open a new browser window
in thread LWP to open a new browser window
use File::Which::Cached 'which'; sub OpenBrowser { my ( $url ) = @_; my @cmd = GetBrowserCmd(); system @cmd, $url; } sub GetBrowserCmd { if( $^O =~ /win32/ ){ return 1, qw'cmd /x /c start'; } elsif( $^O =~ /mac|darwin/ ){ } #~ else { my $xdg = which("xdg-open"); if( -e $xdg and -x _ ){ return $xdg; } #~ http://stackoverflow.com/questions/3743693/macro-detect-kde-or-gnom +e-in-qt4 #~ KDE_FULL_SESSION variable whereas GNOME has the DESKTOP_SESSION var +iable set to "gnome". if ( eval { $ENV{DESKTOP_SESSION} =~ /gnome/i } ){ my $exe = qx{gconftool-2 --get /desktop/gnome/applications +/browser/exec}; if( -e $exe and -x _ ){ return $exe; } } elsif( exists $ENV{KDE_FULL_SESSION} ){ my $kfmclient = which("kfmclient"); if( -e $kfmclient and -x _ ){ return $kfmclient; } } if( eval { require Mail::Cap; 1} ){ #~ http://tools.ietf.org/html/rfc1524# RFC 1524 - A User Agent Configu +ration Mechanism For Multimedia Mail Format Information for my $mailcap ( "$HOME/.mailcap", ## "$HOME/.mime.types", ## ?? outdated wxMimeTypesManager info ## File::BaseDir - Use the Freedesktop.org base directory specificatio +n qw[ /etc/mailcap /usr/etc/mailcap /usr/local/etc/mailcap ] ){ my $cmd = Mail::Cap->new($mailcap)->viewCmd('text/html +'); if( -e $cmd and -x $cmd ){ return $cmd; } } } } }
|
|---|