Tool to automatically start dinit for each new logged in user 12 August 2025, 11:13:30 Good Afternoon,I have developed a tool, dinit-user-spawn, https://github.com/initMayday/dinit-user-spawn, of which automatically starts a dinit process for each user that has logged in, allowing each user to have their own user services with ease. Recently, I released the first master (ie. stable) release, and hence I believe this build is fine for others to use (a few others have tested the development branch before its promotion to master/stable, but of course more testing from others would be appreciated). The way the program works is quite simple and comes in at around 500 lines of c++ code and hence should be readable by most who understand c++. How it precisely works is also explained in the README.The master release is on the AUR, for those who wish to try: https://aur.archlinux.org/packages/dinit-user-spawn-master-gitIf also possible, i think it would make a good addition to the wiki for the dinit installation. The main reason i created this over turnstile is that it is more adjacent in functionality to turnstile's original goal where it was initially known dinit-userservd, and before it expanded its scope to become a logind replacement, of which it has not yet accomplished. With the last update to it being 7 months ago and with only relatively minor commits in the months leading upto the last commit (considering that its goal has not yet been reached), I thought a project with more limited scope of which is much more easily achievable (which it has done) was warranted for purely spawning dinit as a user process for each user.Thank you. Quote Selected 4 Likes
Re: Tool to automatically start dinit for each new logged in user Reply #1 – 12 August 2025, 18:57:39 I was running turnstile (just to try it out as i run most of my services etc system wide) and it was OK, or at least seemed to be. However, saw this and thought i'd at least try it out, especially as it seems simpler (that's my assumption) than turnstiled. So, disabled all the turnstiled stuff, installed this and enabled and yeah, seems to be running and doing exactly what it was designed to do.... Nice one. As soon as i find something that i can run as a user service i'll try it out properly. Many thanks and kudos to you for making it happen. Dinit is a such a great init system, i'm hoping that more people will see that and start using it. Quote Selected 3 Likes
Re: Tool to automatically start dinit for each new logged in user Reply #2 – 12 August 2025, 19:24:02 I will package this for the world repo. Quote Selected 2 Likes
Re: Tool to automatically start dinit for each new logged in user Reply #3 – 12 August 2025, 21:32:32 @initMayday Could you please make a git tag for the upcoming package? Quote Selected 1 Likes
Re: Tool to automatically start dinit for each new logged in user Reply #4 – 12 August 2025, 23:00:20 Good evening,Zendjinn: glad you have found the program useful, and yes it is much simpler than turnstile, as much more akin to turnstile's original goal and name of dinit-userservd, before it expanded to attempt to replace all of logind. The scope is much more limited to what it says on the tin.artoo: Sure thing, I believe I have done so just now (https://github.com/initMayday/dinit-user-spawn/releases/tag/v1.0.0), however, let me know if anything further needs to be done. Just to note, the master branch is always stable (work is only done on the dev branch before eventual promotion to master)Thank you. Quote Selected 2 Likes
Re: Tool to automatically start dinit for each new logged in user Reply #5 – 12 August 2025, 23:51:50 Quote from: initMayday – on 12 August 2025, 23:00:20artoo: Sure thing, I believe I have done so just now (https://github.com/initMayday/dinit-user-spawn/releases/tag/v1.0.0), however, let me know if anything further needs to be done. Just to note, the master branch is always stable (work is only done on the dev branch before eventual promotion to master)It is more for packaging purposes/rules to pull a tag.Your neat tool is precisely the kind of "trickery" dinit needed to match a current openrc. https://gitea.artixlinux.org/packages/dinit-user-spawnMaybe integrate the service install as meson option?That is the only slight improvement I see from deployment side. Next I will test it. Quote Selected Last Edit: 13 August 2025, 01:25:53 by artoo 3 Likes
Re: Tool to automatically start dinit for each new logged in user Reply #6 – 13 August 2025, 01:46:15 I think it is better to have the service within the PKGBUILD, although that should probably be split off into a separate package called dinit-user-spawn-dinit, as nothing inherently ties this program to having dinit as the main init system. Technically it would work just fine to start dinit for each user no matter the root init system (i can't imagine people doing this though). Perhaps other distros may also have different preferred locations for the dinit service directory, so it is just a bit more modular incase other distros want to package it.(Incase you haven't seen it, the PKGBUILD builder is found at: https://github.com/initMayday/dinit-user-spawn/blob/dev/packages/make-packages.sh, and uses https://github.com/initMayday/dinit-user-spawn/blob/dev/packages/template/PKGBUILD, may be useful for your own) Quote Selected 1 Likes
Re: Tool to automatically start dinit for each new logged in user Reply #7 – 15 August 2025, 16:24:01 I integrated dinit-user-spawn via alpm hooks in current gremlins dinit packages.Plesae test.The dinit-user-spawn service is enabled on install by alpm hook. Quote Selected 2 Likes
Re: Tool to automatically start dinit for each new logged in user Reply #8 – 15 August 2025, 23:46:03 1. It doesn't work with startx in .bash_profile2. Why make such stuff as hard dependency? UPD:It actually works with auto startx but it takes 2 minutes to start the service. Quote Selected
Re: Tool to automatically start dinit for each new logged in user Reply #9 – 16 August 2025, 13:11:12 Quote from: darcy – on 15 August 2025, 23:46:031. It doesn't work with startx in .bash_profile2. Why make such stuff as hard dependency? UPD:It actually works with auto startx but it takes 2 minutes to start the service.I don't see why you'd even want to start this alongside X11 (or even within your shell) and not simply via a system service such as the one provided under Dinit. I have a good few user services myself at the moment that are independent of a display server (e.g. dbus, pipewire), and I personally always thought it'd be a better idea to start those immediately upon login. I could be wrong, though. Quote Selected
Re: Tool to automatically start dinit for each new logged in user Reply #10 – 16 August 2025, 13:50:29 Quote from: darcy – on 15 August 2025, 23:46:031. It doesn't work with startx in .bash_profile2. Why make such stuff as hard dependency? UPD:It actually works with auto startx but it takes 2 minutes to start the service.If you don't want the hook to be used you can create a symlink, with the same name, to /dev/null in /etc/pacman.d/hooks Quote Selected
Re: Tool to automatically start dinit for each new logged in user Reply #11 – 16 August 2025, 14:16:41 Quote from: 90 – on 16 August 2025, 13:11:12I don't see why you'd even want to start this alongside X11 (or even within your shell) and not simply via a system service such as the one provided under Dinit. I have a good few user services myself at the moment that are independent of a display server (e.g. dbus, pipewire), and I personally always thought it'd be a better idea to start those immediately upon login. I could be wrong, though.I do start it as system service (sudo dinitctl enable blahblahblah), but for whatever reason it has issues when .bash_profile contains startx.https://wiki.archlinux.org/title/Xinit#Autostart_X_at_loginQuote from: gripped – on 16 August 2025, 13:50:29If you don't want the hook to be used you can create a symlink, with the same name, to /dev/null in /etc/pacman.d/hooksNo problems with hook, but the util itself isn't working properly, whick is a pity. Quote Selected
Re: Tool to automatically start dinit for each new logged in user Reply #12 – 17 August 2025, 22:31:42 It is likely because of environment variables, when you start dinit as your user manually it inherits your env vars, including everything set at runtime. dinit-user-spawn is unable to do as such (since it doesn't inherit from your shell), and can only get env vars as far as su - yourusername -c "env" can give it, which is usually a subset (although if you know what the env var should be if you set it such that env logs it, it'll inherit from that, Note if anyone does have an idea of how to easily get the full set of env vars as from the shell, feel free to contribute such). Beyond this for dinit services, you can provide your service an environment file (see docs: https://davmac.org/projects/dinit/man-pages-html/dinit-service.5.html#env), which seems to be the more official way of doing things.Ultimately, the easiest way of gaining full control is to simply launch dinit from your bashrc or other equivalent.If it is not env vars, then dinit-user-spawn quite literally only starts the dinit process for each user that logs in (and cleans it up), so if the dinit process itself is running, then it has completed its task.Although, nothing should really have a hard dependency on dinit-user-spawn, as the manual method of launching it yourself offers you more control (and works perfectly fine), albeit at a bit less convenience. Quote Selected Last Edit: 17 August 2025, 22:37:32 by initMayday
Re: Tool to automatically start dinit for each new logged in user Reply #13 – 17 August 2025, 23:05:44 Quote from: initMayday – on 17 August 2025, 22:31:42It is likely because of environment variables, when you start dinit as your user manually it inherits your env vars, including everything set at runtime. dinit-user-spawn is unable to do as such (since it doesn't inherit from your shell), and can only get env vars as far as su - yourusername -c "env" can give it, which is usually a subset (although if you know what the env var should be if you set it such that env logs it, it'll inherit from that, Note if anyone does have an idea of how to easily get the full set of env vars as from the shell, feel free to contribute such).Yes, this is it.Quote from: initMayday – on 17 August 2025, 22:31:42Ultimately, the easiest way of gaining full control is to simply launch dinit from your bashrc or other equivalent.That's how I do it. I launch user instance of dinit from .bash_profile:Code: [Select]pgrep -u "$USER" -x "dinit -q" > /dev/null || { dinit -q & }trap "dinitctl shutdown" EXITBut I like the idea of dinit-user-spawn. Quote Selected Last Edit: 17 August 2025, 23:20:36 by darcy 1 Likes
Re: Tool to automatically start dinit for each new logged in user Reply #14 – 17 August 2025, 23:25:16 Yeah dinit-user-spawn seems a bit more "pure" but i think the ultimate solution is to just strip down the program (or even create a new bash script, which would be very minimal even compared to dinit-user-spawn) such that it autocreates your ~/dinit.d and such, and appends (with confirmation) to your bashrc or such the command to launch dinit. This of course is slightly manual, but not to much of a great degree since the script automates it and just prompts you to accept, and of course you'd have to live with your bashrc or equivalent having a command to launch dinit, but this mitigates all issues associated with environment variables in a very understandable manner with no 'hacks', and I personally would see it as a successor to dinit-user-spawn as it is more powerful since you have direct control over the dinit launch (although it is less 'clean').Ultimately davmac should ideally add proper user service support to dinit, although i don't see this happening as it is said to not suggest features unless you will add them on his github, indicating to me that the project is more in maintenance mode (especially with what i perceive as burnout in his older blogs). Hence I don't think it is for the best that dinit-user-spawn is made a hard dependency on other stuff, as it locks people out of the, what I perceive to be, superior bash launch method (which comes at the cost of a bit of convenience). Quote Selected 1 Likes