diff --git a/docs/printing.md b/docs/printing.md new file mode 100644 index 0000000..2a6520d --- /dev/null +++ b/docs/printing.md @@ -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 (1โ€“100, 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 Iโ€™ll give you a *perfect command tuned to it* (no guessing, no trial and error). diff --git a/flake.lock b/flake.lock index 6a9ba47..2c6c935 100755 --- a/flake.lock +++ b/flake.lock @@ -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": { diff --git a/flake.nix b/flake.nix index 3313439..0554d6b 100644 --- a/flake.nix +++ b/flake.nix @@ -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 = { diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index bf89d8b..550f3bc 100755 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -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 diff --git a/modules/nixos/printer.nix b/modules/nixos/printer.nix new file mode 100644 index 0000000..1a9994f --- /dev/null +++ b/modules/nixos/printer.nix @@ -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"; +}; +} diff --git a/modules/other/desktopEntries.nix b/modules/other/desktopEntries.nix index d47438e..6836d2c 100644 --- a/modules/other/desktopEntries.nix +++ b/modules/other/desktopEntries.nix @@ -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 + ''; + }; }