Ask Your Question
0

Changing default printers automatically

asked 2013-07-31 08:13:32 -0500

Neil Calkin gravatar image

Is it possible to set one printer as my default when I'm connected to my home network, and another as the default when I'm connected to my work network? I'm running fedora19, connecting to a wireless network at home, and to both a wired and a wireless network at work.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-07-31 11:21:42 -0500

marcindulak gravatar image

I would set the PRINTER environment variable http://docs.fedoraproject.org/en-US/Fedora/14/html/User_Guide/sect-User_Guide-Printing-send_a_job.html based on your current domain:

if [ x`hostname -d` == x"home.domain" ]; then
export PRINTER=home-printer
fi
if [ x`hostname -d` == x"work.domain" ]; then
export PRINTER=work-printer
fi

You can get the printer names list from:

lpstat -v 2> /dev/null | cut -d " " -f 3 | tr : \\0

You can have the settings in ~/.bashrc (will work only once, at login) or experiment with http://mydailyhacks.wordpress.com/2012/03/12/networkmanager-dispatcher/. There is some more documentation here https://wiki.archlinux.org/index.php/NetworkManager#Network_services_with_NetworkManager_dispatcher and a complete example available here http://sysadminsjourney.com/content/2008/12/18/use-networkmanager-launch-scripts-based-network-location/

edit flag offensive delete link more
0

answered 2013-07-31 10:58:45 -0500

kdg1955 gravatar image

A possibility, add an "if condition" in your .bashrc of your home directory based on your ip address or hostname and:

  • change the default printer with lpadmin $> man lpadmin

    or

  • use the variable LPDEST or PRINTER (not sure it will work on all application).

example:

if [ "$HOSTNAME" == "home.hostname.xx"] ; then
 lpadmin -d myHomeDefaultPrinter
else
 lpadmin -d myWorkDefaultPrinter
fi
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-07-31 08:13:32 -0500

Seen: 321 times

Last updated: Jul 31 '13