cleanup: don't touch gui stuff when in cli mode
(cherry picked from commit 811e70fafa1ce687cc4ee4e61d4a0903844796b3)