2.1 KiB
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.
- 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.
- 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.