From f09a75820e56bd5a16528efed05ffc892997d2f9 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 8 Aug 2023 11:54:44 +0200 Subject: [PATCH] qutebrowser: Improve shaarli/wallabag bookmarkers Both bookmarkers can now either send the current page ("s for sending to shaarli; "w to send to wallabag) or send any link on the current page (;s for shaarli, ;w for wallabag). Both have been adapted to the same format, both can be sent a link as an argument as well (./wallabag_add.sh 'myawesome.blog/entry'). --- qutebrowser/.config/qutebrowser/maps.py | 3 +- .../qutebrowser/userscripts/shaarli_add.sh | 29 +++++++++++++++++-- .../qutebrowser/userscripts/wallabag_add.sh | 12 ++++++-- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/qutebrowser/.config/qutebrowser/maps.py b/qutebrowser/.config/qutebrowser/maps.py index d527d1e..d691b49 100644 --- a/qutebrowser/.config/qutebrowser/maps.py +++ b/qutebrowser/.config/qutebrowser/maps.py @@ -67,8 +67,9 @@ config.bind(lleader + "dp", "save-to-pdf", mode="normal") config.bind("gD", "recent-downloads", mode="normal") config.bind('"w', "add-wallabag", mode="normal") # add current page to wallabag -config.bind(";w", "hint links run add-wallabag") # add link to wallabag +config.bind(';w', "hint links userscript wallabag_add.sh") # add link to wallabag config.bind('"s', "add-shaarli", mode="normal") +config.bind(';s', "hint links userscript shaarli_add.sh") config.bind('"a', "send-to-archive", mode="normal") diff --git a/qutebrowser/.local/share/qutebrowser/userscripts/shaarli_add.sh b/qutebrowser/.local/share/qutebrowser/userscripts/shaarli_add.sh index 01660af..2d3e289 100755 --- a/qutebrowser/.local/share/qutebrowser/userscripts/shaarli_add.sh +++ b/qutebrowser/.local/share/qutebrowser/userscripts/shaarli_add.sh @@ -1,4 +1,27 @@ -#! /usr/bin/bash +#! /usr/bin/env bash +# +# Send current page/link to a shaarli instance. +# +# Can be used for sending the current page via: +# :spawn --userscript shaarli_add.sh +# for sending an arbitrary page passed as argument: +# :spawn --userscript shaarli_add.sh https://myinterestingpage.com +# or for sending a hinted link: +# :hint links userscript shaarli_add.sh +# +# Configure your shaarli instance with this: +SHAARLI_INSTANCE="https://links.martyoeh.me" + +# send page to shaarli instance and open the 'post' page to edit it +if [ "$#" -gt 0 ]; then + BM="$SHAARLI_INSTANCE/?post=$*" +else + BM="$SHAARLI_INSTANCE/?post=$QUTE_URL" +fi + +if [ -n "$QUTE_FIFO" ]; then + echo "open -t -r $BM" >>"$QUTE_FIFO" +else + xdg-open "$BM" +fi -# send current page to my personal shaarli instance and open the 'post' page to edit it -echo "open https://links.martyoeh.me/?post=$QUTE_URL" >>"$QUTE_FIFO" diff --git a/qutebrowser/.local/share/qutebrowser/userscripts/wallabag_add.sh b/qutebrowser/.local/share/qutebrowser/userscripts/wallabag_add.sh index 18c373f..3d3eedf 100755 --- a/qutebrowser/.local/share/qutebrowser/userscripts/wallabag_add.sh +++ b/qutebrowser/.local/share/qutebrowser/userscripts/wallabag_add.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash # # Send current page/link to a wallabag instance. # @@ -14,7 +14,13 @@ WALLABAG_INSTANCE="https://read.martyoeh.me" # only works for wallabag v2.* if [ "$#" -gt 0 ]; then - echo "open -b -r $WALLABAG_INSTANCE/bookmarklet?url=$*" >>"$QUTE_FIFO" + BM="$WALLABAG_INSTANCE/bookmarklet?url=$*" else - echo "open -b -r $WALLABAG_INSTANCE/bookmarklet?url=$QUTE_URL" >>"$QUTE_FIFO" + BM="$WALLABAG_INSTANCE/bookmarklet?url=$QUTE_URL" +fi + +if [ -n "$QUTE_FIFO" ]; then + echo "open -b -r $BM" >>"$QUTE_FIFO" +else + xdg-open "$BM" fi