aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-06-13 11:54:32 +0200
committerMattias Andrée <maandree@operamail.com>2013-06-13 11:54:32 +0200
commit8c4f3828720888e544c711332e557f5cdee80851 (patch)
tree143d4329fe4da84af0b424f6a44e87ebd8575e58
parentminor improvement with flush (diff)
downloadunstickpixels-8c4f3828720888e544c711332e557f5cdee80851.tar.gz
unstickpixels-8c4f3828720888e544c711332e557f5cdee80851.tar.bz2
unstickpixels-8c4f3828720888e544c711332e557f5cdee80851.tar.xz
add sleep possibility
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rwxr-xr-xunstickpixels31
1 files 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: