diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2023-03-27 10:13:40 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2023-03-27 10:13:40 +0800 |
| commit | efa77f6016446187fce494ac4a13c6a0d719e77e (patch) | |
| tree | 10de02536ebc9947b01f6c2cfe1a683a95dd33e1 | |
| parent | 13881f9a0a133b66a80064dbb6f1c62adf26e71f (diff) | |
Add keybinding for banner
| -rw-r--r-- | X11/openbox/rc.xml | 2 | ||||
| -rwxr-xr-x | bin/unix/center_text.sh | 16 |
2 files changed, 17 insertions, 1 deletions
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 @@ | |||
| 508 | -o "window.dimensions.columns=35" | 508 | -o "window.dimensions.columns=35" |
| 509 | -o "window.dimensions.lines=1" | 509 | -o "window.dimensions.lines=1" |
| 510 | -o "font.size=60" | 510 | -o "font.size=60" |
| 511 | -e sh -c 'read' | 511 | -e ~/helper/bin/unix/center_text.sh |
| 512 | </command> | 512 | </command> |
| 513 | </action> | 513 | </action> |
| 514 | </keybind> | 514 | </keybind> |
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 @@ | |||
| 1 | #! /bin/bash | ||
| 2 | |||
| 3 | echo '\e[5 q' | ||
| 4 | |||
| 5 | while read -r -e text; do | ||
| 6 | tput cuu1 civis | ||
| 7 | |||
| 8 | width="$(tput cols)" | ||
| 9 | left=$(( ($width - ${#text}) /2 )) | ||
| 10 | right=$(( $width - $left - ${#text} )) | ||
| 11 | |||
| 12 | echo -en '\r' | ||
| 13 | eval "printf ' %.0s' {1..$left}" | ||
| 14 | echo -n $text | ||
| 15 | eval "printf ' %.0s' {1..$right}" | ||
| 16 | done | ||