How do I suppress the printer or file sharing messages
Suppressing printer or file sharing messages
It is possible to disable the successfully attached printer messages dialog box that occurs when a printer has already been configured, while still allowing all other message dialog, including the first-time printer PPD selection and subsequent successful attachment dialog.
It is also possible to disable the "mounted on" messages that occur when using SMB file sharing.
To do this, you must move the nxclient binary to an arbitrary location (ie. /usr/NX/bin/nxclient.bin) and place a shell script in place of the original nxclient binary.
The example shell script is at the end of this article. You may copy and paste for step #2.
You may enter these commands at a terminal, as root, to perform this change:
- # mv /usr/NX/bin/nxclient /usr/NX/bin/nxclient.bin
- # vi /usr/NX/bin/nxclient
(paste or type the attached shell script) - chown root:root /usr/NX/bin/nxclient
- chmod 0755 /usr/NX/bin/nxclient
Notations for the shell script
The NXCLIENT_BIN variable should be set to the full path of the nxclient.bin. (step #1)
The FIRSTATTACH points to a local file that is used for determining if the printer dialog selection box was used. This allows the printer confirmation to occur the first time the printer is attached, but not thereafter. If you change printer assignment, the printer confirmation dialog will not show up unless you remove the ~/.nx/config/FIRSTATTACH file.
The BLOCK_PRINT_DIALOG variable needs to be set to 1 to disable the sucessfully attached printer messages. Set the variable to 0 to allow the messages to be displayed.
The BLOCK_FILE_DIALOG variable needs to be set to 1 to disable the "mounted on" SMB messages. Set the variable to 0 to allow the messages to be displayed.
All other dialogs will behave normally.
==== SCRIPT STARTS BELOW ====
#!/bin/sh
# This script needs to be saved in place of nxclient, nxclient needs to be
# moved to $NXCLIENT_BIN.
# When printer is connected for the first time and BLOCK_PRINT_DIALOG is set to 1
# nxclient starts the dialog to choose the printer driver driver.
# The nxclient will also display the "successful" attachment
# dialog the first time, through the use of the FIRSTATTACH file in
# the user's home/.nx/config directory.
# The next time the driver is selected without displaying the
# confirmation dialog, or the successful attachment dialog.
#
# When BLOCK_FILE_DIALOG is set to 1, all SMB mounting messages
# will be suppressed
#
# All other dialogs are not filtered.
NXCLIENT_BIN="exec /usr/NX/bin/nxclient.bin"
FIRSTATTACH=~/.nx/config/FIRSTATTACH
BLOCK_FILE_DIALOG=1 # set to 0 to not block
BLOCK_PRINT_DIALOG=1 # set to 0 to not block
echo "`date`" >> /tmp/nxclient.logrm /t
echo "$@" >> /tmp/nxclient.log
case "$1" in
"-printer" | "--printer" )
PRINTER="$2"
if [ -n "$PRINTER" ]
then
DRIVER=`cat ~/.nx/config/drivers.cache | grep "$PRINTER" | awk -F'|' ' { print $3 }' 2>/dev/null`
if [ -n "$DRIVER" ]
then
echo "$DRIVER"
else
$NXCLIENT_BIN "$@"
exit 0
fi
fi
exit 0
;;
"-dialog" | "--dialog" )
MESSAGE="$6"
TEST=`echo "$MESSAGE" | grep "was successfully attached on"`
if [[ -n "$TEST" && "$BLOCK_PRINT_DIALOG" -eq "1" ]]
then
if [ ! -e $FIRSTATTACH ]
then
/usr/bin/touch "$FIRSTATTACH"
$NXCLIENT_BIN "$@"
exit 0
else
exit 0
fi
fi
TEST=`echo "$MESSAGE" | grep "SMB share.*mounted on"`
echo "TESTING STUFF" >> /tmp/nxclient.log
if [[ -n "$TEST" && "$BLOCK_FILE_DIALOG" -eq "1" ]]
then
echo "TESTED POSITIVE" >> /tmp/nxclient.log
exit 0
fi
$NXCLIENT_BIN "$@"
exit 0
;;
* )
$NXCLIENT_BIN "$@"
exit 0
;;
esac
exit 0
