Skip to content

Instantly share code, notes, and snippets.

@AfvanMoopen
Created March 7, 2021 13:47
Show Gist options
  • Save AfvanMoopen/4d146530f1758bc0e16274a66bb68fe3 to your computer and use it in GitHub Desktop.
Save AfvanMoopen/4d146530f1758bc0e16274a66bb68fe3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
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
# Script Usage:
sudo ruby dymo_speed.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment