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

Action proposal: Set default printer #48

Closed
Pconde2A opened this issue Aug 1, 2022 · 3 comments
Closed

Action proposal: Set default printer #48

Pconde2A opened this issue Aug 1, 2022 · 3 comments
Assignees

Comments

@Pconde2A
Copy link

Pconde2A commented Aug 1, 2022

Description

To replace ControlPlane that is no more supported, I would like to use Shortcuts.
One of the feature that I use most is the ability to change the default Printer depending on the location (home, office, customer office sites, ...)
It would be great if you could add this action.
Thx and take care

@sindresorhus sindresorhus changed the title Action proposal: set default printer Action proposal: Set default printer Aug 1, 2022
@sindresorhus
Copy link
Owner

I looked into this. There's no App Store compatible way to set the default printer. It is possible if an app is not sandboxed, but Actions is. I may make a separate app called Actions Plus or something in the future with actions that require more access, but not anytime soon. What is possible is to get the default printer and available printers. I will make actions for that later this year.

However, the solution for you is to use the "Run Shell Script" action with the following command:

lpoptions -d PRINTER_NAME

Example:

lpoptions -d HP_ENVY_5640_series

You can get a list of printer names by running in the Terminal:

lpstat -a

@sindresorhus
Copy link
Owner

Note to self: Get default printer with NSPrintInfo.shared.printer.

@sindresorhus sindresorhus self-assigned this Aug 1, 2022
@sindresorhus
Copy link
Owner

Good news. I found a way to do it using some low-level APIs. It's included in the latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants