Closed walles closed 5 months ago
Example shell script for querying the terminal background color:
#!/bin/sh
OLDSTTY=$(stty -g)
stty raw -echo min 0
echo "\033]11;?\033\\"
# If this delay is too short you will miss your terminal's response
sleep 1
read -r ANSWER
stty "$OLDSTTY"
# Extract response body
RGB=$(echo "$ANSWER" | sed 's/[^r]*//' | sed 's@[^rgb:0-9a-f/]@@g')
echo "$RGB"
Example response: rgb:fefe/f4f4/9c9c
Inspired by: https://stackoverflow.com/a/30540928/473672
We should re-apply ed491742a18f145b7fe4c755343d64969a9f7531 (pick status bar color based on the current style) or something to that effect after this is done.
According to https://stackoverflow.com/a/7767891/473672 some terminals support querying the actual background color of the terminal window.
Unclear what happens with background images / transparency, but still.
Example usage, text after the second
$
is the response from the terminal.