frakswe

surfraw.cgi for w3m

May 4th, 2020
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.50 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. #
  3. # # 04.05.2020
  4. # surfraw.cgi for w3m
  5. # barely tested and created by Jonny Högsten aka frakswe
  6. # (learned from w3m/Bonus/google.cgi & surfraw/examples/hooks.lua)
  7. #
  8. # if the script doesn't execute properly please cut and paste it or
  9. # make sure the line-endings are set correctly for your system,
  10. # pastebin downloads by default appears to be in dos/windows format.
  11. #
  12. # example-usage: open urlinput and type for ex. "youtube:gotbletu"
  13. # or in the commandline: "w3m urban:woke"
  14. # to do multistring searching you have to use a "+" character instead of space,
  15. # for ex. google:get+woke+go+broke
  16. #
  17. # installation:
  18. # 1:
  19. # > sudo cp ./surfraw.cgi /usr/local/libexec/w3m/cgi-bin/
  20. # > sudo chmod +x /usr/local/libexec/w3m/cgi-bin/surfraw.cgi
  21. #
  22. # 2:
  23. # create file if not already existing:
  24. # > touch ~/.w3m/urimethodmap
  25. #
  26. # and do for ex.:
  27. # > echo 'google: file:/cgi-bin/surfraw.cgi?%s
  28. # duckduckgo: file:/cgi-bin/surfraw.cgi?%s
  29. # stack: file:/cgi-bin/surfraw.cgi?%s
  30. # youtube: file:/cgi-bin/surfraw.cgi?%s
  31. # urban: file:/cgi-bin/surfraw.cgi?%s' >>~/.w3m/urimethodmap
  32. #
  33. # ([elvi]: file:/cgi-bin/surfraw.cgi%s)
  34. # w3m needs to be restarted each time you make changes in the urimethodmap file.
  35. #
  36. # 3:
  37. # Go into w3m's settings and add under Directory Settings:
  38. # Directory corresponding to cgi-bin    /usr/local/libexec/w3m/cgi-bin
  39. #
  40. #
  41. $search = $ENV{"QUERY_STRING"};
  42. $search =~ tr/:/ /;
  43. $search =~ tr/+/ /;
  44. $url = `surfraw -p $search`;
  45. print <<EOF;
  46. w3m-control: GOTO $url
  47. EOF
Add Comment
Please, Sign In to add comment