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.
This commit is contained in:
parent
ff2ae79878
commit
d69a0f40e1
5 changed files with 41 additions and 8 deletions
qutebrowser/data/userscripts
social/.config/tut
|
@ -12,6 +12,16 @@
|
||||||
# Configure your shaarli instance with this:
|
# Configure your shaarli instance with this:
|
||||||
INSTANCE="https://links.martyoeh.me"
|
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
|
# send page to shaarli instance and open the 'post' page to edit it
|
||||||
if [ "$#" -gt 0 ]; then
|
if [ "$#" -gt 0 ]; then
|
||||||
BM="$INSTANCE/bookmarks/new?url=$*&auto_close"
|
BM="$INSTANCE/bookmarks/new?url=$*&auto_close"
|
||||||
|
@ -19,9 +29,8 @@ else
|
||||||
BM="$INSTANCE/bookmarks/new?url=$QUTE_URL&auto_close"
|
BM="$INSTANCE/bookmarks/new?url=$QUTE_URL&auto_close"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$QUTE_FIFO" ]; then
|
if [ "$QUTE_FIFO" != "" ]; then
|
||||||
echo "open -t -r $BM" >>"$QUTE_FIFO"
|
echo "open -t -r $BM" >>"$QUTE_FIFO"
|
||||||
else
|
else
|
||||||
xdg-open "$BM"
|
_open "$BM"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# continue surfing like normal, only that you can now also access
|
# continue surfing like normal, only that you can now also access
|
||||||
# any gemini pages as if they were part of the normal http protocol.
|
# any gemini pages as if they were part of the normal http protocol.
|
||||||
|
|
||||||
|
import shutil
|
||||||
import cgi
|
import cgi
|
||||||
import html
|
import html
|
||||||
import os
|
import os
|
||||||
|
@ -379,7 +380,10 @@ def open_url(url: str, open_args: str) -> None:
|
||||||
with open(fifo, "w") as qfifo:
|
with open(fifo, "w") as qfifo:
|
||||||
qfifo.write(f"open {open_args} {to_open}")
|
qfifo.write(f"open {open_args} {to_open}")
|
||||||
return
|
return
|
||||||
os.system(f"xdg-open {to_open}")
|
if shutil.which("mimeo"):
|
||||||
|
_ = os.system(f"mimeo {to_open}")
|
||||||
|
elif shutil.which("xdg-open"):
|
||||||
|
_ = os.system(f"xdg-open {to_open}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -12,6 +12,16 @@
|
||||||
# Configure your shaarli instance with this:
|
# Configure your shaarli instance with this:
|
||||||
SHAARLI_INSTANCE="https://links.martyoeh.me"
|
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
|
# send page to shaarli instance and open the 'post' page to edit it
|
||||||
if [ "$#" -gt 0 ]; then
|
if [ "$#" -gt 0 ]; then
|
||||||
BM="$SHAARLI_INSTANCE/?post=$*"
|
BM="$SHAARLI_INSTANCE/?post=$*"
|
||||||
|
@ -22,6 +32,6 @@ fi
|
||||||
if [ -n "$QUTE_FIFO" ]; then
|
if [ -n "$QUTE_FIFO" ]; then
|
||||||
echo "open -t -r $BM" >>"$QUTE_FIFO"
|
echo "open -t -r $BM" >>"$QUTE_FIFO"
|
||||||
else
|
else
|
||||||
xdg-open "$BM"
|
_open "$BM"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,16 @@
|
||||||
# Configure your wallabag instance with this:
|
# Configure your wallabag instance with this:
|
||||||
WALLABAG_INSTANCE="https://read.martyoeh.me"
|
WALLABAG_INSTANCE="https://read.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
|
||||||
|
}
|
||||||
|
|
||||||
# only works for wallabag v2.*
|
# only works for wallabag v2.*
|
||||||
if [ "$#" -gt 0 ]; then
|
if [ "$#" -gt 0 ]; then
|
||||||
BM="$WALLABAG_INSTANCE/bookmarklet?url=$*"
|
BM="$WALLABAG_INSTANCE/bookmarklet?url=$*"
|
||||||
|
@ -22,5 +32,5 @@ fi
|
||||||
if [ -n "$QUTE_FIFO" ]; then
|
if [ -n "$QUTE_FIFO" ]; then
|
||||||
echo "open -b -r $BM" >>"$QUTE_FIFO"
|
echo "open -b -r $BM" >>"$QUTE_FIFO"
|
||||||
else
|
else
|
||||||
xdg-open "$BM"
|
_open "$BM"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -243,7 +243,7 @@ video-reverse=false
|
||||||
|
|
||||||
# Your audio viewer.
|
# Your audio viewer.
|
||||||
# default=xdg-open
|
# default=xdg-open
|
||||||
audio-viewer=xdg-open
|
audio-viewer=mimeo
|
||||||
|
|
||||||
# Open the audio viewer in the same terminal as toot. Only for terminal based
|
# Open the audio viewer in the same terminal as toot. Only for terminal based
|
||||||
# viewers.
|
# viewers.
|
||||||
|
@ -261,7 +261,7 @@ audio-reverse=false
|
||||||
|
|
||||||
# Your web browser.
|
# Your web browser.
|
||||||
# default=xdg-open
|
# default=xdg-open
|
||||||
link-viewer=xdg-open
|
link-viewer=mimeo
|
||||||
|
|
||||||
# Open the browser in the same terminal as toot. Only for terminal based
|
# Open the browser in the same terminal as toot. Only for terminal based
|
||||||
# browsers.
|
# browsers.
|
||||||
|
|
Loading…
Reference in a new issue