Hacker News new | ask | show | jobs
by projektfu 3 days ago
So often the answer to "Can systemd just do that?" is "yes." But before AI, it was hard to surface the way to do it. Now I can get a lot done just by asking Claude for a few ways of doing something, and often the systemd answer is there.
2 comments

For something like this I don't think you need to know much about systemd to figure it out, without AI. I promise it is worth the effort to learn some basics of systemd units. It then becomes easy to learn things like path triggers, timers, mounts, etc because they all follow the same pattern. The annoying (and nice) thing about systemd is that these files are a bit verbose. I'd suggest just dropping a few templates in your dotfiles. I do that (I even did that with cron).

For this file, it's pretty straight forward to read. I'm telling you because I think it'll change your mind.

The file name ends in ".path"[0] (it starts with `~/.config/systemd` so it is a user process with user permissions), meaning it monitors paths. Simple!

Then what matters is what's in `[Path]`. `PathExists` is the path being monitored. `Unit` is what service runs. In this case whatever is in `~/.config/systemd/user/remove-thunderbird-dir.service` but guess what, `Unit` is completely optional here. It will default to that. You can probably guess `%h` means `$HOME`. The `[Install]` is necessary though, but that's going to be common and everywhere.

Cumbersome? Yes. Annoying? Mildly, but it's worth it and just minorly inconvenient. Difficult? No. Powerful? YES

[0] https://www.freedesktop.org/software/systemd/man/latest/syst...

I think it is because AI and systemd are colleages, growing to do anything and everything.