Skip to content

Commit

Permalink
print_msg.sh: always call lpr in background
Browse files Browse the repository at this point in the history
Prevent that the printer system lpr can block the Smuxi interface.
This can happen when the printer is stuck or there is no paper.
  • Loading branch information
root committed Oct 24, 2023
1 parent 64eb09c commit 216f6f0
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions smuxi_hooks/on-message-received/print_msg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ if [ "$SMUXI_CHAT_ID" != "#dimsumlabs" ]; then
exit 0
fi

# Sends ESC/P command
send_esc() {
echo -en "\x1b$1" | lpr
}

echo -n "$SMUXI_MSG_TIMESTAMP_ISO_LOCAL " | lpr
send_esc 4 # Select italic
echo -n "$SMUXI_SENDER " | lpr
send_esc 5 # Cancel italic
echo $SMUXI_MSG \
| iconv -f utf-8 -t 437 -c \
| lpr &
ESC="\x1b"
ITALIC_ON="${ESC}4"
ITALIC_OFF="${ESC}5"
(
echo -n "$SMUXI_MSG_TIMESTAMP_ISO_LOCAL "
echo -ne "$ITALIC_ON"
echo -n "$SMUXI_SENDER"
echo -ne "$ITALIC_OFF"
echo " $SMUXI_MSG"
) | iconv -f utf-8 -t 437 -c \
| lpr &

0 comments on commit 216f6f0

Please sign in to comment.