A collection of shell scripts to interactively print and manage printers via command line.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
To install all (necessary and optional) packages on your system, simply run:
echo "https://dl-cdn.alpinelinux.org/alpine/v$(cut -d'.' -f1,2 /etc/alpine-release)/community/" | sudo tee -a /etc/apk/repositories
echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing/" | sudo tee -a /etc/apk/repositories
sudo apk update && \
sudo apk add avahi dialog cups cups-filters cups-pdf@testing gutenprint-cups@testingsudo apt install avahi-daemon dialog cups printer-driver-allThe current user must be a member of the 'lpadmin' group:
sudo usermod -a -G lpadmin $(id -un)Please make sure that systemd is enabled as the default system/session manager. For more information please have a look at: https://learn.microsoft.com/en-us/windows/wsl/systemd
git clone --recurse-submodules https://github.com/fkemser/CUPSwrapper.git && \
chmod +x ./CUPSwrapper/src/cups.sh && \
./CUPSwrapper/src/cups.shFor more information please have a look at the usage section.
This project provides a dialog-based interface to
- set up a printer,
- select a default printer,
- set default printing settings,
- print a document (or
stdininput), allowing the user to interactively choose printer and printing settings, - create print job settings (
lparguments) that can be saved into a variable for multiple usage, - cancel print jobs.
The project has been developed and tested on the following system:
| Info | Description |
|---|---|
| OS | Debian GNU/Linux 12 (bookworm) |
| Kernel | 5.15.133.1-microsoft-standard-WSL2 |
| Packages | avahi-daemon (0.8-10) |
| coreutils (9.1-1) | |
| cups (2.4.2-3+deb12u5) | |
| dash (0.5.12-2) | |
| dialog (1.3-20230209-1) | |
| libc-bin (2.36-9+deb12u3) | |
| printer-driver-all (0.20210903) |
Please make sure that the following dependencies are installed:
- Avahi
- CUPS
- Dialog
- In case you have an older printer that does not support driverless printing (IPP) yet you may also need additional legacy drivers.
Below you can find distribution-specific installation instructions.
# Required
echo "https://dl-cdn.alpinelinux.org/alpine/v$(cut -d'.' -f1,2 /etc/alpine-release)/community/" | sudo tee -a /etc/apk/repositories
echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing/" | sudo tee -a /etc/apk/repositories
sudo apk update
sudo apk add avahi cups cups-filters cups-pdf@testing dialog
# Optional
sudo apk add gutenprint-cups@testingsudo apt install avahi-daemon cups dialog # Required
sudo apt install printer-driver-all # OptionalThe current user must be a member of the 'lpadmin' group:
sudo usermod -a -G lpadmin <username>Please make sure that systemd is enabled as the default system/session manager. For more information please have a look at: https://learn.microsoft.com/en-us/windows/wsl/systemd
- Clone the repo
git clone --recurse-submodules https://github.com/fkemser/CUPSwrapper.git
- Edit the repository configuration file. In case it is empty just keep it as it is, do not delete it.
nano ./CUPSwrapper/etc/cups.cfg.sh
To call the script interactively, run /src/cups.sh (without further arguments) from your terminal.
For script mode run /src/cups.sh followed by a list of arguments --arg1 [<val1>] --arg2 [<val2>] .... To get help, run /src/cups.sh -h.
================================================================================
=============================== SYNOPSIS ===============================
================================================================================
There are multiple ways to run this script:
Interactive mode (without any args):
> ./cups.sh
Classic (script) mode:
> ./cups.sh [ OPTION ]... ACTION [<file>]
ACTION := { -h|--help | --jobsettings | --print [<file>] }
[<file>] : File to print (optional)
--------------------------------------------------------------------------------
-------------------------------- ACTION --------------------------------
--------------------------------------------------------------------------------
-h|--help Show this help message
--submenu <menu> Run a certain submenu interactively and exit
<menu> = { add | default | defsettings | remove | print }
--jobsettings Interactively select printer and print job settings. The
chosen settings will be printed to <stdout>, e.g. for
further use with 'lp' command.
--print [<file>] Print, either from a given <file> or a previous command's
output (via pipe). Interactively select printer and print
job settings before printing.
================================================================================
=============================== EXAMPLES ===============================
================================================================================
____________________________________ Print _____________________________________
./cups.sh --print letter.pdf # Print a PDF file named 'letter.pdf'
echo Hello | ./cups.sh --print # Print a command's output, here 'echo Hello'See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the GNU General Public License v3.0 (or later). See LICENSE for more information.
⚠️ The license above does not apply to the files and folders within the library directory/lib. Please have a look at theLICENSEfile located in the root directory of each library to get more information.
Project Link: https://github.com/fkemser/CUPSwrapper
