| 1 | #!/usr/bin/env bash |
| 2 | ############################################################################### |
| 3 | # BRLTTY - A background process providing access to the console screen (when in |
| 4 | # text mode) for a blind person using a refreshable braille display. |
| 5 | # |
| 6 | # Copyright (C) 1995-2026 by The BRLTTY Developers. |
| 7 | # |
| 8 | # BRLTTY comes with ABSOLUTELY NO WARRANTY. |
| 9 | # |
| 10 | # This is free software, placed under the terms of the |
| 11 | # GNU Lesser General Public License, as published by the Free Software |
| 12 | # Foundation; either version 2.1 of the License, or (at your option) any |
| 13 | # later version. Please see the file LICENSE-LGPL for details. |
| 14 | # |
| 15 | # Web Page: http://brltty.app/ |
| 16 | # |
| 17 | # This software is maintained by Dave Mielke <[email protected]>. |
| 18 | ############################################################################### |
| 19 | |
| 20 | . "$(dirname "${0}")/brltty-prologue.sh" |
| 21 | ttyDefaultPath="/dev/tty" |
| 22 | |
| 23 | showProgramUsagePurpose() { |
| 24 | cat <<END_OF_PROGRAM_USAGE_PURPOSE |
| 25 | Inspect or change the size of the current virtual terminal's screen. |
| 26 | END_OF_PROGRAM_USAGE_PURPOSE |
| 27 | } |
| 28 | |
| 29 | addProgramOption p string.path ttyPath "the path to the device" "${ttyDefaultPath}" |
| 30 | addProgramOption c string.count ttyColumns "set the number of columns" |
| 31 | addProgramOption l string.count ttyLines "set the number of lines" |
| 32 | parseProgramArguments "${@}" |
| 33 | |
| 34 | [ -n "${ttyPath}" ] || ttyPath="${ttyDefaultPath}" |
| 35 | showSize=true |
| 36 | |
| 37 | if [ -n "${ttyColumns}" ] |
| 38 | then |
| 39 | verifyInteger "column count" "${ttyColumns}" 1 255 |
| 40 | showSize=false |
| 41 | else |
| 42 | ttyColumns="$(tput cols)" |
| 43 | [ -n "${ttyColumns}" ] || semanticError "column count not available: ${TERM}" |
| 44 | fi |
| 45 | |
| 46 | if [ -n "${ttyLines}" ] |
| 47 | then |
| 48 | verifyInteger "line count" "${ttyLines}" 1 255 |
| 49 | showSize=false |
| 50 | else |
| 51 | ttyLines="$(tput lines)" |
| 52 | [ -n "${ttyLines}" ] || semanticError "line count not available: ${TERM}" |
| 53 | fi |
| 54 | |
| 55 | if "${showSize}" |
| 56 | then |
| 57 | echo "${ttyColumns}x${ttyLines}" |
| 58 | elif [ "${TERM#xterm}" != "${TERM}" ] |
| 59 | then |
| 60 | echo >"${ttyPath}" -n -e "\\e[8;${ttyLines};${ttyColumns}t" |
| 61 | else |
| 62 | stty -F "${ttyPath}" columns "${ttyColumns}" rows "${ttyLines}" |
| 63 | fi |
| 64 | |
| 65 | exit 0 |