2020-01-03 15:07:57 +00:00
#!/bin/bash
2020-01-08 21:21:10 +00:00
SOURCE = " ${ BASH_SOURCE [0] } "
while [ -h " $SOURCE " ] ; do # resolve $SOURCE until the file is no longer a symlink
2020-02-16 05:12:12 +00:00
DIR = " $( cd -P " $( dirname " $SOURCE " ) " >/dev/null 2>& 1 && pwd ) "
SOURCE = " $( readlink " $SOURCE " ) "
[ [ $SOURCE != /* ] ] && SOURCE = " $DIR / $SOURCE " # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
2020-01-08 21:21:10 +00:00
done
DIR = " $( cd -P " $( dirname " $SOURCE " ) " >/dev/null 2>& 1 && pwd ) "
2020-02-14 18:20:11 +00:00
PATH = " /usr/local/bin: $PATH " # to find Homebrew-installed fish
2020-01-08 21:21:10 +00:00
2020-02-16 05:12:12 +00:00
# look for config file in XDG config dirs
2020-02-16 05:50:59 +00:00
while IFS = : read -d: -r p; do
if [ -z " $config_path " ] && [ -r " $p /bitbar/plugins/ambient.json " ] ; then
config_path = " $p /bitbar/plugins/ambient.json "
2020-02-16 05:12:12 +00:00
fi
2020-02-16 05:50:59 +00:00
done <<< $( printf '%s:\0' " ${ XDG_CONFIG_HOME :- " ${ HOME } /.config " } : ${ XDG_CONFIG_DIRS :- /etc/xdg } " )
if [ -z " $config_path " ] ; then
2020-02-16 05:12:12 +00:00
config = '{}'
else
2020-02-16 05:50:59 +00:00
config = " $( cat " $config_path " ) "
2020-02-16 05:12:12 +00:00
fi
2020-01-08 21:21:10 +00:00
WIDGET = $( /usr/local/bin/fish $DIR /../ambient-widgets | tr '\n' ' ' )
2020-01-03 15:07:57 +00:00
if [ -z " $WIDGET " ] ; then
2020-02-16 05:12:12 +00:00
if echo " $config " | jq -e 'if has("showIfEmpty") then .showIfEmpty else true end' > /dev/null; then
echo "🚄"
fi
else
echo $WIDGET
echo "---"
2020-09-27 17:16:43 +00:00
echo "Go to map|href=https://iceportal.de/Karte_neu"
2020-02-16 05:12:12 +00:00
echo $( /usr/local/bin/fish $DIR /../ambient | tr '\n' '\r\n' )
2020-01-08 21:21:10 +00:00
fi