From 6ca47e77d90ca0c299c9229fa5753e2034236583 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 31 Oct 2016 18:03:21 -0400 Subject: [PATCH] Support running script from anywhere References the programs fonts, no matter where the script is run from. --- text-to-image.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/text-to-image.sh b/text-to-image.sh index 3ba8b34..25616bd 100755 --- a/text-to-image.sh +++ b/text-to-image.sh @@ -45,14 +45,15 @@ esac echo "Thanks. Generating image..." -font_reg=$HOME/.local/share/fonts/Lora-Regular.ttf +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +font_reg=$DIR/fonts/Lora-Regular.ttf if [ "$font" = "mono" ]; then - font_reg=$HOME/.local/share/fonts/Hack-Regular.ttf + font_reg=$DIR/fonts/Hack-Regular.ttf elif [ "$font" != "norm" ]; then - font_reg=$HOME/.local/share/fonts/OpenSans-Regular.ttf + font_reg=$DIR/fonts/OpenSans-Regular.ttf fi -write_bold=$HOME/.local/share/fonts/Lora-Bold.ttf -write_reg=$HOME/.local/share/fonts/Lora-Regular.ttf +write_bold=$DIR/fonts/Lora-Bold.ttf +write_reg=$DIR/fonts/Lora-Regular.ttf # Generate post text if [ $(echo "$msg" | wc -m) -lt 40 ]; then