I have put together a snippet for nickelmenu it stores the flag in /tmp as it resets to default on reboot and tmp is destroied on reboot
Code:
menu_item : main : USB OTG Status : cmd_output : 500 : quiet : test -e /tmp/otg_enabled
chain_success : dbg_toast : USB OTG IS ENABLED
chain_failure : dbg_toast : USB OTG IS DISABLED
menu_item : main : Toggle USB OTG : cmd_output : 500 : quiet : test -e /tmp/otg_enabled
chain_success : skip : 5
chain_always : cmd_spawn : quiet: touch /tmp/otg_enabled
chain_always : cmd_spawn : quiet: mount -t debugfs none /sys/kernel/debug
chain_always : cmd_spawn : quiet: echo host > /sys/kernel/debug/ci_hdrc.0/role
chain_always : dbg_toast : USB OTG IS NOW ENABLED
chain_always : skip : 3
chain_always : cmd_spawn : quiet: rm /tmp/otg_enabled
chain_always : cmd_spawn : quiet: echo gadget > /sys/kernel/debug/ci_hdrc.0/role
chain_always : dbg_toast : USB OTG IS NOW DISABLED