From a798aee74e26d0ad714a09df4f322ee0a6821265 Mon Sep 17 00:00:00 2001 From: speedie Date: Sun, 4 Jun 2023 23:48:06 +0200 Subject: [PATCH] add new page --- pages/Cool spmenu tricks.md | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 pages/Cool spmenu tricks.md diff --git a/pages/Cool spmenu tricks.md b/pages/Cool spmenu tricks.md new file mode 100644 index 0000000..4e1434a --- /dev/null +++ b/pages/Cool spmenu tricks.md @@ -0,0 +1,49 @@ +Cool spmenu tricks +================== + +This wiki article is intended to be a list of cool things you can do with +spmenu that I find very useful, and have changed the way I use my computer. + +1. clipmenu-spmenu + +This is listed in [[User scripts]] too, but clipmenu is extremely useful. +With clipmenu, everything in the clipboard is saved, and you can easily pull up +a spmenu list of everything in your clipboard and then use it again. + +If you're the kind of person that copies a lot of text all the time and then later +wants to use that same text again, this script is extremely useful. + +2. spmenu_run: Web searches + +If you've read [[Functions in spmenu_run]] you're already aware that things like this +can be done with ease, but here's another use of the `run_post_func()` function. + +Open `~/.config/spmenu/run/config` and add a function like this to the config: + +``` +run_post_func() { + case "${1:0:1}" in # first char + "s") query="$(printf "%s\n" "$1" | sed "s/s //; s/ /+/g")" && chromium "http://localhost:8888/search?q=$query"; ;; + esac +``` + +Note that you should replace `http://localhost:8888` here with the search engine +you use. Every search engine I've ever used uses this same format, though. + +In this `case` statement, we're checking if the first character is `s`. If it is, +we get everything except `s ` from the input, and in the latter half of the `sed` +we also replace all spaces with `+`, which search engines translate into a space. + +You can easily add more search engines, too if you want. + +``` +run_post_func() { + case "${1:0:1}" in # first char + "s") query="$(printf "%s\n" "$1" | sed "s/s //; s/ /+/g")" && chromium "http://localhost:8888/search?q=$query" ;; + "d") query="$(printf "%s\n" "$1" | sed "s/d //; s/ /+/g")" && chromium "https://duckduckgo.com/search?q=$query" ;; + "r") query="$(printf "%s\n" "$1" | sed "s/r //; s/ /+/g")" && chromium "https://reddit.com/search?q=$query" ;; + esac +``` + +In this example, I've added duckduckgo searches using the `d` prefix and Reddit +searches using the `r` prefix. Pretty cool.