frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

U.S. CBP Reported Employee Arrests (FY2020 – FYTD)

https://www.cbp.gov/newsroom/stats/reported-employee-arrests
1•ludicrousdispla•1m ago•0 comments

Show HN: I built a free UCP checker – see if AI agents can find your store

https://ucphub.ai/ucp-store-check/
1•vladeta•6m ago•1 comments

Show HN: SVGV – A Real-Time Vector Video Format for Budget Hardware

https://github.com/thealidev/VectorVision-SVGV
1•thealidev•8m ago•0 comments

Study of 150 developers shows AI generated code no harder to maintain long term

https://www.youtube.com/watch?v=b9EbCb5A408
1•lifeisstillgood•8m ago•0 comments

Spotify now requires premium accounts for developer mode API access

https://www.neowin.net/news/spotify-now-requires-premium-accounts-for-developer-mode-api-access/
1•bundie•11m ago•0 comments

When Albert Einstein Moved to Princeton

https://twitter.com/Math_files/status/2020017485815456224
1•keepamovin•12m ago•0 comments

Agents.md as a Dark Signal

https://joshmock.com/post/2026-agents-md-as-a-dark-signal/
1•birdculture•14m ago•0 comments

System time, clocks, and their syncing in macOS

https://eclecticlight.co/2025/05/21/system-time-clocks-and-their-syncing-in-macos/
1•fanf2•16m ago•0 comments

McCLIM and 7GUIs – Part 1: The Counter

https://turtleware.eu/posts/McCLIM-and-7GUIs---Part-1-The-Counter.html
1•ramenbytes•18m ago•0 comments

So whats the next word, then? Almost-no-math intro to transformer models

https://matthias-kainer.de/blog/posts/so-whats-the-next-word-then-/
1•oesimania•20m ago•0 comments

Ed Zitron: The Hater's Guide to Microsoft

https://bsky.app/profile/edzitron.com/post/3me7ibeym2c2n
2•vintagedave•23m ago•1 comments

UK infants ill after drinking contaminated baby formula of Nestle and Danone

https://www.bbc.com/news/articles/c931rxnwn3lo
1•__natty__•23m ago•0 comments

Show HN: Android-based audio player for seniors – Homer Audio Player

https://homeraudioplayer.app
2•cinusek•24m ago•0 comments

Starter Template for Ory Kratos

https://github.com/Samuelk0nrad/docker-ory
1•samuel_0xK•25m ago•0 comments

LLMs are powerful, but enterprises are deterministic by nature

2•prateekdalal•29m ago•0 comments

Make your iPad 3 a touchscreen for your computer

https://github.com/lemonjesus/ipad-touch-screen
2•0y•34m ago•1 comments

Internationalization and Localization in the Age of Agents

https://myblog.ru/internationalization-and-localization-in-the-age-of-agents
1•xenator•34m ago•0 comments

Building a Custom Clawdbot Workflow to Automate Website Creation

https://seedance2api.org/
1•pekingzcc•37m ago•1 comments

Why the "Taiwan Dome" won't survive a Chinese attack

https://www.lowyinstitute.org/the-interpreter/why-taiwan-dome-won-t-survive-chinese-attack
2•ryan_j_naughton•37m ago•0 comments

Xkcd: Game AIs

https://xkcd.com/1002/
1•ravenical•39m ago•0 comments

Windows 11 is finally killing off legacy printer drivers in 2026

https://www.windowscentral.com/microsoft/windows-11/windows-11-finally-pulls-the-plug-on-legacy-p...
1•ValdikSS•39m ago•0 comments

From Offloading to Engagement (Study on Generative AI)

https://www.mdpi.com/2306-5729/10/11/172
1•boshomi•41m ago•1 comments

AI for People

https://justsitandgrin.im/posts/ai-for-people/
1•dive•42m ago•0 comments

Rome is studded with cannon balls (2022)

https://essenceofrome.com/rome-is-studded-with-cannon-balls
1•thomassmith65•47m ago•0 comments

8-piece tablebase development on Lichess (op1 partial)

https://lichess.org/@/Lichess/blog/op1-partial-8-piece-tablebase-available/1ptPBDpC
2•somethingp•49m ago•0 comments

US to bankroll far-right think tanks in Europe against digital laws

