Ask Your Question

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

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

marcindulak gravatar image

I would set the PRINTER environment variable based on your current domain:

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

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 There is some more documentation here and a complete example available here

edit flag offensive delete link more

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


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


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

Question Tools


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

Seen: 321 times

Last updated: Jul 31 '13