#!/usr/bin/env python3

import sys
import os

# Which terminal? Guess based on desktop environment:
desktop = os.environ.get('XDG_CURRENT_DESKTOP')
if desktop is not None:
    desktop = desktop.lower()

if desktop in ['gnome', 'unity', 'unity:unity7']:
    TERMINAL = ['gnome-terminal', '-x']
elif desktop == 'kde':
    TERMINAL = ['konsole', '-e']
elif desktop == 'xfce':
    TERMINAL = ['xfce4-terminal', '-x']
else:
    TERMINAL = ['xterm', '-e']


def main():
    # Replace this process with a terminal emulator, with command line arguments
    # to run 'inshell' (the other script provided by this package) with the user's
    # command:
    sys.argv[0] = 'inshell'
    os.execvp(TERMINAL[0], TERMINAL + sys.argv)


if __name__ == '__main__':
    main()
