multiwebsearch.pl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/perl
  2. # * Copyright © 2003 Paul Mangan <claws@thewildbeast.co.uk>
  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. use Getopt::Long;
  19. my $where = '';
  20. my $what = '';
  21. GetOptions("where=s" => \$where,
  22. "what=s" => \$what);
  23. $what =~ s/\s/%20/g;
  24. chdir($ENV{HOME} . "/.sylpheed-claws")
  25. || die("Can't find your ~/.sylpheed-claws directory\n");
  26. open (CONF, "<multiwebsearch.conf")
  27. || die("Can't open ~/.sylpheed-claws/multiwebsearch.conf\n");
  28. @conflines = <CONF>;
  29. close CONF;
  30. foreach $confline (@conflines) {
  31. if ($confline =~ m/^$where\|/) {
  32. chomp $confline;
  33. @parts = split(/\|/, $confline);
  34. $url = $parts[1];
  35. if ($parts[2]) {
  36. $what .= $parts[2];
  37. }
  38. }
  39. }
  40. if (!$url) {
  41. die("No url found with the alias \"$where\"\n");
  42. }
  43. open (SYLRC, "<sylpheedrc")
  44. || die("Can't open ~/.sylpheed-claws/sylpheedrc\n");
  45. @rclines = <SYLRC>;
  46. close SYLRC;
  47. foreach $rcline (@rclines) {
  48. if ($rcline =~ m/^uri_open_command/) {
  49. chomp $rcline;
  50. @browser = split(/=/, $rcline);
  51. $browser[1] =~ s/%s/$url$what/;
  52. }
  53. }
  54. system("$browser[1]&");
  55. exit;