aboutsummaryrefslogtreecommitdiff
path: root/ponysay.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-08-18 17:57:50 +0200
committerMattias Andrée <maandree@operamail.com>2012-08-18 17:57:50 +0200
commit1dc737fb8b51e224ed29e60ae3c1751e3d54f31f (patch)
tree27d0007c396ce09c1f07d7bc3ba95cb69c6d96ba /ponysay.py
parent6e754c5509228f7c9b7d2aa3eca0ab6fb4e211d6 (diff)
downloadponysay-1dc737fb8b51e224ed29e60ae3c1751e3d54f31f.tar.gz
ponysay-1dc737fb8b51e224ed29e60ae3c1751e3d54f31f.tar.bz2
ponysay-1dc737fb8b51e224ed29e60ae3c1751e3d54f31f.zip
m misc
Diffstat (limited to 'ponysay.py')
-rwxr-xr-xponysay.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/ponysay.py b/ponysay.py
index 23e8f39..1714e77 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -41,11 +41,17 @@ HOME = os.environ['HOME']
'''
+Whether the program is execute in Linux VT (TTY)
+'''
+linuxvt = os.environ['TERM'] == 'linux'
+
+
+'''
The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY)
'''
ponydirs = []
-if os.environ['TERM'] == 'linux': _ponydirs = [HOME + '/.local/share/ponysay/ttyponies/', INSTALLDIR + '/share/ponysay/ttyponies/']
-else: _ponydirs = [HOME + '/.local/share/ponysay/ponies/', INSTALLDIR + '/share/ponysay/ponies/' ]
+if linuxvt: _ponydirs = [HOME + '/.local/share/ponysay/ttyponies/', INSTALLDIR + '/share/ponysay/ttyponies/']
+else: _ponydirs = [HOME + '/.local/share/ponysay/ponies/', INSTALLDIR + '/share/ponysay/ponies/' ]
for ponydir in _ponydirs:
if os.path.isdir(ponydir):
ponydirs.append(ponydir)
@@ -320,9 +326,11 @@ class ponysay():
pony = self.__getponypath(args.pony)
- if "think.py" in __file__: cmd = 'cowthink'
+ if 'think.py' in __file__: cmd = 'cowthink'
else: cmd = 'cowsay'
+ if linuxvt:
+ print('\033[H\033[2J', end='')
os.system(cmd + (' -W ' + args.wrap if args.wrap is not None else '') + ' -f ' + pony + ' \'' + msg + '\'')