aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-08-06 15:28:39 -0300
committerEuAndreh <eu@euandre.org>2025-08-06 15:28:39 -0300
commitf6355af737ca338e82cdf65a564e6cf7e01477d6 (patch)
treef296fa09939a6f0ccbc533be9f1e96f97d41845c
parentetc/sh/rc: Add $POSIXLY_CORRECT (diff)
downloaddotfiles-f6355af737ca338e82cdf65a564e6cf7e01477d6.tar.gz
dotfiles-f6355af737ca338e82cdf65a564e6cf7e01477d6.tar.xz
bin/print: Use $OPTS over lpotions(1) that modifies ~/.cups
-rwxr-xr-xbin/print21
1 files changed, 8 insertions, 13 deletions
diff --git a/bin/print b/bin/print
index 5aef102..4f41272 100755
--- a/bin/print
+++ b/bin/print
@@ -63,13 +63,13 @@ main() {
cd "$NEWDIR"
if [ -z "$DUPLEX" ]; then
- lp in.pdf
+ lp $OPTS in.pdf
cd - > /dev/null
return
fi
if [ "$(n_pages in.pdf)" = '1' ]; then
- lp in.pdf
+ lp $OPTS in.pdf
return
fi
@@ -80,10 +80,10 @@ main() {
NEVEN="$(n_pages even.pdf)"
printf 'Printing odd pages...\n' >&2
- lp odd.pdf
+ lp $OPTS odd.pdf
printf 'Has printing finished yet? Once it does, reload the pages and hit it enter to continue. '
read -r < /dev/tty
- lp even.pdf
+ lp $OPTS even.pdf
if [ "$NODD" != "$NEVEN" ]; then
printf '\n' | lp
@@ -107,24 +107,23 @@ for flag in "$@"; do
esac
done
-QUALITY_SET=false
DUPLEX=
+OPTS='-o PrintQuality=standard'
while getopts 'dq:h' flag; do
case "$flag" in
(d)
DUPLEX=1
;;
(q)
- QUALITY_SET=true
case "$OPTARG" in
low)
- lpoptions -o PrintQuality=draft
+ OPTS='-o PrintQuality=draft'
;;
medium)
- lpoptions -o PrintQuality=standard
+ OPTS='-o PrintQuality=standard'
;;
high)
- lpoptions -o PrintQuality=high
+ OPTS='-o PrintQuality=high'
;;
*)
echo "Bad QUALITY option: \"$OPTARG\"" >&2
@@ -145,10 +144,6 @@ while getopts 'dq:h' flag; do
done
shift $((OPTIND - 1))
-if [ "$QUALITY_SET" = false ]; then
- lpoptions -o PrintQuality=standard
-fi
-
NEWDIR="$(mkdtemp)"
trap 'rm -rf "$NEWDIR"' EXIT
if [ -z "${1:-}" ]; then