Skip to content

Latest commit

 

History

History
334 lines (238 loc) · 11.7 KB

README.md

File metadata and controls

334 lines (238 loc) · 11.7 KB

Contributors Forks Stargazers Issues GNU GPL v3.0 License


CUPSwrapper

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
  1. About The Project
  2. Getting Started
  3. Usage (/src/cups.sh)
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

This project provides a dialog-based interface to

  • set up a printer,
    Screenshot 1

  • select a default printer,

  • set default printing settings,

  • print a document (or stdin input), allowing the user to interactively choose printer and printing settings,
    Screenshot 2

  • create print job settings (lp arguments) that can be saved into a variable for multiple usage,
    Screenshot 3

  • cancel print jobs.
    Screenshot 4

(back to top)

Built With

Shell Script

(back to top)

Testing Environment

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)

(back to top)

Getting Started

Prerequisites

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.

Alpine Linux

# 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@testing

Debian

sudo apt install avahi-daemon cups dialog   # Required
sudo apt install printer-driver-all         # Optional

OS Settings

The current user must be a member of the 'lpadmin' group:

sudo usermod -a -G lpadmin <username>

Windows Subsystem for Linux (WSL) Users Only

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

Installation

  1. Clone the repo
    git clone --recurse-submodules https://github.com/fkemser/CUPSwrapper.git
  2. 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

(back to top)

Usage (/src/cups.sh)

================================================================================
===============================     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'

Roadmap

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

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 the LICENSE file located in the root directory of each library to get more information.

(back to top)

Contact

Project Link: https://github.com/fkemser/CUPSwrapper

(back to top)

Acknowledgments

(back to top)