#!/bin/sh # vim: shiftwidth=4 tabstop=4 noexpandtab # constants data_repo="${HOME}/.local/share/mydata" data_rel="tables/urls.tsv" data_abs="${data_repo}/${data_rel}" # check if data file exists if ! [ -f "${data_abs}" ] then echo "Data file '""${data_abs}""' not found." exit 1 fi # select a menu program or panic if command -v bemenu > /dev/null 2>&1 then menu='bemenu' elif command -v dmenu > /dev/null 2>&1 then menu='dmenu' elif command -v sxmo_dmenu.sh > /dev/null 2>&1 then menu='sxmo_dmenu.sh' else echo 'You have to install bemenu, sxmo_dmenu.sh or dmenu!' exit 1 fi # check firefox dependency and warn user if necessary if ! command -v firefox > /dev/null 2>&1 then echo 'You have to install firefox.' exit 1 fi # let user select the URL closer="close menu" line="$(sed "$ a ${closer}" < "${data_abs}" | ${menu} -l 10)" selection="$(echo "${line}" | awk -F '\t' '{print $1}')" # exit or open URL in browser if [ "${selection}" = "${closer}" ] then exit 0 else firefox "${selection}" fi