Added printer setup

This commit is contained in:
2026-04-27 15:16:04 +02:00
parent 5578496be0
commit 67d6afafd2
6 changed files with 252 additions and 10 deletions
+187
View File
@@ -0,0 +1,187 @@
Control dashboard: http://localhost:631
---
# 🧾 Core controls
```bash
lp file.pdf
```
```bash
-d PRINTER # choose printer
-n NUM # number of copies
-t "TITLE" # job name
-q NUM # priority (1100, higher = sooner)
```
Printer at the house: `HP_OfficeJet_Pro_7740`. I can't make printing without USB work...
---
## If printer stuck:
```bash id="enable1"
sudo cupsenable HP_OfficeJet_Pro_7740
```
---
```bash id="accept1"
sudo cupsaccept HP_OfficeJet_Pro_7740
```
```bash id="cancel1"
cancel -a HP_OfficeJet_Pro_7740
```
#### 🧪 Verify state
```bash id="check1"
lpstat -p -d
```
You want:
```
HP_OfficeJet_Pro_7740 idle, accepting jobs
```
---
# 📄 Page selection
```bash
-P 1-5,8,10-20 # specific pages / ranges
-o page-ranges= # same as -P (sometimes more reliable)
```
Example:
```bash
lp -o page-ranges=142-184 file.pdf
```
---
# 📐 Layout & scaling
```bash
-o fit-to-page
-o scaling=100 # percent
-o media=A4
-o orientation-requested=4 # landscape
```
Orientation values:
* `3` = portrait
* `4` = landscape
---
# 🧠 Duplex (double-sided)
```bash
-o sides=one-sided
-o sides=two-sided-long-edge
-o sides=two-sided-short-edge
```
---
# 📚 Multiple pages per sheet
```bash
-o number-up=2
-o number-up=4
-o number-up=6
-o number-up=9
-o number-up=16
```
---
# 🖼️ Image handling
```bash
-o fit-to-page
-o position=center
-o saturation=100
-o brightness=100
```
---
# 🎨 Color / quality
```bash
-o ColorModel=Color
-o ColorModel=Gray
-o print-quality=3 # draft
-o print-quality=4 # normal
-o print-quality=5 # high
```
---
# 📦 Paper / tray
```bash
-o media=A4
-o media=Letter
-o InputSlot=tray1
-o InputSlot=manual
```
---
# 🔁 Job handling
```bash
-H hold # hold job
-H resume # resume job
-H immediate # print ASAP
```
---
# 🔍 Debug / info
```bash
lpstat -p -d # printers + default
lpstat -o # jobs
lpoptions -l # printer-specific options
```
---
# 🔥 Real-world example (what you actually want)
```bash
lp -d HP_LaserJet \
-o page-ranges=142-184 \
-o sides=two-sided-long-edge \
-o media=A4 \
-o print-quality=5 \
file.pdf
```
---
# ⚠️ Important reality check
Not all printers support all options. The **real supported ones** come from:
```bash
lpoptions -p PRINTER_NAME -l
```
That command is gold—use it.
---
If you want, tell me your **printer model**, and Ill give you a *perfect command tuned to it* (no guessing, no trial and error).
Generated
+3 -3
View File
@@ -135,11 +135,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1776734388,
"narHash": "sha256-vl3dkhlE5gzsItuHoEMVe+DlonsK+0836LIRDnm6MXQ=",
"lastModified": 1777077449,
"narHash": "sha256-AIiMJiqvGrN4HyLEbKAoCSRRYn0rnlW5VbKNIMIYqm4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "10e7ad5bbcb421fe07e3a4ad53a634b0cd57ffac",
"rev": "a4bf06618f0b5ee50f14ed8f0da77d34ecc19160",
"type": "github"
},
"original": {
+1 -1
View File
@@ -38,7 +38,7 @@
pkgs = nixpkgs.legacyPackages.${system};
pkgs-unstable = import nixpkgs-unstable {
inherit system;
config.allowUnfree = false;
config.allowUnfree = true; #hplipWithPlugins is unfree...
};
in {
nixosConfigurations = {
+5 -3
View File
@@ -20,6 +20,7 @@
../../modules/nixos/nixUtils.nix
../../hostsModules/laptop/nixos/udev.nix
../../hostsModules/laptop/nixos/disk.nix
../../modules/nixos/printer.nix
];
@@ -50,6 +51,9 @@
extraSpecialArgs = {inherit inputs pkgs-unstable;};
};
services.dbus.enable = true;
security.polkit.enable = true;
environment.pathsToLink = [
"/share/applications"
"/share/xdg-desktop-portal"
@@ -120,8 +124,6 @@
# Configure console keymap
console.keyMap = "fr_CH";
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable sound with pipewire.
services.pulseaudio.enable = false;
@@ -156,7 +158,7 @@
# Allow unfree packages
nixpkgs.config.allowUnfree = true; # Nonfree packages: Obsidian
nixpkgs.config.allowUnfree = true; # Nonfree packages: hplipWithPlugin
# List packages installed in system profile. To search, run:
# $ nix search wget
+43
View File
@@ -0,0 +1,43 @@
{
config,
pkgs,
...
}: {
#https://wiki.nixos.org/wiki/Printing
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
# Enable CUPS to print documents.
services.printing = {
enable = true;
drivers = with pkgs; [
cups-filters
#cups-browsed
#gutenprint
#gutenprintBin
hplipWithPlugin
hplip
];
};
services.ipp-usb.enable = true;
environment.systemPackages = with pkgs; [
kdePackages.print-manager
ghostscript
hplipWithPlugin
];
hardware.printers = {
ensurePrinters = [
{
name = "HP_OfficeJet_Pro_7740";
location = "Home";
deviceUri = "hp:/usb/OfficeJet_Pro_7740_series";
model = "drv:///hp/hpcups.drv/hp-officejet_pro_7740_series.ppd";
}
];
ensureDefaultPrinter = "HP_OfficeJet_Pro_7740";
};
}
+13 -3
View File
@@ -1,9 +1,7 @@
{
...
}:
# add a desktop entry here if you have an error like
# Failed to register with host portal QDBusError("org.freedesktop.portal.Error.Failed", "Could not register app ID: App info not found for 'org.quickshell'")
# see ../../docs/printing.md
{
home.file.".local/share/applications/org.quickshell.desktop" = {
enable = true;
@@ -19,4 +17,16 @@
X-DBUS-ServiceName=org.quickshell
'';
};
home.file.".local/share/applications/org.kde.PrintQueue.desktop" = {
enable = true;
text = ''
[Desktop Entry]
Type=Application
Name=Print Queue
Exec=print-queue
Icon=printer
Categories=Utility;
StartupNotify=true
'';
};
}