colort[int]
A small program for ‘tinting’ colors by values. Also supports inverting colors.
command | output |
---|---|
colort 1 "#000000" |
#010101 |
colort -l 1 "#FFFFFF" |
#FFFFFF |
colort -l 1 "#FFFFFF" |
#FFFFFF , exit status 0 |
colort -i "#000000" |
#FFFFFF |
colort 60 "#000000" |
#3C3C3C |
colort -60 "#000000" |
#C4C4C4 |
colort -s 4 1 "spam000000spam" |
spam010101spam |
colort -t -s 4 1 "spam000000spam" |
010101 |
colort -t "ff000000" |
000000 |
colort -r 1 "#000000" |
#010000 |
-s
)-l
flag limits color tinting by not letting values roll around.-i
flag inverts colors.-s
flag selects the index in the input string to start getting color from.-t
flag makes the output only the color string-c
flag calculates the contrast of the color. If this evaluates to black, exit status 0. If white, exit status 1.long
datatype.Invert a background color to have readable text on any background:
![]() |
![]() |
![]() |
---|---|---|
Auto-determine select and icon colors for GTK themes based on the background (using oomox and acyl in these examples)
Select_color="$(colort -c "$BG" && colort 25 "$BG" || colort -25 "$BG")"
Icon_color="$(colort -c "$BG" && colort -l 80 "$BG" || colort -l -80 "$BG")"
![]() |
![]() |
![]() |
---|---|---|
If for some reason we wanted everything to have a blue tint, we can wrap both the above calls with a colort -b 40
:
![]() |
![]() |
![]() |
---|---|---|
Input background colors used for the examples: 282828
, AB4642
, D8D8D8
from base16 colorsets.