Here is some bash code that can be used to DA queries.
I’ve hardwired in the DA1 and DA2 control sequences but
you can substitute other sequences as desired.
#!/bin/bash
#
# This shows how to use bash to send ANSI terminal control
# sequences to the underlying TTY and read the response for
# queries such as Device Attributes (DA). If the primary
# DA includes the value 4 then sixel graphics is supported.
# Query DA 1
echo -e "\n\nQuerying primary Device Attribute for TTY"
IFS=";" read -a REPLY -s -t 1 -d "c" -p $'\e[c' >&2
echo "${#REPLY[@]}" # How many values were returned?
echo "${!REPLY[@]}" # What indices were set?
# Use printf with %q option to display printing and non-
# printing values returned.
for code in "${REPLY[@]}" ; do printf '%q\n' "$code" ; done
# Query DA 2
echo -e "\n\nQuerying secondary Device Attribute for TTY"
IFS=";" read -a REPLY -s -t 1 -d "c" -p $'\e[>c' >&2
echo "${#REPLY[@]}" # How many values were returned?
echo "${!REPLY[@]}" # What indices were set?
# Use printf with %q option to display printing and non-
# printing values returned.
for code in "${REPLY[@]}" ; do printf '%q\n' "$code" ; done
# Here is another way to output the values from the terminal
# that seems to work for a number of different shells. It seems
# to produce output good for shell input
bash> typeset -p REPLY
declare -a REPLY=([0]=$'\E[>19' [1]="370" [2]="0")