# Launch Xorg in a non-interactive console



## Emrion (Feb 27, 2020)

Hi,

I create this thread for the question I asked in this one.

I usually start X at boot time in this way:

```
#minute hour    mday    month   wday    who     command
@reboot                                 Emrion  startx
```

But since Xorg 1.20 this doesn't work anymore. It took me time to find any relevant log on my machine but, actually as *kpedersen *said, it's because now X doesn't want to be launched from a non-interactive console.

I finally found that cron tried to email me the problem and since there is no MTA configured, the log ended in my home directory in dead.letter.


> /usr/local/bin/X: Only console users are allowed to run the X server
> xinit: giving up
> xinit: unable to connect to X server: Connection refused
> xinit: server error



I well noticed that there is another means to automatically run X: make the system to autolog a user and startx at login. But I find that less simple and elegant that the cron stuff.

I searched for days a solution but didn't find anything (except one trick from linux for linux); not even the list of options of `xinit` or `startx`...

Is anyone can point me in the right direction?


----------



## aragats (Feb 27, 2020)

In Linux Xorg server honors /etc/X11/Xwrapper.config, so, the following line in that file lets it to be launched from any environment, even through SSH:
	
	



```
allowed_users = anybody
```
I'm not sure it's supported in FreeBSD ― just a thought, you can also try /usr/local/etc/X11/Xwrapper.config.


----------



## Phishfry (Feb 27, 2020)

I found wblock@  has a nice way that worked good for me when creating a OpenBox Kiosk.








						Trouble calling 'startx' in Start-Up Script
					

Hello everyone! This is my first post!  I'm trying to set-up a Thin Client that when booted will automatically log into a server for vnc. Right now, I have a bash shell script at /etc/rc.d/thinclient #!/bin/sh  echo "thinclient script starting..."  SERVER_IP="192.168.1.124"...




					forums.freebsd.org


----------



## Emrion (Feb 28, 2020)

Thanks to both of you.


aragats said:


> In Linux Xorg server honors /etc/X11/Xwrapper.config, so, the following line in that file lets it to be launched from any environment, even through SSH:
> 
> 
> 
> ...


This is the linux thing I mentionned. I didn't even try because, as far as I know (but I may be wrong), there is no X wrapper anymore in FreeBSD. See x11/wrapper.



Phishfry said:


> I found wblock@  has a nice way that worked good for me when creating a OpenBox Kiosk.
> 
> 
> 
> ...


And that is the means I was alluding to automatically run X. If I don't find another method, I'll try this.

I'd like to find an option on `startx` command line for example or something like that.


----------



## kpedersen (Feb 28, 2020)

You might also want to consider a (simple-ish) display manager like SLIM? That has auto login I believe.

I know the OpenBSD guys put an auto login facility into XDM (because they have outlawed the use of startx).
I would really love to see the upstream XDM get an auto login. I wonder how likely that would be.


----------



## Keve (Feb 28, 2020)

Depending on the particular purpose you want this non-interactive autostarting X desktop for, you may find the net/x11vnc port suitable.


----------



## Emrion (Feb 28, 2020)

kpedersen said:


> You might also want to consider a (simple-ish) display manager like SLIM? That has auto login I believe.
> 
> I know the OpenBSD guys put an auto login facility into XDM (because they have outlawed the use of startx).
> I would really love to see the upstream XDM get an auto login. I wonder how likely that would be.


Yes. I recall long time ago, I was using GhostBSD and I activated the autologin feature on the advise of people from the forum. This may be an interresting alternative even if it needs to install an additional software.

To be clear in my goal, I ain't working on this subject because I'm too lazy to type my user name and its password. The point is that I use this desktop machine to test how I'll configure my router when I'll upgrade it. It's a FreeBSD box which do have X automatically launched at startup. This box must be 100% operational in case of power outage (well, after the said power outage) and, of course, even if I'm not there to type something in.

I ever tried to use x11vnc for another purpose but I don't see the point here. Maybe I'm missing something?


----------



## Minbari (Feb 29, 2020)

Emrion you should pay more attention when peoples quotes you. I've already given you the solution. You can ignore ssh-agent if you have a desktop environment which has a service/programs autostart.


----------



## Emrion (Feb 29, 2020)

I found x11/slim very convenient with its autologin feature. So I will stick to that for the moment.


----------



## zspider (Mar 4, 2020)

So what is the solution to this situation? Before I would always go 
	
	



