Wifi toggle on power loss

Hi,

I am running a new device, HP Chromebook 11 G5, which to me seemed to be the perfect fit for my business application. Which is ironic as it only has a single M.2 wifi card and no ethernet.

I am really liking this device, I pretty much gutted the thing and it's headless with the entire screen and panel / hinges removed from the device.

As it operates from this compiled openwrt I built, most of the keyboard is not functional outside of the bios. I had a UEFI firmware installed on it and honestly, I love this device. It has a massive battery. Initial testing showed a loss of power of 18% in 5 hours, and I know that these devices are a dim a dozen. Ordering a usb ethernet dongle for it's purpose, and that will be the deciding factor for me.

At the moment I had been looking to implement some form of wifi toggle for it. I looked at the buttons, which honestly, only the power button seems to work. I thought of something else, I'm probably going to operate the device in offline mode when off the power.

What I wanted to know, is if there is a way to trigger the wifi to turn off and on when the battery switches into discharge. /sys/class/power_device/BAT0/status shows discharging when unplugged. I would assume that when plugged in this changes. I could definitely sweep the internet searching, but if someone has the answer off the top of their head, I'd love to know. Also, in kind of a swap of information, felt that if anyone else was wanting to know how to try this, it's certainly very easy and happy to impart some of the experience on this. I think my battery-less Vocore2 is certainly feeling lonely at the moment.