You are not logged in.

#1 2017-05-24 13:55:21

mashers
Member
Registered: 2017-05-24
Posts: 3

Keyboard input in systemd service

Hi all

I don't think this belongs in this forum, but I don't yet have permission to post in the system administration forum. Perhaps a mod can move this if necessary.

I have set up an emulation box which is running Arch Linux, and starts up a custom front end implemented using a bash script. The script displays images using ply-image to show the user their options, and simply uses 'read' to read inputs from the keyboard to control the interface. This was working well when the script was being run from .bash_login and autologin, but I have now moved the script to a systemd service as it boots faster. The script runs and the emulator starts, but when I quit the emulator and go back to the menu interface, none of the keyboard inputs are detected. I'm guessing this is because systemd is not connected to stdin.

Is there any way around this?

Many thanks in advance.

Offline

#2 2017-05-24 16:25:33

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Keyboard input in systemd service

Not an Installation issue, moving to Apps and DEs


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2017-05-24 17:30:02

mashers
Member
Registered: 2017-05-24
Posts: 3

Re: Keyboard input in systemd service

Thank you jasonwryan. I wasn't sure where to put it since it fitted best into the system administration form I think, so I appreciate you moving it for me. Hopefully somebody here will know the answer.

Last edited by mashers (2017-05-24 17:30:30)

Offline

#4 2017-05-25 06:29:50

mashers
Member
Registered: 2017-05-24
Posts: 3

Re: Keyboard input in systemd service

In the end I worked around this by using both systemd and .bash_login. The systemd script sets a flag (actually just by creating a file in /tmp) to state that the emulator has started, and then another one to state that it has exited. The .bash_login script enters an infinite loop checking for the presence of both files. Once the emulator has been exited and the files in /tmp created, the .bash_login script breaks out of its infinite loop and continues to display the options menu. Because the options menu is being presented by .bash_login in a normal tty (auto logged in), it is able to capture keyboard input from stdin. This isn't ideal as I would prefer for everything to be in one script, but at least it works.

Offline

Board footer

Powered by FluxBB