https://www.brusselstimes.com/1957195/us-to-fund-far-right-forces-in-europe-tbtb
4•saubeidl•50m ago•0 comments

Ask HN: Have AI companies replaced their own SaaS usage with agents?

1•tuxpenguine•53m ago•0 comments

pi-nes

https://twitter.com/thomasmustier/status/2018362041506132205
1•tosh•55m ago•0 comments

Show HN: Crew – Multi-agent orchestration tool for AI-assisted development

https://github.com/garnetliu/crew
1•gl2334•55m ago•0 comments

New hire fixed a problem so fast, their boss left to become a yoga instructor

https://www.theregister.com/2026/02/06/on_call/
1•Brajeshwar•57m ago•0 comments
Open in hackernews

How to trigger a command on Linux when power switches from AC to battery

https://dataswamp.org/~solene/2025-05-31-linux-killswitch-on-power-disconnect.html
81•Mr_Minderbinder•6mo ago

Comments

Apreche•6mo ago
The headline is a bit misleading. I thought it meant it was about triggering a command on a computer that has no power, which is obviously impossible.

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!

nisegami•6mo ago
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.
netsharc•6mo ago
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.

LoganDark•6mo ago
"on power disconnection" (event) probably would've worked better than "when disconnected from power" (time period).
1718627440•6mo ago
That's exactly how I understood the headline.
Rooster61•6mo ago
+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.

NooneAtAll3•6mo ago
+1?
Rooster61•6mo ago
Yes, thank you. Fatfingered
wkjagt•6mo ago
It's a way of signaling agreement.
Rooster61•6mo ago
They were correcting my initial "1+"
tenthirtyam•6mo ago
Shouldn't we programmers be just typing "++"?
yndoendo•6mo ago
i++
wildzzz•6mo ago
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.

piperswe•6mo ago
> 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

telotortium•6mo ago
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?
nemomarx•6mo ago
Yeah, it was when disconnected from power at first
mrheosuper•6mo ago
>. 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.

solene•6mo ago
Thanks for reporting, I updated the title, I hope it will be clearer for new readers.

For the APC, use nut :)

ajross•6mo ago
So for those who want the tl;dr: The answer is just "use a udev rule".

Udev is one of those classic open source tools that is immensely powerful and gracefully well designed, with all sorts of emergent power...

...that ends up being an obscure bit of graybeard prestidigitation purely because of it's awful syntax.

No really, there's a very clean mapping between the state in sysfs and the resulting uevents produced. You just can't tell because of the way it looks.

M95D•6mo ago
If you don't like udev (and I don't blame you, I hate it too), you can do the exact same thing with mdev or acpid.
ajross•6mo ago
Oh, I like udev! I'm just sad that so few people know anything about how sysfs/uevents/udev work, because it seems so ugly and arcane when you're exposed to your first udev rule.
M95D•6mo ago
> I'm just sad that so few people know anything about how sysfs/uevents/udev work

Here's the opportunity to write a blog post about it.

sigwinch•6mo ago
udev is useful for customizing all sorts of ergonomics. My example: when my keyboard/mouse switches from one machine to another, control signals are sent to each monitor. This mimics a very expensive 8k DisplayPort KVM.

So that’s an option rather than power. Devise where you’d place a YubiKey on an extension cord, with its removal triggering logout and shutdown.

Const-me•6mo ago
Interestingly, a few months ago I wanted a similar thing for Windows. Ended up developing a simple tray utility for that. Probably the most important method is the handler of WM_POWERBROADCAST message: https://github.com/Const-me/SleepOnUnplug/blob/0.4/SleepOnUn...
sgt•6mo ago
On macOS this is elegant and efficient by listening to OS level notifications into userland. Tapping into IOKit - namely IOPowerSources and IOPSNotificationCreateRunLoopSource - is trivial and will notify you when there is a power source event.

I believe Windows has something similar - also an event.

masom•6mo ago
This is pretty much what this solution does, but through udev.

Systemd, D-Bus, and udev can be used separately or together to make this easier to listen in userland, it will just be dependent on your distribution or setup.

The kernel essentially flags the power source through udev, and the rule triggers the script. That can be done programmatically instead of a script as well. libudev is there for that: https://www.freedesktop.org/software/systemd/man/latest/libu...

