  In two-dimensional materials research, oxidation is usually considered as a
common source for the degradation of electronic and optoelectronic devices or
even device failure. However, in some cases a controlled oxidation can open the
possibility to widely tune the band structure of 2D materials. In particular,
we demonstrate the controlled oxidation of titanium trisulfide (TiS$_3$), a
layered semiconductor that has attracted much attention recently thanks to its
quasi-1D electronic and optoelectronic properties and its direct bandgap of 1.1
eV. Heating TiS$_3$ in air above 300 {\deg}C gradually converts it into
TiO$_2$, a semiconductor with a wide bandgap of 3.2 eV with ap-plications in
photo-electrochemistry and catalysis. In this work, we investigate the
controlled thermal oxidation of individual TiS$_3$ nanoribbons and its
influence on the optoelectronic properties of TiS$_3$-based photodetectors. We
observe a step-wise change in the cut-off wavelength from its pristine value
~1000 nm to 450 nm after subjecting the TiS$_3$ devices to subsequent thermal
treatment cycles. Ab-initio and many-body calculations confirm an increase in
the bandgap of titanium oxysulfide (TiO$_{2-x}$S$_x$) when increasing the
amount of oxygen and reducing the amount of sulfur.
