Only set title if DISPLAY is set, change os x behavior to check DISPLAY.

This commit is contained in:
Michael Lazar
2016-07-15 16:22:54 -07:00
parent 131e64273a
commit 797ea5d072
3 changed files with 27 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import sys
import locale
import logging
@@ -29,16 +30,17 @@ _logger = logging.getLogger(__name__)
def main():
"Main entry point"
"""Main entry point"""
# Squelch SSL warnings
logging.captureWarnings(True)
locale.setlocale(locale.LC_ALL, '')
# Set the terminal title
title = 'rtv {0}'.format(__version__)
sys.stdout.write('\x1b]2;{0}\x07'.format(title))
sys.stdout.flush()
if os.getenv('DISPLAY'):
title = 'rtv {0}'.format(__version__)
sys.stdout.write('\x1b]2;{0}\x07'.format(title))
sys.stdout.flush()
args = Config.get_args()
fargs, bindings = Config.get_file(args.get('config'))
@@ -79,6 +81,14 @@ def main():
filename=config['log'],
format='%(asctime)s:%(levelname)s:%(filename)s:%(lineno)d:%(message)s')
_logger.info('Starting new session, RTV v%s', __version__)
env = [
('$DISPLAY', os.getenv('DISPLAY')),
('$XDG_CONFIG_HOME', os.getenv('XDG_CONFIG_HOME')),
('$BROWSER', os.getenv('BROWSER')),
('$PAGER', os.getenv('PAGER')),
('$RTV_EDITOR', os.getenv('RTV_EDITOR')),
('$RTV_URLVIEWER', os.getenv('RTV_URLVIEWER'))]
_logger.info('Environment: %s', env)
else:
# Add an empty handler so the logger doesn't complain
logging.root.addHandler(logging.NullHandler())