diff --git a/_posts/2024-01-23-thermal.md b/_posts/2024-01-23-thermal.md index 7e39b447b..b455f63a2 100644 --- a/_posts/2024-01-23-thermal.md +++ b/_posts/2024-01-23-thermal.md @@ -34,3 +34,25 @@ if ! printf '\x1B\x40\x1B\x21\x08\x1B\x61\x01%s\x0A\x0A\x0A\x1B\x69' "$converted fi ``` + +# reverse white printing + +``` + +if ! command -v xclip &>/dev/null; then + echo "xclip could not be found." + exit 1 +fi + +clipboard_content="$(xclip -o -selection clipboard)" + +escaped_content=$(sed 's/%/%%/g' <<<"$clipboard_content") + +converted_text=$(iconv -f UTF-8 -t CP850//TRANSLIT//IGNORE <<<"$escaped_content" 2>/dev/null) + +if ! printf '\x1A\x5B\x01\x00\x00\x00\x00\x40\x02\xB0\x04\x00\x1A\x54\x01\x00\x00\x00\x00\x18\x00\x04\x00%s\x00\x1A\x5D\x00\x1A\x4F\x00\x1B\x69' "$converted_text" | lp -d thermal -o raw; then + echo "Failed to print. Please check the printer and its configuration." + exit 1 +fi + +```