<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, May 16, 2016 at 5:09 AM, Emanuel Berg <span dir="ltr"><<a href="mailto:embe8573@student.uu.se" target="_blank">embe8573@student.uu.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I would like to start different processes in<br>
different ttys on boot, automatically and with<br>
autologin first, and then have them run as normal<br>
programs, with the I/O intact, including quitting<br>
and get the shell - i.e., just as you would if you<br>
did it all manually. (The autologin part of the<br>
above question I solved.)<br>
<br>
Up and until today, I've done this with zsh in<br>
.zprofile, and I include it here so you'll know<br>
exactly what I ask for:<br>
<br>
# ...<br>
<br>
local tty_number=${TTY#/dev/tty}<br>
<br>
case $tty_number in<br>
    (1)       lkeys # [1]<br>
              make -C ~/.emacs.d/emacs-init<br>
              emacs ;;<br>
    (2|3)     tmux-new-session-split ;;<br>
    (5)       echo "Waiting for Internet connection..."<br>
              when-internet-set-time > /dev/null # ~/.zsh/web<br>
              tmux ;;<br>
    (6)       start-x-if-not-running & ;;<br>
esac<br>
<br>
# ...<br>
<br>
I thought it'd be a good idea to do it with systemd!<br></blockquote><div><br></div><div>~/.zprofile seems just fine for this task – it *is* the zsh "run things on login" script after all. (And since these are your personal processes, especially the X stuff, it's much better to have them running *inside* the login session along with everything else.)</div><div><br></div><div>Trying to cram these into systemd .services would only overcomplicate things.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
As a test, I tried to do it with top(1) in<br>
/dev/tty4, and I got this far<br>
<br>
    [Unit]<br>
    Description=top on tty4<br>
<br>
    [Service]<br>
    Type=simple<br>
    ExecStart=/usr/bin/top<br>
    StandardInput=tty<br>
    StandardOutput=tty<br>
    TTYPath=/dev/tty4<br>
    Restart=always<br>
<br>
    [Install]<br>
    WantedBy=getty.target<br>
<br>
This results in a running process, but it doesn't<br>
seem to be associated with /dev/tty4 and there is no<br>
I/O there but the familiar shell.<br></blockquote><div><br></div><div>I'm not sure of the exact conditions, but sometimes (depending on various [Service] settings) TTYPath= uses exclusive access mode – only one service at a time is allowed. If it didn't, then you'd have both top and getty trying to display things *at once*, and trying to read from the keyboard at once as well.</div><div><br></div><div>To make this work at all, you'd need Conflicts=getty@tty4.service and some way to start the getty@ again once your custom service has exit. Or, perhaps, Type=oneshot + Before=getty@tty4 + an infinite timeout. (Also you'd of course need User=emanuel, some PAMName=, and so on – autostarting top as root isn't the best idea.)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
PS. I would say this is a ".user" question but<br>
    I couldn't find such a group!<br></blockquote><div><br></div><div>For the time being, systemd-devel@ is multipurpose. It doesn't really receive enough traffic to warrant separation, IMHO.</div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Mantas Mikulėnas <<a href="mailto:grawity@gmail.com" target="_blank">grawity@gmail.com</a>></div></div>
</div></div>