Set default printer from command line?

Kurt Pfeifle k1pfeifle at gmx.net
Fri Sep 7 18:30:03 CEST 2007


Dean Montgomery wrote:
> How do I set the default printer for kde from the command line?
>
> For cups "~/.cups/lpoptions":
> lpoptions -d library

CUPS 1.1.x used to use ~/.lpoptions and only in 1.2.0 switched to use
~/.cups/lpoptions

> For kde's "~/.lpoptions":
> ???

This is one example of many, where KDEPrint has gone out of sync with
CUPS development. (See also KDE bugzilla, bugs #130423, #130425
and #149546).

KDE *should* use the exact same file as CUPS.

You can work around that by moving the "~/.lpoptions" file away, (so you
can later check which settings you may want to copy over to the real file),
and replace it with a symlink:

   mv ~/.lpoptions ~/.lpoptions.old
   ln -s ~/.cups/lpoptions ~/.lpoptions

If your non-compliant KDEPrint will now try to read/write from/to the "old"
~/.lpoptions it only knows about, it will be redirected to the "new" file
used by CUPS too.

> I tried symlinking the two files but kde has its own settings that cups 
> re-writes/deletes which in turn is not recognized by kde and breaks kde 
> printing.

Ah... you had the idea already...  :-)

Should have read the complete post before starting to reply.

That CUPS deletes this is news to me... but then, I was not using KDEPrint
that much in the past 12 months.

(/me tries to verify now....)

Nope. At least on openSUSE-10.2, KDE 3.5.7, kprinter already uses the new
.cups/lpoptions file without even a symlink. So, thanks a lot!, some good
soul has at least fixed that little annoyance.

I also cannot verify that CUPS deletes the .lpoptions file and replaces it
with ".cups/loptions" (The only command to do this I can imagine would be
the CUPS "lpoptions" command -- but this doesn't do any harm to .lpoptions
here).

Are you sure it is CUPS? How did you find out? Which exact command of CUPS
is it that causes this?  Isn't it possible that an install/upgrade script
of your distro's package manager does do it? Which distro are you using,
which version of KDE is it?

> == Background ==
> We are in the process of installing linux/kde on all of the teacher and 
> student desktops in our school district.  I wrote a small script to detect 
> which room the user is in and change their default printer to that room at 
> login.  This way people can move around the school and the printer follows 
> them.  I hope someone will have a way to set kde's default printer from the 
> command line.
>
> I've looked at the kprinter man page and the help:/kprinter html help.  I've 
> tried fiddling around with the options but I've had no luck.

I could think of a way to still "script around" that weird situation,
even if the case is exactly described by you. But it will be some kind
of effort.

-- 
Kurt Pfeifle
System & Network Printing Consultant ---- Linux/Unix/Windows/Samba/CUPS
Infotec Deutschland GmbH  .....................  Hedelfinger Strasse 58
A RICOH Company  ...........................  D-70327 Stuttgart/Germany



More information about the kde-print mailing list