summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2022-08-03 20:24:31 +0200
committerxengineering <me@xengineering.eu>2022-08-03 20:24:31 +0200
commit46289c9ca45d23cbbb573515685a15fc17908bad (patch)
treeafa4c72aebfde4897ee5875aaabb8321073b3350
parent49f3bfce56f7ba1e8447ce6cf4229f8f2cbb2e19 (diff)
downloadscripts-46289c9ca45d23cbbb573515685a15fc17908bad.tar
scripts-46289c9ca45d23cbbb573515685a15fc17908bad.tar.zst
scripts-46289c9ca45d23cbbb573515685a15fc17908bad.zip
Add url.sh
-rwxr-xr-xurl.sh17
1 files changed, 12 insertions, 5 deletions
diff --git a/url.sh b/url.sh
index e198399..8a5e054 100755
--- a/url.sh
+++ b/url.sh
@@ -14,21 +14,28 @@ then
fi
# check dependency and warn user if necessary
-if ! which bemenu > /dev/null 2>&1
+if ! command -v bemenu > /dev/null 2>&1
then
echo 'You have to install bemenu.'
exit 1
fi
# check dependency and warn user if necessary
-if ! which firefox > /dev/null 2>&1
+if ! command -v firefox > /dev/null 2>&1
then
echo 'You have to install firefox.'
exit 1
fi
# let user select the URL
-line="$(bemenu -l 10 < "${data_abs}")"
-url="$(echo "${line}" | awk -F '\t' '{print $1}')"
+closer="close menu"
+line="$(sed "$ a ${closer}" < "${data_abs}" | bemenu -l 10)"
+selection="$(echo "${line}" | awk -F '\t' '{print $1}')"
-firefox "${url}"
+# exit or open URL in browser
+if [ "${selection}" = "${closer}" ]
+then
+ exit 0
+else
+ firefox "${selection}"
+fi