From 4ba21cd72b0098feb3c7002e0fc07adc682ee25c Mon Sep 17 00:00:00 2001 From: Jeremy Kaplan Date: Wed, 7 Aug 2019 19:24:21 -0700 Subject: [PATCH] Add fh userscript --- qutebrowser/config.py | 4 +++- qutebrowser/userscripts/fh-add | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 qutebrowser/userscripts/fh-add diff --git a/qutebrowser/config.py b/qutebrowser/config.py index bd8beb2..eda7f52 100644 --- a/qutebrowser/config.py +++ b/qutebrowser/config.py @@ -11,7 +11,9 @@ config.load_autoconfig() # Aliases for commands. The keys of the given dictionary are the # aliases, while the values are the commands they map to. # Type: Dict -c.aliases.update({"rmqs": "spawn --userscript clean-url"}) +c.aliases.update( + {"rmqs": "spawn --userscript clean-url", "fh": "spawn --userscript fh-add"} +) # How often (in milliseconds) to auto-save config/cookies/etc. # Type: Int diff --git a/qutebrowser/userscripts/fh-add b/qutebrowser/userscripts/fh-add new file mode 100755 index 0000000..b36fa0b --- /dev/null +++ b/qutebrowser/userscripts/fh-add @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import os +from urllib.parse import urlencode + +url = os.environ["QUTE_URL"] +fifo = os.environ["QUTE_FIFO"] +title = os.environ["QUTE_TITLE"] + +query = {"title": title, "url": url} + +share_link = "https://metagram.net/firehose/share?{}".format(urlencode(query)) + +with open(fifo, "w") as f: + f.write(":open {}".format(share_link))