This phrase is used to express doing something unintentionally or without conscious thought.
Long explanation:
Verbる ともなしに Verb is a Japanese grammar point used to express doing something without particularly intending to do it; often something happens due to unconscious habit or without a particular reason. It usually involves an action done indirectly or without conscious thought. There are usually two verbs in the sentence: the first verb (in dictionary form) is the unintentional action, and the second one is the result or what you ended up doing.