My situation
I installed a few new unit files under $HOME/.local/share/systemd/user/
ls -1 $HOME/.local/share/systemd/user/
some.service
some.timer
some_other.service
I ran the following command to have them loaded properly: systemctl --user daemon-reload
They show up in auto completion of systemctl --user enable <tab> <tab>
. What I'm looking for is a way to later write a script with gum to show me a list of those units which are currently not enabled to enable them.
My question
Is there a better way than ls -1 $HOME/.local/share/systemd/user/
to get the list I'm looking for?
systemctl
knows about the units through auto completion, but I don't want to that deep for a seemingly rather simple question. I looked at systemctl list all possible (including disabled) services and some parts of the Systemd documentation, but I wasn't able to find what I was looking for yet. It doesn't have to be perfect, the auto complete list also has some other entries which I could filter out. That won't be a problem for me.
echo " $a"
outputs the first column (= unit file name). Ok, now I don't have to feel ashamed for usingawk {print $1}
to get what I want. The path to bash completers should be pretty much standardized in distributions which integrate Systemd. For Ubuntu it is https://packages.ubuntu.com/noble/amd64/systemd/filelist the same, for other distributions the quickest way I know of would be https://pkgs.org/search/?q=systemd&on=files and looking at the file list. :-) – LiveWireBT Jan 23 '24 at 00:39