Remove support for the obsolete AWN
[claws.git] / tools / ddg_search.pl
blobb7d5f58fd46d017676136bf9b05b44470448ea38
1 #!/usr/bin/perl
3 # * Copyright 2003-2019 Paul Mangan <paul@claws-mail.org>
4 # *
5 # * This file is free software; you can redistribute it and/or modify it
6 # * under the terms of the GNU General Public License as published by
7 # * the Free Software Foundation; either version 3 of the License, or
8 # * (at your option) any later version.
9 # *
10 # * This program is distributed in the hope that it will be useful, but
11 # * WITHOUT ANY WARRANTY; without even the implied warranty of
12 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # * General Public License for more details.
14 # *
15 # * You should have received a copy of the GNU General Public License
16 # * along with this program; if not, write to the Free Software
17 # * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # *
20 # Changes:
21 # Feb 2007: add support for non ISO-8859-1 compatible locales
22 # by Alex Gorbachenko <agent_007@immo.ru>
25 use URI::Escape;
26 use POSIX qw(locale_h);
27 use locale;
28 use Text::Iconv;
30 my $ddg = "https://duckduckgo.com/?q";
31 $_ = <>;
33 $locale = setlocale(LC_CTYPE);
34 $locale =~ s/\S+\.//;
36 $converter = Text::Iconv->new("$locale", "UTF-8");
37 $safe=uri_escape($converter->convert("$_"));
39 my $config_dir = `claws-mail --config-dir` or die("ERROR:
40 You don't appear to have Claws Mail installed\n");
41 chomp $config_dir;
43 chdir($ENV{HOME} . "/$config_dir") or die("ERROR:
44 Claws Mail config directory not found [~/$config_dir]
45 You need to run Claws Mail once, quit it, and then rerun this script\n");
47 open (CMRC, "<clawsrc") || die("Can't open the clawsrc file\n");
48 @rclines = <CMRC>;
49 close CMRC;
51 foreach $rcline (@rclines) {
52 if ($rcline =~ m/^uri_open_command/) {
53 chomp $rcline;
54 @browser = split(/=/, $rcline);
55 $browser[1] =~ s/%s/$ddg=$safe/;
58 system("$browser[1]&");
60 exit;