Re:How to trigger a command on Linux when disconnected from ...
by netsharc on Thursday July 31, 2025 @09:05AM
(#44745246)
Maybe you know this, but UPSs have signaling software to tell whomever it may concern if it has lost power and is running on battery.
For big servers, the UPS's batteries might only give minutes of power, so they'd listen for such a signal to do an orderly shutdown.
Re:How to trigger a command on Linux when disconnected from ...
by piperswe on Thursday July 31, 2025 @11:38AM
(#44746767)
> I wonder if the same approach will also work for a computer connected to a UPS. Probably not!
Considering that my UPS appears as a battery in KDE when I plug the USB cable in, I wouldn't be surprised if it's treated the same as a laptop battery across most of the stack
Re:How to trigger a command on Linux when disconnected from ...
by telotortium on Thursday July 31, 2025 @12:06PM
(#44747037)
Was the title changed since this comment? It now says “How to trigger a command on Linux when power switches from AC to battery”, which seems perfectly clear. I’m guessing “from AC to battery” was not present initially?
Re:How to trigger a command on Linux when disconnected from ...
by nemomarx on Thursday July 31, 2025 @12:28PM
(#44747250)
Yeah, it was when disconnected from power at first
Re:How to trigger a command on Linux when disconnected from ...
by wildzzz on Thursday July 31, 2025 @11:23AM
(#44746602)
With that example, why not just remove the battery entirely?
As for a UPS, I have a Synology NAS that can monitor an APC UPS over its serial USB port. When the UPS loses power or is told to gracefully shutdown, the NAS also gracefully shuts down.
Re:How to trigger a command on Linux when disconnected from ...
by Rooster61 on Thursday July 31, 2025 @09:47AM
(#44745612)
+1 to this.
This is still a logical use case, but it's not the mental image that immediately got conjured up after reading the title for me.
Re:How to trigger a command on Linux when disconnected from ...
by NooneAtAll3 on Thursday July 31, 2025 @10:21AM
(#44745957)
+1?
Re:How to trigger a command on Linux when disconnected from ...
by wkjagt on Thursday July 31, 2025 @11:07AM
(#44746468)
It's a way of signaling agreement.
Re:How to trigger a command on Linux when disconnected from ...
by Rooster61 on Thursday July 31, 2025 @11:18AM
(#44746561)
They were correcting my initial "1+"
Re:How to trigger a command on Linux when disconnected from ...
by tenthirtyam on Thursday July 31, 2025 @01:16PM
(#44747801)
Shouldn't we programmers be just typing "++"?
Re:How to trigger a command on Linux when disconnected from ...
by yndoendo on Thursday July 31, 2025 @10:59PM
(#44752608)
i++
Re:How to trigger a command on Linux when disconnected from ...
by Rooster61 on Thursday July 31, 2025 @11:06AM
(#44746459)
Yes, thank you. Fatfingered
Re:How to trigger a command on Linux when disconnected from ...
by 1718627440 on Thursday July 31, 2025 @09:14AM
(#44745308)
That's exactly how I understood the headline.
Re:How to trigger a command on Linux when disconnected from ...
by LoganDark on Thursday July 31, 2025 @09:11AM
(#44745293)
"on power disconnection" (event) probably would've worked better than "when disconnected from power" (time period).
Re:How to trigger a command on Linux when disconnected from ...
by nisegami on Thursday July 31, 2025 @09:05AM
(#44745243)
Computers connected a UPS can use tools like NUT or more specific tools like apcupsd. It's much more common to need to know when a UPS powered device switches to battery to trigger stuff than it is to need to know when a laptop switches to battery, so there's a lot more tooling in that area.
Re:How to trigger a command on Linux when disconnected from ...
by mrheosuper on Thursday July 31, 2025 @10:01PM
(#44752303)
>. Someone steals it, which involves unplugging it from the wall. At the moment it is unplugged it automatically shuts down
You could achieve same thing if you unplug your battery.
What it’s actually about how to automatically automatically trigger a command on a Linux computer (almost certainly a laptop) in the event that it switches from AC power to battery power.
The example given is your laptop is plugged it at a café. Someone steals it, which involves unplugging it from the wall. At the moment it is unplugged it automatically shuts down, locks itself, etc.
I wonder if the same approach will also work for a computer connected to a UPS. Probably not!