dotfiles/qutebrowser/data/userscripts/shaarli_add.sh
Marty Oehme d69a0f40e1
qutebrowser: Make xdg-utils optional
Replace all hard-coded instances of using xdg-open with at least one
non-xdg alternative. Mostly falling back to either mimeo or a custom
open script.
2025-03-19 21:30:02 +01:00

37 lines
904 B
Bash
Executable file

#! /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"
_open() {
if command -v open >/dev/null 2>&1; then
open "$1" &
elif command -v mimeo >/dev/null 2>&1; then
mimeo "$1" &
else
xdg-open "$1" &
fi
}
# 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
_open "$BM"
fi