From 1dc737fb8b51e224ed29e60ae3c1751e3d54f31f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 18 Aug 2012 17:57:50 +0200 Subject: m misc --- ponysay.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'ponysay.py') diff --git a/ponysay.py b/ponysay.py index 23e8f39..1714e77 100755 --- a/ponysay.py +++ b/ponysay.py @@ -40,12 +40,18 @@ The user's home directory 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 + '\'') -- cgit