Skip to content

Instantly share code, notes, and snippets.

@sheepla
Last active July 16, 2023 23:49
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheepla/ceef0a86a0b5f8d4bfd7f8e18d74df28 to your computer and use it in GitHub Desktop.
Save sheepla/ceef0a86a0b5f8d4bfd7f8e18d74df28 to your computer and use it in GitHub Desktop.
dmenu-websearch.sh - creating tiny web-search menu on Linux desktop
#!/bin/sh
_err() {
echo "[ \e[31;1mERROR\e[m ] ${1}" 2>&1
}
_has() {
command -v "${1}" &>/dev/null
}
_dmenu() {
dmenu -nb "#161821" -sb "#444b71" -fn "Terminus (TTF)" -l 5 "${@}"
}
_has s || _err "s command not found. please install s. see: https://github.com/zquestz/s"
_has dmenu || _err "dmenu command not found. please install dmenu. see: https://github.com/davatorium/rofi"
provider="$(s --list-providers | _dmenu -p "Search Provider")"
query="$(echo "" | _dmenu -p "Query")"
s -p "${provider}" "${query}"
@sheepla
Copy link
Author

sheepla commented Jul 16, 2023

About

This is a tiny script to create quick web-search menu on Linux desktop.

Usage

  1. Install dmenu and zquestz/s
  2. Save this script with the name dmenu-websearch.sh
  3. bind keyboard shortcut with your favorite window manager

e.g. on i3wm:

# ~/.config/i3/config
bindsym $mod+o exec --no-startup-id "path/to/dmenu-websearch.sh"
  1. Launch this script with the keyboard shortcut that you set.
  2. Select search provider with dmenu e.g. duckduckgo
  3. Type query text. e.g. Arch Linux
  4. Type Enter to open search result with the default browser on your system.
  5. Web browser will launch, and will open search result. e.g. https://duckduckgo.com/?q=Arch+Linux

s-search

@sheepla
Copy link
Author

sheepla commented Jul 16, 2023

Q: How to use dmenu-like less-bloated dinamic menu on Windows? 🪟🤔
A: Use LinArcX/wmenu !😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment