-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmac_printers_resume.command
More file actions
49 lines (46 loc) · 931 Bytes
/
Copy pathmac_printers_resume.command
File metadata and controls
49 lines (46 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
#!/bin/bash
# macOS Resume Printers
# Usage: mac_printers_resume.command
# By: Gene Chao - Last updated: 10/9/2019
if [ ! -t 1 ]; then exit 1; fi
echo
echo Resume Printers
echo
_printers=()
while read -r _printer; do
_printers+=($_printer)
done < <(lpstat -p | grep '^printer \w\+ disabled ' | awk '{print $2}')
if [ ! -z "$_printers" ]; then
_canceljobs=n
while true; do
echo -n "Cancel all print jobs (y/n)? "
read
REPLY=${REPLY# }
REPLY=${REPLY% }
case "${REPLY:0:1}" in
y|Y)
_canceljobs=y
break
;;
n|N)
_canceljobs=n
break
;;
*)
continue
;;
esac
done
if [ "$_canceljobs" = "y" ]; then
(set -x; cancel -ax ${_printers[*]})
fi
for _printer in ${_printers[*]}; do
_cupsenable_params=
if [ "$_canceljobs" = "y" ]; then _cupsenable_params=-c; fi
(set -x; cupsenable $_cupsenable_params $_printer)
done
else
echo No disabled printers detected
fi
echo