https://wiki.archlinux.org/title/Udev (userland /dev is what udev does)

jahrichie•6mo ago
I use an APC with a management cable, triggers graceful shutdown and startup on reconnection. It also e-mails me and stores a log. I prefer this approach so 99% of ecosystem isn't on the server, you can let your server do server things and not be the battery police.
hamandcheese•6mo ago
How does it trigger the shutdown? Does it have a power switch connection to the motherboard?
treve•6mo ago
shutdowns can be done in software like 'sudo systemctl halt', so it doesn't need a line straight to the motherboard. That's the desired path because it lets running applications gracefully close and finish writing to disk.
hamandcheese•6mo ago
Well, yes. But they liked that "99% of ecosystem isn't on the server" which makes me think it isn't a software solution. What is the 1%?
e40•6mo ago
Yep, I have used apcupsd on Linux, Windows and macOS for more than a decade. It’s been triggered many times, too!
ge96•6mo ago
I remembering profiling battery life on a chromebook that I put GalliumOS on. When it would be on timestamp, off timestmap and then it would tally up runtime in hours/minutes, nasty bash
Theodores•6mo ago
It is interesting how laptops, whether running a consumer operating system or Linux, are poorly protected from theft. There is the Kensington lock hole that nobody uses and that is about it. Really, any laptop needs to be a brick without the magic password or bio-id, if the owner has configured it to be so when stolen, as identified by a change of power source or other cause.

As it is, all you need is a screwdriver to take out the disc, put it in another box, format it and put it back. Then you have a machine good to sell on eBay.

NFC could be another way of protecting a PC so you need your phone to unlock it.

PCs used to have a low grade lock on them originally, that locked the power button and disks behind a flimsy piece of plastic. This feature was soon dropped.

Clearly the market does not demand theft proofing. Otherwise we would have a little bit more than noble efforts like this udev script.

Doohickey-d•6mo ago
M1 Macs are more theft-proof than most: it's useless if it's attached to someone else's iCloud account.

It even has parts pairing, so the e.g. the screen has some features disabled if you swap it.

jauntywundrkind•6mo ago
There's much much better Secure Boot and encrypted disk options than there used to be, which is good!!

But it does feel like the security regime is pretty lax. I feel like some BLE tracker system is a natural fit for laptops. I'd love a motion sensor alarm built in.

Framework laptop's embedded controller is open source, run Zephyr. I don't think there's a ton of peripherals it has access too, but I love the idea that one could potentially make their own firmware that has their own security designs built in.

thunderfork•6mo ago
Problem with theft-proofing is it inherently comes at the cost of both repairability and recyclability. If every part is cryptographically locked to its parent machine, you can't scrap devices for parts.

Sometimes there's "unlock before recycling" flows but generally people are pretty unlikely to know they should do that, and even less likely to remember to do it.

gorgoiler•6mo ago
Pah! Shut the system down like a real BOFH! Use the Magic SysRq Key interface to instantly crash the system:

  echo 1 > /proc/sys/kernel/sysrq
  echo o > /proc/sysrq-trigger
https://docs.redhat.com/en/documentation/red_hat_enterprise_...
47282847•6mo ago
Wouldn’t this potentially leave e.g. disk encryption keys in memory?
kees99•6mo ago
You'd probably want to do the filesystem unmount dance first:

  echo 1 > /proc/sys/kernel/sysrq
  echo u > /proc/sysrq-trigger
  dmesg --follow \
  | grep -qm1 'Emergency Remount complete'
  echo o > /proc/sysrq-trigger
...least putting a bit too much trust in ext4/btrfs/zfs journalling.
jauntywundrkind•6mo ago
That's neat, I'd never considered one could use udev reactively like this! Very nice.

Not nearly as elegant, but I keep running into problems where I want to run some command when X happens. I've been trying to lean into systemd, creating a service for whatever it is I want run (perhaps just a oneshot if it's a a one off command). Then have a separate program that detects for the desired condition (polling?) and runs systemd-notify to signal that it's healthy. Then you can just BindTo=, so that the desired command runs whenever the condition-detector thing goes green.

PeterStuer•6mo ago
I'm using NUT ( https://networkupstools.org/index.html ) to distribute the backup power events from the one usb connected system to all other machines relying on the batteries.

Works pretty well so far.