[FreeNX-kNX] FreeNX 0.6.0.99 snapshot with full printing support and some bugs fixed

Kurt Pfeifle k1pfeifle at gmx.net
Thu Jan 25 04:58:21 UTC 2007


On Wednesday 24 January 2007 22:45, Fabian Franz wrote:

>         * Added setting of CUPS_SERVER environment var.
> 
> -> Now this is great! As of CUPS 1.2, it can use UNIX domain 
> sockets as the servername. So we export this to the session 
> specific port and whereever we are we can always print to it 
> (and  other users cannot, because its protected via file system 
> permissions.)    
> 
> -> But what about those KDE apps? First of all you can just enable 
> ENABLE_KDE_CUPS="1" and are done with it. Second however you can 
> use a more tricky approach if you want to work locally and remote 
> at the same time with the same home directory:   
> 
> Use the following script and save it as for example 
> /usr/bin/nxcupsd_getsock: 
>
> --
> 
> #!/bin/sh
> 
> if [ -n "$NXSESSIONID" -a -r "$HOME/.nx/C-$NXSESSIONID/cups/cups.sock" ] 
> then
>         echo "$HOME/.nx/C-$NXSESSIONID/cups/cups.sock"
> else
>         echo "/var/run/cups/cups.sock"
> fi
> 
> --
> 
> make it executable (chmod a+x /usr/bin/nxcupsd_getsock) and add the 
> following entry to your global kdeprintrc: 
> 
> Host[$e]=$(/usr/bin/nxcupsd_getsock)
> 
> This means whenever we are running in an nxsession we will be redirected 
> to the right cupsd, else the system cupsd will be used. 

Nah, that solution is incomplete; it will *only* work in cases were 
Unix domain socket printing is used for non-NX printing from KDE. But 
it breaks all cases where users have a CUPS_SERVER that is localhost
(or even some $remote_host); you can's simply assume that *all* local
printing will go through socket files whenever CUPS 1.2.x is used...
(and one example is also: *lots* of users still use their old 
cupsd.conf file which never had a Listen directive for .sock, and so
they still are defaulting to localhost:631. If cupsd on startup does
not read a Listen directive that points to a .sock, it will not 
create one, and it will only bind to 127.0.0.1:631 (or some other IP
socket).)

So the basic idea is right, but it needs to cover the case too where
there is no .sock file used to connect to a local CUPS, but where the 
traditional is still in use.

[Also, the path /var/run/cups/cups.sock isn't always correct; users
should not think it is hard-coded like that; you can find it in the
cupsd.conf. As I said, cupsd uses whatever path it finds there to
create the socket upon startup, if it doesn't exist yet.]

> Isn't KDE great?

Beyond any doubt!  :-)

I assume most people on this list will have no clue what this line:

  Host[$e]=$(/usr/bin/nxcupsd_getsock)

actually means. To give you an idea: KDE3 uses ini-style configuration
files. Adding a [$i] makes the setting immutable (part of KDE's famous
"Kiosk mode" features). Adding a [$e] to a parameter name marks it as
an "expansion". Expansions allow for dynamic assignment of config 
settings. The value can be set either to an environment variable, or 
to an executable. With shell expansion a config key value is assigned
"on the fly". In Fabian's example above, it tells it that its value is 
an executable script; it will execute that script in order to get the 
current value it should use (and that executable must "echo" a value.)

Howver, I think it really should be made "immutable" in addition:

   Host[$ie]=$(/usr/bin/nxcupsd_getsock)

A key tagged as [$e] only be be set dynamically only once (like, for 
the first login after installation of KDE: "Mail[$e]=$USER@$HOST"), 
and may then be static from then on. 

I think the kdeprintrc "Host" key should be made to be *always*
dynamically set by those people who run NX sessions.

If it is not immutable, a user may be clicking his kprinter dialogs,
and by accident set the value to a static one again, wondering for a 
few days why his FreeNX printing stopped working, pull out his hair 
and finally come to this list to complain.   :-)

Some resources about KDE Kiosk mode:

  http://enterprise.kde.org/articles/kiosk-lp.php
  http://enterprise.kde.org/articles/Kiosk_customization.pdf
  http://www.kde.org/areas/sysadmin/config_file.php
 
> Future: I was thinking that one could do the same for a "immutable 
> flat profile" to just disable all fancy things if running inside an 
> NX session.  
 
Great idea!
 

[....]

> If you use the nxcupsd-wrapper script, which is also necessary to 
> run the !M client with CUPS 1.2 it will automatically try to 
> download the PPDs. If you don't have this or the script does not 
> work do on the client something like:   
>
> $ cd ~/.nx/cups/
> $ mkdir ppd
> $ cd ppd
> $ for i in $(lpstat -p | cut -d" " -f2 ); do 
>         wget http://localhost:631/printers/$i.ppd -O ${i}_nxdl.ppd; 
>   done  

This will spit error messages for all cases where CUPS "printer 
instances" are in use; but these will be harmless.

[....]

> To enable completely seamless mode add $ENABLE_CUPS_SEAMLESS="1" 
> to your config. 
> 
> If you now run CUPS 1.2 on the client side with NX 2.1.0, cupsd won't
> start. So we need to wrap it: 
> 
> http://svn.berlios.de/svnroot/repos/freenx/nx-utils/nxcupsd-wrapper/nxcupsd-wrapper
>
> Download it, put it somewhere in your home directory, chmod a+x 
> nxcupsd-wrapper, and point nxclient to it instead of /usr/sbin/cupsd. 

Isn't this renamed, elsewhere, to nxcups-wrapper (no "d")?


Cheers,
Kurt

P.S.: You may want to visit 
      http://mail.kde.org/pipermail/freenx-knx/2007-January/004555.html
      You'll see that your message is very hard to read. You may want 
      to change your mail client (or use a text editor beforehand to
      draft it with hardcoded linebreaks at a sensible width (the GMX
      web interface sucks when it comes to write mails to mailing 
      lists).



More information about the FreeNX-kNX mailing list