Linux, starting services which require xorg

my project as posted here (mserv)

requires x as it runs vlc, for people not familiar with xorg, it doesnt start itself, nor do you just give it an argument and then it will run that program using it etc.

basically your display manager usually is what handles starting it in modern setups, or you use xinit/startx to run the supplied xinitrc/xorg config to figure out what window manager your running, and start that after x has started, then if you close the window manager x will close itself.

basically was looking up as easily to implement as possible(to make it easier to install my project for other people as is usually desired by most people that create packages).

what i found was

use systemd/init to autologin a user and startx using something like

su username -l -c /usr/bin/startx

as the command and have a user for this specific purpose with a local .xinitrc to start my program(have the .xinitrc where it works and starts it up properly)

but the issue trying this was.. it seems to give unexpected results (Atleast to me). where from doing a systemd status mserv.service(the file unit file i made) it shows that it had executed the result and had switched users from root to mserv, but.. the startx starts with

'$[HOME]'

including the single quotes as the home directory and uses the system xinitrc

so not really sure there lol.. tried doing some other stuff like make a script which did the su command, and then presumably would have been continuing the script as mserv, cd into /home/mserv then do start x etc, but similar result ensued.

probably will try messing with it a bit more just to cover my bases before abandoning this approach,

but
also found another approach which seems not worth it in the long run, as involved a modified loginshell, modifying a bashrc for this user, the xinitrc, and then use getty from systemd/init to use the modified loginshell

issue with this is.. if i do nothing other than provide a xinitrc its probably less time consuming to just login and hit startx even over the life span of the server as its a server, they could deploy it no internet access and do update/upgrade 1-2x a year if they even wanted to at all other than if power failed

which will be like 5-10seconds to login and hit startx versus 5+ minutes of reading my horribly written directions/manual on how to get this shit to work.

tldr:
anybody got any other ideas that would be easy to setup, to start x and then this service not as root. before i start digging more

figured would ask since.. kind of an interesting use/edge case

Edit .xinitrc and add

exec vlc

This will cause vlc to start when startx is run

lol

i already have this done :p.(as in the summary)

i mean to have the computer automatically start the service on poweron

to do the login/do the startx to run my program 'the service'

i.e. if the systemd unit does

ExecStart=/home/mserv/mserv

then it spawns vlc but xorg isnt running so all you get is the commandline version where you get audio and thats it

startx starts the xorg you could get it to start a boot up using a cron job or use a start up script

well issue using startx was autologin issues/executing startx as the specific user account

but did get it to work and then had a systemd issue/bug maybe,
where the ExecStop didnt execute when i tried using systemctl to tell it to stop

but the syntax from what seen online is just exactly the same as ExecStart so.. dunno lol.

seems fiddly
@SEP

1 Like

Is it just me or does systemd never seem to do what it's supposed to?

idk XD.

it just waited forever then did sigkill(prolly) and then it freaked out agetty which went 100% load on that core

1 Like

haha yep, that sounds like a critical error

and then the logging was being weird was printing to if i did 'systemctl status mserv' instead of to the tty it logged into/ran it on

#sojank
1 Like


down the rabbit hole we go!

< probs just leave it be for now XD.

wanted it to not be specific to systemd anyways just thats what has currently/is one of the main options.

not really that big of deal depending on implementation, since could be on a pfsense box or some shit where you wouldnt have to start it that often

1 Like

eh, i say build a hole distro for it, save yourself the hastle.
everybodies doing it
obvious sarcasm is obvious

i should >.>

probs wouldnt even be hard if i would bother to lookup a thing lol.

1 Like

what is this, looking up thing you speak of
never heard of it

lol was < wasnt sure my options for repacking a squashfs :p. could just rip open a gentoo/arch whatever live disk, throw x11 vlc and my shit on there

1 Like

Haha
I just read a wonderful superuser thread :3

ye saw before is basically dont linux isnt ready yet :p

1 Like

I say, fight the system.

It should be possible lel

I have yet to try it, still swamped with school work and other things

not that I would know or be helpful on fixing problems lol

Glad you are still working on it! Forum is better with threads and projects like this!

well had it where it was working but that shutdown thing is like.. seems like is systemd is fucked or somethin lol

maybe if set it to kill the user or some shit(assuming it would even run the stop commands lol..)
would prevent the agetty freakout

but then what if they dont have agetty then have to figure out the command for the version they have, or if they dont have systemd to do a init script or whatever,

like have to make a seperate thing for each possible combination

1 Like