From 38d24bdb338d32b6345c9ba1ac17c358a157f927 Mon Sep 17 00:00:00 2001 From: dece Date: Sun, 28 Aug 2022 15:46:14 +0200 Subject: [PATCH] rofibangs: add raw parameter --- rofibangs.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/rofibangs.py b/rofibangs.py index eb0110e..65b5771 100755 --- a/rofibangs.py +++ b/rofibangs.py @@ -7,11 +7,18 @@ want a Wikipedia article for "burger", or at least a much needed disambiguation… Config file example: - { "bangs": [ { - "handle": "w", - "name": "Wikipedia", - "url": "https://en.wikipedia.org/wiki/Special:Search?search={}&go=Go" - } ] } + { + "bangs": [ + { + "handle": "w", + "name": "Wikipedia", + "url": "https://en.wikipedia.org/wiki/Special:Search?search={}&go=Go" + } + ] + } + +Optionally, a bang object can contain a "raw" key with a boolean value: if +true, arguments are passed without being URL-encoded. By default this scripts attempts to load your config file from `~/.config/rofibangs.json`, but you can specify the ROFIBANGS_CONFIG_PATH @@ -66,7 +73,10 @@ def open_bang(config, handle, query): else: print("Unknown handle.") return - url = bang["url"].format(urllib.parse.quote(query.strip())) + query = query.strip() + if not bang.get("raw", False): + query = urllib.parse.quote(query) + url = bang["url"].format(query) webbrowser.open_new_tab(url)