The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Term::Detect - Detect running under terminal (and get terminal emulator information)

VERSION

version 0.03

SYNOPSIS

 use Term::Detect qw(detect_terminal);
 say "Running under terminal" if detect_terminal();

DESCRIPTION

FUNCTIONS

detect_terminal([$flag]) => ANY

Return undef if not detected running under terminal.

Otherwise, return a hash of information, currently includes:

  • emulator_engine => STR

  • emulator_software => STR

    Currently Konsole and xterm can be detected through environment because they publish some environment variables.

    If $flag contains "p", will execute pstree to try to find out emulator software from parent process.

  • color_depth => INT

    Either 0 (does not support ANSI color codes), 16, 256, or 16777216 (2**24).

  • default_bgcolor => STR (6-hexdigit RGB)

    For example, any xterm is assumed to have white background (ffffff) by default, while Konsole is assumed to have black (000000).

  • unicode => BOOL

    Whether terminal supports Unicode/wide characters.

SEE ALSO

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.