google_search.pl 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/perl
  2. # * Copyright 2003-2007 Paul Mangan <paul@claws-mail.org>
  3. # *
  4. # * This file is free software; you can redistribute it and/or modify it
  5. # * under the terms of the GNU General Public License as published by
  6. # * the Free Software Foundation; either version 2 of the License, or
  7. # * (at your option) any later version.
  8. # *
  9. # * This program is distributed in the hope that it will be useful, but
  10. # * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # * General Public License for more details.
  13. # *
  14. # * You should have received a copy of the GNU General Public License
  15. # * along with this program; if not, write to the Free Software
  16. # * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. # *
  18. # Changes:
  19. # Feb 2007: add support for non ISO-8859-1 compatible locales
  20. # by Alex Gorbachenko <agent_007@immo.ru>
  21. #
  22. use URI::Escape;
  23. use POSIX qw(locale_h);
  24. use Text::Iconv;
  25. my $google = "http://www.google.com/search?q";
  26. $_ = <>;
  27. $locale = setlocale(LC_CTYPE);
  28. $locale =~ s/\S+\.//;
  29. $converter = Text::Iconv->new("$locale", "UTF-8");
  30. $safe=uri_escape($converter->convert("$_"));
  31. chdir($ENV{HOME} . "/.claws-mail") || die("Can't find your .claws-mail directory\n");
  32. open (SYLRC, "<clawsrc") || die("Can't open the clawsrc file\n");
  33. @rclines = <SYLRC>;
  34. close SYLRC;
  35. foreach $rcline (@rclines) {
  36. if ($rcline =~ m/^uri_open_command/) {
  37. chomp $rcline;
  38. @browser = split(/=/, $rcline);
  39. $browser[1] =~ s/%s/$google=$safe/;
  40. }
  41. }
  42. system("$browser[1]&");
  43. exit;