From 8c4f3828720888e544c711332e557f5cdee80851 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 13 Jun 2013 11:54:32 +0200 Subject: add sleep possibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- unstickpixels | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/unstickpixels b/unstickpixels index 2068ea8..d3aba07 100755 --- a/unstickpixels +++ b/unstickpixels @@ -19,6 +19,7 @@ ## import sys +import time from subprocess import Popen, PIPE @@ -27,6 +28,9 @@ def print(text, end = '\n'): sys.stdout.buffer.flush() +sleep = 0 if len(sys.argv) < 2 else int(sys.argv[1]) + + (height, width) = Popen(['stty', 'size'], stdout=PIPE).communicate()[0].decode('utf-8', 'replace').split(' ') (height, width) = (int(height), int(width)) COPYING = ['unstickpixels – screen loop to try to unstick dead pixels', @@ -55,13 +59,26 @@ try: input() started = True print('\033[H', '') - while True: - sys.stdout.buffer.write('\033]P0FF0000\033[2J'.encode('utf-8')) - sys.stdout.buffer.flush() - sys.stdout.buffer.write('\033]P000FF00\033[2J'.encode('utf-8')) - sys.stdout.buffer.flush() - sys.stdout.buffer.write('\033]P00000FF\033[2J'.encode('utf-8')) - sys.stdout.buffer.flush() + if sleep == 0: + while True: + sys.stdout.buffer.write('\033]P0FF0000\033[2J'.encode('utf-8')) + sys.stdout.buffer.flush() + sys.stdout.buffer.write('\033]P000FF00\033[2J'.encode('utf-8')) + sys.stdout.buffer.flush() + sys.stdout.buffer.write('\033]P00000FF\033[2J'.encode('utf-8')) + sys.stdout.buffer.flush() + else: + sleep /= 1000 + while True: + sys.stdout.buffer.write('\033]P0FF0000\033[2J'.encode('utf-8')) + sys.stdout.buffer.flush() + time.sleep(sleep) + sys.stdout.buffer.write('\033]P000FF00\033[2J'.encode('utf-8')) + sys.stdout.buffer.flush() + time.sleep(sleep) + sys.stdout.buffer.write('\033]P00000FF\033[2J'.encode('utf-8')) + sys.stdout.buffer.flush() + time.sleep(sleep) except: pass if started: -- cgit v1.2.3-70-g09d2