Skip to content

Instantly share code, notes, and snippets.

@Shinichi-Ohki
Created August 2, 2020 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shinichi-Ohki/b0405b2bcf6534645cd91d19faa37a86 to your computer and use it in GitHub Desktop.
Save Shinichi-Ohki/b0405b2bcf6534645cd91d19faa37a86 to your computer and use it in GitHub Desktop.
TSP(Task Spooler)のキューに積まれたタスクが全部終わったらPush Bulletで通知を飛ばすRuby Script
#!/usr/bin/env ruby
require 'pushbullet_ruby'
client = PushbulletRuby::Client.new("***pushbullet Access Token***")
tsstr = `tsp`
count=[0,0,0] # running | queued | finished
tsstr.each_line do |line|
if line =~ / running / then
count[0] += 1
p line
elsif line =~ / queued / then
count[1] += 1
p line
elsif line =~ / finished / then
count[2] += 1
p line
end
end
p count
if count[1] != 0 then
exit
end
client.push_note(
receiver: :device,
id: '***device iden***',
params: {
title: 'TSP queue clear',
body: "#{count[2]} tasks finished"
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment