From 46289c9ca45d23cbbb573515685a15fc17908bad Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 3 Aug 2022 20:24:31 +0200 Subject: Add url.sh --- url.sh | 17 ++++++++++++----- 1 file 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 -- cgit v1.2.3-70-g09d2