Opens .URL files in your favorite browser on Linux and FreeBSD.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

21 lines
434 B

#!/bin/bash
# SPDX-FileCopyrightText: 2021 Daniel Aleksandersen <https://www.daniel.priv.no/>
# SPDX-License-Identifier: CC0-1.0
if test ! -f "$1" -o ! -r "$1"
then
>&2 echo "File '$1' doesn't exist or isn't readable."
exit 1
fi
URL=`awk -F "=" '/URL/ {print $2}' "$1" | tr -d ' '`
echo "$URL" | grep -E '[a-z]+:'
if test -z "$URL" -o ! $? -eq 0
then
>&2 echo "Didn't find an URL in file '$1'."
exit 1
fi
xdg-open "$URL"