diff --git a/xkcdlock b/xkcdlock index e35e221..e9a01b1 100755 --- a/xkcdlock +++ b/xkcdlock @@ -46,7 +46,7 @@ IMG_DEFAULT="not_really_into_pokemon.png" # background colour BG_COLOUR="white" # Break tooltip every x char to prevent border overflow -TOOLTIP_MAX_LINE_LEN=120 +TOOLTIP_MAX_LINE_LEN=100 FONT="xkcd Script" FONT_FILE="xkcd-script.ttf" @@ -201,20 +201,8 @@ xkcd_get_img_tooltip() { } xkcd_format_tooltip() { - local ntext=${#text} - local nbreaks=$((ntext / TOOLTIP_MAX_LINE_LEN)) - local nbreak=$((ntext - TOOLTIP_MAX_LINE_LEN)) - local m=$((nbreaks * TOOLTIP_MAX_LINE_LEN)) - local nrest=$((ntext - m - 1)) - - if (( "$nbreak" > 0 )); then - local text_tok_start=${text:0:$nrest} - local text_tok_end=${text:ntok_end} - text_tok_end=`echo "$text_tok_end" | sed "s/.\{$TOOLTIP_MAX_LINE_LEN\}/&\\n/g"` - echo "${text_tok_start}\\n${text_tok_end}" - else - echo "$text" - fi + local text=$(echo $text | fold -s -w $TOOLTIP_MAX_LINE_LEN) + echo "$text" } get_nscreens() {