A service that imitates DuckDuckGo's bangs:
Bangs are shortcuts that quickly take you to search results on other sites. For example, when you know you want to search on another site like Wikipedia or Amazon, our bangs get you there fastest. A search for !w filter bubble will take you directly to Wikipedia. -- DuckDuckGo !Bangs
Banger is intended to be used as search engine proxy, configured as a search engine in browsers.
Configuration files are used to configure bangs Banger uses, set a default bang to be used if there are no bangs in the query, and define a default address the server will be listening on.
Configuration is named banger.toml. It may be passed with --config or -c CLI option.
Otherwise, it is searched for in following order:
$BANGER_CONFIG$XDG_CONFIG_HOME/banger/banger.toml$HOME/.config/banger/banger.toml<dir>/banger/banger.toml,diris taken from$XDG_CONFIG_DIRSlist, where directories are split by:$sysconfdir/xdg/banger/banger.toml/etc/xdg/banger/banger.toml<directory_with_binary>/banger.toml
Names with $ are environment variables.
For locations 2-6, Banger attempts to implement XDG base directory specification.
Banger uses TOML. Configuration file is a valid UTF-8 encoded Unicode document. Values and keys are case-sensitive.
Configuration file consists of default and address key-value pairs, and bangs,
an array of tables for each bang.
address is optional, every other mentioned key-value pair is required.
Value of address must be a string in format <IP address>:<port>.
Value of default must be a string that corresponds to one of the bangs
from bangs array.
Each bang table consists of aliases and query pairs.
aliasesis an array of bang aliases as strings. Each bang must be unique to one bang table.queryis a string that contains a URL, that the user will be redirected to when the bang is used. Bangs will be stripped, and{}will be replaced with search terms.
address='127.0.0.1:8080'
default='duckduckgo'
[[bangs]]
aliases = ['duckduckgo', 'ddg']
query = 'https://duckduckgo.com/?q={}'
[[bangs]]
aliases = ['wikipedia', 'wiki', 'w']
query = 'https://en.wikipedia.org/w/?search={}'
[[bangs]]
aliases = ['вікі', 'в', 'ukwiki']
query = 'https://uk.wikipedia.org/w/?search={}'Here, we can see three configurations, with DuckDuckGo selected as a default:
- DuckDuckGo, with two bang aliases and a query
- Wikipedia, with three bang aliases and a query
- Ukrainian Wikipedia, with three bang aliases, some with Unicode symbols, and a query
Address is set to 127.0.0.1 with port 8080.
makepkg -siTo install to ~/.cargo/bin:
cargo installOther paths and options may be chosen: check cargo install documentation
Alternatively:
cargo build --release
cp target/release/banger_rs <somewhere_in_your_path>Program takes 2 optional CLI arguments: config file and address to bind to. Examples:
# Look up config and take address from config
banger_rs
# Look up config and override address
banger_rs --address 0.0.0.0:8080
# Select config manually
banger_rs -c banger.toml
# Select config manually and override address
banger_rs --config banger.toml --address 0.0.0.0:8080
# Short options may be used
banger_rs -c banger.toml -a 0.0.0.0:8080# Run at system startup
sudo systemctl enable --now banger
# Run at first user login
systemctl --user enable --now bangerYou may want to edit path to the binary in the service file before running commands.
# Run at system startup
sudo systemctl enable --now ./banger.service
# Run at first user login
systemctl --user enable --now ./banger.service