Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always query current CUPS default printer #33

Conversation

michaelweghorn
Copy link

@michaelweghorn michaelweghorn commented Jul 29, 2024

When asked for the default printer, always
query and return the current CUPS default
printer instead of whatever was the default
last time this was done, to take into account
that the CUPS default printer can change while
the backend is running.

Sample steps (without this commit in place)
to reproduce an incorrect default
printer being returned with cpdb-text-frontend
from cpdb-libs, when the PDF printer is initially
set as default:

Run cpdb-text-frontend:

$ cpdb-text-frontend

Query for the default printer

> get-default-printer
PDF#CUPS

Now, switch the CUPS user default printer
to another one:

$ lpoptions -d somedummy

In the running cpdb-text-frontend instance,
query the default printer again:

> get-default-printer
PDF#CUPS

-> The outdated/previous default printer was returned.

With this commit in place, the new default
printer is now returned as expected:

> get-default-printer
somedummy#CUPS

(This addresses part of issue 3) from comment [1] on the pending change to update CPDB support in LibreOffice.)

[1] https://gerrit.libreoffice.org/c/core/+/169617/comments/3ef76e40_4f120b66

When asked for the default printer, always
query and return the current CUPS default
printer instead of whatever was the default
last time this was done, to take into account
that the CUPS default printer can change while
the backend is running.

Sample steps (without this commit in place)
to reproduce an incorrect default
printer being returned with cpdb-text-frontend
from cpdb-libs, when the PDF printer is initially
set as default:

Run cpdb-text-frontend:

    $ cpdb-text-frontend

Query for the default printer

    > get-default-printer
    PDF#CUPS

Now, switch the CUPS user default printer
to another one:

    $ lpoptions -d somedummy

In the running cpdb-text-frontend instance,
query the default printer again:

    > get-default-printer
    PDF#CUPS

-> The outdated/previous default printer was returned.

With this commit in place, the new default
printer is now returned as expected:

    > get-default-printer
    somedummy#CUPS

(This addresses part of issue 3) from comment [1] on
the pending change to update CPDB support in LibreOffice.)

[1] https://gerrit.libreoffice.org/c/core/+/169617/comments/3ef76e40_4f120b66
@michaelweghorn michaelweghorn force-pushed the michaelweghorn/return_current_default_printer branch from f84c138 to 74c11fc Compare July 29, 2024 06:04
@tillkamppeter tillkamppeter merged commit 69fd708 into OpenPrinting:master Aug 5, 2024
@michaelweghorn michaelweghorn deleted the michaelweghorn/return_current_default_printer branch August 5, 2024 08:20
michaelweghorn added a commit to michaelweghorn/cpdb-backend-cups that referenced this pull request Aug 5, 2024
NULL makes clear that there's no default printer, while
"NA" could even be the name of an actual printer, so
use the former instead of the latter if no default
printer could be determined.

See also discussion in [1] where this preexisting
issue was spotted.

[1] OpenPrinting#33 (comment)
tillkamppeter pushed a commit that referenced this pull request Aug 5, 2024

Verified

This commit was created on github.com and signed with GitHub’s verified signature.
NULL makes clear that there's no default printer, while
"NA" could even be the name of an actual printer, so
use the former instead of the latter if no default
printer could be determined.

See also discussion in [1] where this preexisting
issue was spotted.

[1] #33 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants