Skip to content

Commit 6a96d19

Browse files
authored
Merge pull request #21 from OS2borgerPC/20-princh-scripts
Use princh-setup to add the printer instead of lpadmin
2 parents ff6f414 + 9ec1b7d commit 6a96d19

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

printer_princh_add.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: "Tilføj Princh Cloud Printer"
3-
version: 1
3+
version: 2
44
parent: "Printer"
5-
source: scripts/printer_options_set.sh
5+
source: scripts/printer_princh_add.sh
66
parameters:
77
- name: "Navn (OBS: INGEN ÆØÅ, mellemrum eller apostrofer)"
88
type: "string"

printer_princh_install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Installer Princh Cloud Printer"
3-
version: 1
3+
version: 2
44
parent: "Printer"
55
source: scripts/printer_princh_install.sh
66
parameters:

scripts/printer_princh_add.sh

100755100644
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
#! /usr/bin/env sh
1+
#!/usr/bin/env sh
22

33
set -ex
44

55
if get_os2borgerpc_config os2_product | grep --quiet kiosk; then
66
echo "Dette script er ikke designet til at blive anvendt på en kiosk-maskine."
77
exit 1
88
fi
9-
# lpadmin doesn't like spaces
9+
10+
# CUPS/lpadmin doesn't like spaces
1011
NAME="$(echo "$1" | tr ' ' '_')"
1112
PRINCH_ID="$2"
1213
DESCRIPTION="$3"
13-
SET_STANDARD="$4"
14+
SET_DEFAULT="$4"
15+
16+
if [ "$SET_DEFAULT" = "True" ]; then
17+
DEFAULT_MAYBE="--default"
18+
fi
1419

1520
# Delete the printer if a printer already exists by that NAME
1621
lpadmin -x "$NAME" || true
1722

1823
# No princh-cloud-printer binary in path, so checking for princh-setup
1924
if which princh-setup > /dev/null; then
20-
lpadmin -p "$NAME" -v "princh:$PRINCH_ID" -D "$DESCRIPTION" -E -P /usr/share/ppd/princh/princheu.ppd -L "$DESCRIPTION"
25+
# 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
26+
# shellcheck disable=SC2086 # With quotes around princh_setup gets an explicitly empty argument and fails because of it
27+
princh-setup add --name "$NAME" --device-id "$PRINCH_ID" --driver iso --description "$DESCRIPTION" $DEFAULT_MAYBE
28+
# Finally additionally set the location on the newly added printer
29+
lpadmin -p "$NAME" -L "$DESCRIPTION"
2130
else
2231
echo "Princh is not installed. Please run the script that installs Princh before this one."
2332
exit 1
2433
fi
25-
26-
if [ "$SET_STANDARD" = "True" ]; then
27-
# Set the printer as standard printer
28-
lpadmin -d "$NAME" && lpstat -d
29-
fi

scripts/printer_princh_install.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/env sh
1+
#!/usr/bin/env sh
22

33
set -ex
44

@@ -29,15 +29,15 @@ if [ "$PRINCH_VERSION_AVAILABLE" != "$PRINCH_VERSION_INSTALLED" ]; then
2929
# predictable for the command to install it below
3030
curl $URL --output $FILE
3131
dpkg --install $FILE
32-
32+
rm $FILE
3333
else
3434
printf '%s\n' "Princh is already installed and in the most recent version."
3535
fi
3636

3737
# Create Princh autostart
38-
princh_autostart_dir=/home/.skjult/.config/autostart
38+
PRINCH_AUTOSTART_DIR=/home/.skjult/.config/autostart
3939

40-
mkdir --parents $princh_autostart_dir
40+
mkdir --parents $PRINCH_AUTOSTART_DIR
4141

4242
# This will fail if the symlink already exists, but the exit status is still 0 so no problem
43-
ln -sf /usr/share/applications/com-princh-print-daemon.desktop $princh_autostart_dir
43+
ln -sf /usr/share/applications/com-princh-print-daemon.desktop $PRINCH_AUTOSTART_DIR

0 commit comments

Comments
 (0)