From e5b7193aae9e729af7dedb867e2e907299083a6c Mon Sep 17 00:00:00 2001 From: Agnete Moos Date: Tue, 4 Feb 2025 16:37:33 +0100 Subject: [PATCH 1/2] Use princh-setup to add the printer instead of lpadmin --- printer_princh_add.md | 2 +- printer_princh_install.md | 2 +- scripts/printer_princh_add.sh | 22 +++++++++++++--------- scripts/printer_princh_install.sh | 10 +++++----- 4 files changed, 20 insertions(+), 16 deletions(-) mode change 100755 => 100644 scripts/printer_princh_add.sh diff --git a/printer_princh_add.md b/printer_princh_add.md index 770761a..c6ab645 100644 --- a/printer_princh_add.md +++ b/printer_princh_add.md @@ -1,6 +1,6 @@ --- title: "Tilføj Princh Cloud Printer" -version: 1 +version: 2 parent: "Printer" source: scripts/printer_options_set.sh parameters: diff --git a/printer_princh_install.md b/printer_princh_install.md index b89ad72..e44e334 100644 --- a/printer_princh_install.md +++ b/printer_princh_install.md @@ -1,6 +1,6 @@ --- title: "Installer Princh Cloud Printer" -version: 1 +version: 2 parent: "Printer" source: scripts/printer_princh_install.sh parameters: diff --git a/scripts/printer_princh_add.sh b/scripts/printer_princh_add.sh old mode 100755 new mode 100644 index 6ecbead..06f29fb --- a/scripts/printer_princh_add.sh +++ b/scripts/printer_princh_add.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env sh +#!/usr/bin/env sh set -ex @@ -6,24 +6,28 @@ if get_os2borgerpc_config os2_product | grep --quiet kiosk; then echo "Dette script er ikke designet til at blive anvendt på en kiosk-maskine." exit 1 fi -# lpadmin doesn't like spaces + +# CUPS/lpadmin doesn't like spaces NAME="$(echo "$1" | tr ' ' '_')" PRINCH_ID="$2" DESCRIPTION="$3" -SET_STANDARD="$4" +SET_DEFAULT="$4" + +if [ "$SET_DEFAULT" = "True" ]; then + DEFAULT_MAYBE="--default" +fi # Delete the printer if a printer already exists by that NAME lpadmin -x "$NAME" || true # No princh-cloud-printer binary in path, so checking for princh-setup if which princh-setup > /dev/null; then - lpadmin -p "$NAME" -v "princh:$PRINCH_ID" -D "$DESCRIPTION" -E -P /usr/share/ppd/princh/princheu.ppd -L "$DESCRIPTION" + # The two driver options are ISO and US, determining the paper sizes it uses, and specifically whether princheu.ppd (ISO) or princhus.ppd (US) is being used + # shellcheck disable=SC2086 # With quotes around princh_setup gets an explicitly empty argument and fails because of it + princh-setup add --name "$NAME" --device-id "$PRINCH_ID" --driver iso --description "$DESCRIPTION" $DEFAULT_MAYBE + # Finally additionally set the location on the newly added printer + lpadmin -p "$NAME" -L "$DESCRIPTION" else echo "Princh is not installed. Please run the script that installs Princh before this one." exit 1 fi - -if [ "$SET_STANDARD" = "True" ]; then - # Set the printer as standard printer - lpadmin -d "$NAME" && lpstat -d -fi diff --git a/scripts/printer_princh_install.sh b/scripts/printer_princh_install.sh index 2a92801..4692792 100644 --- a/scripts/printer_princh_install.sh +++ b/scripts/printer_princh_install.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env sh +#!/usr/bin/env sh set -ex @@ -29,15 +29,15 @@ if [ "$PRINCH_VERSION_AVAILABLE" != "$PRINCH_VERSION_INSTALLED" ]; then # predictable for the command to install it below curl $URL --output $FILE dpkg --install $FILE - + rm $FILE else printf '%s\n' "Princh is already installed and in the most recent version." fi # Create Princh autostart -princh_autostart_dir=/home/.skjult/.config/autostart +PRINCH_AUTOSTART_DIR=/home/.skjult/.config/autostart -mkdir --parents $princh_autostart_dir +mkdir --parents $PRINCH_AUTOSTART_DIR # This will fail if the symlink already exists, but the exit status is still 0 so no problem -ln -sf /usr/share/applications/com-princh-print-daemon.desktop $princh_autostart_dir +ln -sf /usr/share/applications/com-princh-print-daemon.desktop $PRINCH_AUTOSTART_DIR From 9ec1b7d39adb168a45dcf1248c8ae5fbc3e5d66b Mon Sep 17 00:00:00 2001 From: Agnete Moos Date: Wed, 5 Feb 2025 16:23:40 +0100 Subject: [PATCH 2/2] Fix wrong source path --- printer_princh_add.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/printer_princh_add.md b/printer_princh_add.md index c6ab645..1ba2ef8 100644 --- a/printer_princh_add.md +++ b/printer_princh_add.md @@ -2,7 +2,7 @@ title: "Tilføj Princh Cloud Printer" version: 2 parent: "Printer" -source: scripts/printer_options_set.sh +source: scripts/printer_princh_add.sh parameters: - name: "Navn (OBS: INGEN ÆØÅ, mellemrum eller apostrofer)" type: "string"