Re: [systemd-devel] autostart processes based on tty

2016-05-21 Thread Jonathan de Boyne Pollard

I would like to start different processes in different ttys on boot,


What you need is a Q&A WWW site.  (-:

* http://unix.stackexchange.com/questions/211544/
* http://askubuntu.com/questions/770673/
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] autostart processes based on tty

2016-05-16 Thread Emanuel Berg
Mantas Mikulėnas  writes:

> ~/.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.)

OK, so you should not run user processes with
systemd? Now I understand why there is no
user ML... :)

But what do you mean "your personal processes,
especially the X stuff"? How does it differ from the
tmux and Emacs stuff?

Actually I thought people generally didn't launch
X manually - which is what I do, only I have that
automatized...

-- 
underground experts united  http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic . http://user.it.uu.se/~embe8573/blogomatic
   - so far: 30 Blogomatic articles -   

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] autostart processes based on tty

2016-05-15 Thread Mantas Mikulėnas
On Mon, May 16, 2016 at 5:09 AM, Emanuel Berg 
wrote:

> I would like to start different processes in
> different ttys on boot, automatically and with
> autologin first, and then have them run as normal
> programs, with the I/O intact, including quitting
> and get the shell - i.e., just as you would if you
> did it all manually. (The autologin part of the
> above question I solved.)
>
> Up and until today, I've done this with zsh in
> .zprofile, and I include it here so you'll know
> exactly what I ask for:
>
> # ...
>
> local tty_number=${TTY#/dev/tty}
>
> case $tty_number in
> (1)   lkeys # [1]
>   make -C ~/.emacs.d/emacs-init
>   emacs ;;
> (2|3) tmux-new-session-split ;;
> (5)   echo "Waiting for Internet connection..."
>   when-internet-set-time > /dev/null # ~/.zsh/web
>   tmux ;;
> (6)   start-x-if-not-running & ;;
> esac
>
> # ...
>
> I thought it'd be a good idea to do it with systemd!
>

~/.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.)

Trying to cram these into systemd .services would only overcomplicate
things.


>
> As a test, I tried to do it with top(1) in
> /dev/tty4, and I got this far
>
> [Unit]
> Description=top on tty4
>
> [Service]
> Type=simple
> ExecStart=/usr/bin/top
> StandardInput=tty
> StandardOutput=tty
> TTYPath=/dev/tty4
> Restart=always
>
> [Install]
> WantedBy=getty.target
>
> This results in a running process, but it doesn't
> seem to be associated with /dev/tty4 and there is no
> I/O there but the familiar shell.
>

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.

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.)


> PS. I would say this is a ".user" question but
> I couldn't find such a group!
>

For the time being, systemd-devel@ is multipurpose. It doesn't really
receive enough traffic to warrant separation, IMHO.

-- 
Mantas Mikulėnas 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] autostart processes based on tty

2016-05-15 Thread Emanuel Berg
I would like to start different processes in
different ttys on boot, automatically and with
autologin first, and then have them run as normal
programs, with the I/O intact, including quitting
and get the shell - i.e., just as you would if you
did it all manually. (The autologin part of the
above question I solved.)

Up and until today, I've done this with zsh in
.zprofile, and I include it here so you'll know
exactly what I ask for:

# ...

local tty_number=${TTY#/dev/tty}

case $tty_number in
(1)   lkeys # [1]
  make -C ~/.emacs.d/emacs-init
  emacs ;;
(2|3) tmux-new-session-split ;;
(5)   echo "Waiting for Internet connection..."
  when-internet-set-time > /dev/null # ~/.zsh/web
  tmux ;;
(6)   start-x-if-not-running & ;;
esac

# ...

I thought it'd be a good idea to do it with systemd!

As a test, I tried to do it with top(1) in
/dev/tty4, and I got this far

[Unit]
Description=top on tty4

[Service]
Type=simple
ExecStart=/usr/bin/top
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty4
Restart=always

[Install]
WantedBy=getty.target

This results in a running process, but it doesn't
seem to be associated with /dev/tty4 and there is no
I/O there but the familiar shell.

PS. I would say this is a ".user" question but
I couldn't find such a group!

-- 
underground experts united  http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic . http://user.it.uu.se/~embe8573/blogomatic
   - so far: 30 Blogomatic articles -   

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel