-
Notifications
You must be signed in to change notification settings - Fork 2
/
dymo_lag_fix.rb
executable file
·46 lines (44 loc) · 1.37 KB
/
dymo_lag_fix.rb
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
#!/usr/bin/env ruby
# Problem:
#
# There is a 5-10 second delay between each print job when printing labels on a Dymo LabelWriter
# (and probably other Dymo printers) via newer versions of Cups. This affects macOS High Sierra,
# Raspbian Linux, and probably other Linux distributions.
#
# This script is a hack to work around the problem by killing hung print processes once the label is finished printing.
#
# Script Usage:
#
# sudo ruby dymo_speed.rb
#
# This is what you see when Dymo is printing:
#
# $ ps aux | grep -i dymo
# lp 6428 4.5 0.5 13244 5012 ? S 18:03 0:00 Dymo 63 ...
# root 6429 3.0 0.4 37684 4596 ? Sl 18:03 0:00 usb://DYMO/LabelWriter%20450?serial=...
#
#
# This is what you see when the Dymo driver is sleeping, preventing the next print job from running:
#
# $ ps aux | grep -i dymo
# root 6429 3.0 0.4 37684 4596 ? Sl 18:03 0:00 usb://DYMO/LabelWriter%20450?serial=...
#
# When the second scenario is witnessed, kill -9 the driver so the next job can be processed.
#
loop do
printing = false
driver_pid = nil
`ps aux | grep -i [d]ymo`.split(/\n/).each do |line|
parts = line.split
user = parts[0]
pid = parts[1]
name = parts[10]
printing = true if user == 'lp'
driver_pid = pid if name =~ %r{usb://}
end
if driver_pid && !printing
`kill -9 #{driver_pid}`
puts "#{driver_pid} was killed"
end
sleep 0.1
end