Local ring if and only if $x$ or $1-x$ is unit 
A commutative ring $R$ with identity is local if and only if for all $x
\in R$, $x$ or $1-x$ or both is unit.

I have solved the 'only if' part, but I have stuck on the 'if' part for a very long time$\ldots$ My idea is to prove that all non-units form an ideal. But I don't know how to check $rx$ is non-unit for any $r\in R$ and non-unit $x$$\ldots$
 A: In fact, the hard part is proving the nonunits are closed under addition.
Also, the ring can be noncommutative. The same proof will work.
Suppose the nonunits are closed under addition. Then it is impossible for $x$ and $1-x$ to both be nonunits, because their sum (which is $1$) would have to be a nonunit, and of course $1$ is a unit.
Now suppose $R$ has the property that for every $x\in R$, at least one of $x$ and $1-x$ is a unit.  Let $M$ be any maximal right ideal. We claim that every nonunit is in $M$ so that the sum of nonunits is again a nonunit.
First, a little Lemma:

Under the assumptions immediately above, any one-sided invertible element is a unit. Suppose $xy=1$. Then it satisfies $(1-yx)yx=0$.  By assumption, one of $yx$ or $1-yx$ is a unit: but in the former case, $1-yx=0$ is a contradition, and in the latter case $yx=0$ leads to a contradiction too.

If we assume to the contrary there is a nonunit $x$ outside of $M$, it would have to be the case that $xR+M=R$. Selecting $r\in R$ and $m\in M$ such that $xr+m=1$, since $x$ is not a unit, $xr$ is not a unit either (because of the lemma: if $xr$ were a unit, $x$ would be right invertible, hence a unit also.) By assumption again, $1-xr$ is a unit... but $1-xr=m\in M$, which is a proper ideal... that is a contradiction.
Hence all nonunits are contained in $M$, and so the nonunits are closed under addition.
A: Let's show that $R\setminus R^*$ is an ideal ($R^*$ being the set of units).
Clearly, $0\in R\setminus R^*$. Now, let $x, y\in R\setminus R^*$. Suppose, for the sake of contradiction, that $x + y\in R^*$. Then $(x + y)z = 1$ for some $z$. Hence, $xz + yz = 1$. Now, the condition says that one of $xz$ or $yz$ has to be a unit, which means that one of $x$ or $y$ has to be a unit, which is false. Hence $x + y\in R\setminus R^*$. Showing closure under multiplication by $R$'s elements is easy.