```
startx & exit
```
Now it actively blocks me from doing that, even if I delay the exit command. It actually creates a loophole in the security, because you can just switch to the virtual console, kill Xorg and get full control of the system, even with a lock screen up.


----------



## zspider (Mar 5, 2020)

Never mind then...

Startx seems to be on the way out. Even OpenBSD "outlawed" it.

Replaced with XDM and everything is good. Thanks to vermaden for the nice minimalist theme.


----------



## aragats (Mar 5, 2020)

zspider said:


> Startx seems to be on the way out. Even OpenBSD "outlawed" it.


Doesn't make much sense to me. I've never needed a display manager, also I have boxes, where I may need to run X just from time to time.


----------



## sprock (Apr 21, 2020)

Hello,

I just "upgraded" to xorg-server 1.20.7 on one of my boxes and am running into:


```
Only console users are allowed to run the X server
```
 when I ssh into the box and run startx.

I have tried to implement the solution from W. Block in this thread, but I'm not sure I did it correctly because it makes no difference.

I appreciate any help offered.
Thanks,
sprock


----------



## Emrion (Apr 21, 2020)

sprock said:


> when I ssh into the box and run startx.



Just because I'm curious: what's the point to start X via ssh login?
You get no graphic at the console.


----------



## sprock (Apr 21, 2020)

I ssh from box A to box B and runs startx on box B.  I have box A as a synergy server and box B as a client.  I can use one keyboard & mouse for both boxes.  Less clutter on my desk.


----------



## sprock (Apr 22, 2020)

I have now tried both slim and XDM.  For the latter I tried starting is (as per the handbook) in /etc/ttys and by using the script in /usr/local/etc/rc.d.   No matter  which display manager I use, the screen is blank.  I can see that xorg and xdm or xorg and slim are running using top.
Is there some further configuration to be done?


----------



## sprock (Apr 22, 2020)

After some more testing I discovered that I could start X-windows even from a console after the change to 1.20.7.  After some more testing I had to install x11-drivers/xf86-video-scfb to get X-windows to run.   I can now startx from the console but neither XDM nor slim will start.


----------



## aragats (Apr 22, 2020)

sprock said:


> I had to install x11-drivers/xf86-video-scfb to get X-windows to run


Well, the _scfb_ is not a solution. Instead, I believe, you should use the _vt_ option, from Xorg():
	
	



```
vtXX    XX specifies the Virtual Terminal device number which Xorg will
               use.  Without this option, Xorg will pick the first available
               Virtual Terminal that it can locate.
```
Usually it's supposed to be 9 or 10. For example, I'm able to start another instance of _X_ through _ssh_ by running:
	
	



```
% X vt10 :1
```


----------



## sprock (Apr 23, 2020)

I tried drm-kmod with  hw.syscons.disable=1 as described here: https://wiki.freebsd.org/Graphics.
That just slowly painted the console grey and I could not log in - had to crash the machine (an old iMac, booting using UEFI).  That is when I dumped drm-kmod & installed scfb.  It works, and I have now set up slim as login manager.  Unfortunately that means I need a keyboard plugged in so I can log in, just the situation I want to avoid and which was previously solved by running startx after ssh into the box.   My .xinitrc then started synergy so I could use the keyboard on the box from which I ran ssh. The 'upgraded' xorg-server has screwed that up.  I have been attempting to get synergy to start from an rc script, to no avail.

Thank you for the suggestion.  Unfortunately...

patchperthite rmason X vt10 :1 X: 
Only console users are allowed to run the X server

Drat.


----------



## Emrion (Apr 23, 2020)

sprock said:


> Unfortunately that means I need a keyboard plugged in so I can log in


No. slim has an autologin feature. See in /usr/local/etc/slim.conf, you will find `default_user` and `auto_login` variables.


----------



## sprock (Apr 24, 2020)

Indeed, that works OK.  However, I decided to use SDDM as that allows synergy to be available before login.

Thanks.


----------



## yadong (Jan 1, 2022)

aragats said:


> In Linux Xorg server honors /etc/X11/Xwrapper.config, so, the following line in that file lets it to be launched from any environment, even through SSH:
> 
> 
> 
> ...


It's work for me. Thanks.

# touch /usr/local/etc/X11/Xwrapper.config

Add this to Xwrapper.config


> allowed_users = anybody



Go back to XDM login.

The OS version is FreeBSD 13 release.

But I have a question, Why Xorg limits user to login from console?


----------

