summaryrefslogtreecommitdiff
path: root/url.sh
diff options
context:
space:
mode:
Diffstat (limited to '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