From efa77f6016446187fce494ac4a13c6a0d719e77e Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Mon, 27 Mar 2023 10:13:40 +0800 Subject: Add keybinding for banner --- X11/openbox/rc.xml | 2 +- bin/unix/center_text.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 bin/unix/center_text.sh diff --git a/X11/openbox/rc.xml b/X11/openbox/rc.xml index 89328ce..a7e6e5d 100644 --- a/X11/openbox/rc.xml +++ b/X11/openbox/rc.xml @@ -508,7 +508,7 @@ -o "window.dimensions.columns=35" -o "window.dimensions.lines=1" -o "font.size=60" - -e sh -c 'read' + -e ~/helper/bin/unix/center_text.sh diff --git a/bin/unix/center_text.sh b/bin/unix/center_text.sh new file mode 100755 index 0000000..6e3b9b2 --- /dev/null +++ b/bin/unix/center_text.sh @@ -0,0 +1,16 @@ +#! /bin/bash + +echo '\e[5 q' + +while read -r -e text; do + tput cuu1 civis + + width="$(tput cols)" + left=$(( ($width - ${#text}) /2 )) + right=$(( $width - $left - ${#text} )) + + echo -en '\r' + eval "printf ' %.0s' {1..$left}" + echo -n $text + eval "printf ' %.0s' {1..$right}" +done -- cgit v1.2.3-70-g09d2