The dmenu command's version message.

    Raises:
        DmenuCommandError

    Example:

        >>> import dmenu
        >>> dmenu.version()
        'dmenu-4.5, \xc2\xa9 2006-2012 dmenu engineers, see LICENSE for details'

def version(command='dmenu'):
    '''The dmenu command's version message.

    Raises:
        DmenuCommandError

    Example:

        >>> import dmenu
        >>> dmenu.version()
        'dmenu-4.5, \xc2\xa9 2006-2012 dmenu engineers, see LICENSE for details'
    '''

    args = [command, '-v']

    try:
        # start the dmenu process
        proc = subprocess.Popen(
            args,
            universal_newlines=True,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
    except OSError as err:
        # something went wrong with starting the process
        raise DmenuCommandError(args, err)

    if proc.wait() == 0:
        # version information from stdout
        return proc.stdout.read().rstrip('\n')

    # error from dmenu
    raise DmenuCommandError(args, proc.stderr.read())