Skip to content

Instantly share code, notes, and snippets.

@namandixit
Created September 10, 2024 03:57
Show Gist options
  • Save namandixit/9f65e59bea03c9b71419d3ddc9d510ea to your computer and use it in GitHub Desktop.
Save namandixit/9f65e59bea03c9b71419d3ddc9d510ea to your computer and use it in GitHub Desktop.
Make WebHTTrack work inside Distrobox
#!/usr/bin/env bash
# Replace /usr/bin/x-www-browser with this script to make webhttrack work properly inside a Distrobox
# extract the protocol
proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# remove the protocol -- updated
url=$(echo $1 | sed -e s,$proto,,g)
# extract the user (if any)
user="$(echo $url | grep @ | cut -d@ -f1)"
# extract the host and port -- updated
hostport=$(echo $url | sed -e s,$user@,,g | cut -d/ -f1)
# by request host without port
host="$(echo $hostport | sed -e 's,:.*,,g')"
# by request - try to extract the port
port="$(echo $hostport | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
# extract the path (if any)
path="$(echo $url | grep / | cut -d/ -f2-)"
exec distrobox-host-exec /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=firefox --file-forwarding org.mozilla.firefox "${proto}localhost:${port}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment