Skip to content

Commit 216f6f0

Browse files
author
root
committed
print_msg.sh: always call lpr in background
Prevent that the printer system lpr can block the Smuxi interface. This can happen when the printer is stuck or there is no paper.
1 parent 64eb09c commit 216f6f0

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

smuxi_hooks/on-message-received/print_msg.sh

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ if [ "$SMUXI_CHAT_ID" != "#dimsumlabs" ]; then
1111
exit 0
1212
fi
1313

14-
# Sends ESC/P command
15-
send_esc() {
16-
echo -en "\x1b$1" | lpr
17-
}
18-
19-
echo -n "$SMUXI_MSG_TIMESTAMP_ISO_LOCAL " | lpr
20-
send_esc 4 # Select italic
21-
echo -n "$SMUXI_SENDER " | lpr
22-
send_esc 5 # Cancel italic
23-
echo $SMUXI_MSG \
24-
| iconv -f utf-8 -t 437 -c \
25-
| lpr &
14+
ESC="\x1b"
15+
ITALIC_ON="${ESC}4"
16+
ITALIC_OFF="${ESC}5"
17+
(
18+
echo -n "$SMUXI_MSG_TIMESTAMP_ISO_LOCAL "
19+
echo -ne "$ITALIC_ON"
20+
echo -n "$SMUXI_SENDER"
21+
echo -ne "$ITALIC_OFF"
22+
echo " $SMUXI_MSG"
23+
) | iconv -f utf-8 -t 437 -c \
24+
| lpr &

0 commit comments

Comments
 (0)