I have attached my UPS to ubuntu and it's recognised. However I don't like the options that I see in ubuntu power settings. I have another PC also attached to same UPS. So I want ubuntu desktop to execute script when power is about 50% so my second pc can also properly hibernate. And then I can hibernate my ubuntu PC with same script.
Is it possible to do that in the way that is not breaking ubuntu implpementation of UPS monitor? I have read that I can install nut but I have some errors, maybe it's a conflict
● nut-monitor.service - Network UPS Tools - power device monitor and shutdown controller
Loaded: loaded (/lib/systemd/system/nut-monitor.service; enabled; vendor preset: enabled)
Active: failed (Result: protocol) since Sat 2019-07-13 02:09:46 MSK; 11ms ago
Process: 13906 ExecStart=/sbin/upsmon (code=exited, status=0/SUCCESS)
Maybe I can catch some dmesg message or check the status of UPS with some native tool?
Ubuntu automatically keeps track of all batteries status:
The same information displayed in the GUI screen above can also be accessed from your terminal / shell / bash script (they are all sort of the same thing in many ways).
To get the same information from CLI use:
Then to narrow it down to percentage use:
Then to extract the second column use:
Then to extract only digits and eliminate leading spaces and trailing % use:
Now assign what you want to a variable and display it:
Next step is to write a script something like this
This is a script I would use, in your case adapt it to hibernate (I have a laptop so I never hibernate). My UPS is for window fan, not laptop which has it's own battery and is suspended when I'm at work. Technology can be used differently by different people.