Created
March 7, 2021 13:47
-
-
Save AfvanMoopen/4d146530f1758bc0e16274a66bb68fe3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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