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