1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#!/usr/bin/env ruby CLIPBOARD_PROG = "clipboard-0.1.rb" CLIPBOARD_PATH = "/path/to/clipboardprog/" command = "ps aux|grep '#{CLIPBOARD_PROG}'|grep '#{ENV['USER']}'|grep -v grep" proc = `#{command}`.strip.scan(/^#{ENV['USER']} *([0-9]+)/)[0].to_s.to_i puts proc if proc == 0 system "exec #{CLIPBOARD_PATH}#{CLIPBOARD_PROG} &" else system "kill -s USR1 #{proc}" end |