# Startx not coming up



## golpemortal (Jun 15, 2017)

I am running Mate Desktop with FreeBSD 11
Everything working fine before but I added this to support my Intel video /etc/rc.conf

I added it

kld_list="i915kms.ko"

worked great but startx try to start but it stops at terminal login 
slim log says 

slim: waiting for X server to begin accepting connections.
slim: pam_authentication(): authentication error

at the terminal I login as regular user  $startx worked!!!! but startx will not work at Boot.......

I try to fix the but no result but I notice if I remove kld_list="i915kms.ko" from /etc/rc.conf
startx works at boot....

any one want to help resolve this issue, may be something that I am doing wrong...

thanks in advance


----------



## aragats (Jun 15, 2017)

You have to load the Intel KMS module at boot, do not add it to /etc/rc.conf, instead add it to /boot/loader.conf:
	
	



```
i915kms_load="YES"
```


----------



## golpemortal (Jun 15, 2017)

it worked fine startx works however its not the i915kms, it seems that it did not load at boot therefore it got kick back to the default video....

added to /boot/loader.conf
i915kms_load="YES"

But I don't think it got loaded...


----------



## aragats (Jun 15, 2017)

golpemortal said:


> it seems that it did not load at boot


That's exactly what I'm telling you: stuff from /etc/rc.conf is loaded _*after*_ boot, that's why you have to put it in /boot/loader.conf.


----------



## golpemortal (Jun 15, 2017)

aragats, no it did not work.... on my first post I said if I remove i915kms it will work fine but the screen looks crappy a bit so if use i915 and add it to /etc/rc.conf as kld_list="i915kms.ko" then it work nice but startx wont load at boot if I add i915kms at /boot/loader.conf startx works but; it goes to the crappy screen so that tells me that i915kms didnt load at boot.


----------



## aragats (Jun 15, 2017)

What is your graphic card?
Is it officially supported as per https://wiki.freebsd.org/Graphics ?


----------



## golpemortal (Jun 15, 2017)

Intel card...
Remember if I startx manually it does work and mate desktop comes up "very nice" but it just wont load at boot. dont knowif the issue is slim or a authentication file.


----------



## aragats (Jun 15, 2017)

golpemortal said:


> Intel card...


Intel has so many cards, see https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units. 

`startx` performs very simple tasks: it starts the X server and runs your ~/.xinitrc. That means you have to run it as the same user. E.g. if you run it as root, it will try to run stuff from root's .xinitrc, which, most likely, does not exist.


----------



## meine (Dec 10, 2017)

I mainly work in terminal (no GUI) and added `i915kms_load="YES"` to my /boot/loader.conf. With this my Asus 1005HA netbook displays the terminal properly at 1024x600, both as root and normal user. I use FreeBSD 11.1-RELEASE #0 r321309.

Sometimes I want to use a GUI (i3 window manager) do display PDF files, pictures, etc. Without the `i915kms_load="YES"` -- if commented with '#' in /boot/loader.conf -- `startx` properly starts the i3 WM for a normal user. The default display is then at 640x480. ~/.xinitrc has a line with `exec startx /usr/local/bin/i3`

When I type `startx` when i915kms is loaded, the GUI doesn't start and I get the following output (root and normal user alike):


```
xauth:  file /home/meine/.serverauth.909 does not exist

X.Org X Server 1.18.4
Release Date: 2016-07-19
X Protocol Version 11, Revision 0
Build Operating System: FreeBSD 11.0-RELEASE-p13 i386
Current Operating System: FreeBSD bunnyhop 11.1-RELEASE FreeBSD 11.1-RELEASE #0 r321309: Fri Jul 21 04:10:47 UTC 2017     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC i386
Build Date: 19 October 2017  09:00:26AM
Current version of pixman: 0.34.0
   Before reporting problems, check http://wiki.x.org
   to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
   (++) from command line, (!!) notice, (II) informational,
   (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Sun Dec 10 12:36:26 2017
(==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"
Require OpenGL version 2.1 or later.
(EE)
Fatal server error:
(EE) AddScreen/ScreenInit failed for driver 0
(EE)
(EE)
Please consult the The X.Org Foundation support
    at http://wiki.x.org
 for help.
(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
(EE)
(EE) Server terminated with error (1). Closing log file.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
```

I tried installing `# pkg install xorg` instead of xorg-minimal, but there is no difference.

`tail -40 /var/log/Xorg.0.log` gives about the same output:


```
[   116.808] (II) modeset(0): Modeline "800x600"x120.0   81.00  800 832 928 1080  600 600 602 625 doublescan +hsync +vsync (75.0 kHz d)
[   116.808] (II) modeset(0): Modeline "800x600"x60.3   40.00  800 840 968 1056  600 601 605 628 +hsync +vsync (37.9 kHz d)
[   116.808] (II) modeset(0): Modeline "800x600"x56.2   36.00  800 824 896 1024  600 601 603 625 +hsync +vsync (35.2 kHz d)
[   116.808] (II) modeset(0): Modeline "700x525"x120.0   61.00  700 744 820 940  525 526 532 541 doublescan +hsync +vsync (64.9 kHz d)
[   116.808] (II) modeset(0): Modeline "640x512"x120.0   54.00  640 664 720 844  512 512 514 533 doublescan +hsync +vsync (64.0 kHz d)
[   116.808] (II) modeset(0): Modeline "640x480"x120.0   54.00  640 688 744 900  480 480 482 500 doublescan +hsync +vsync (60.0 kHz d)
[   116.808] (II) modeset(0): Modeline "640x480"x59.9   25.18  640 656 752 800  480 490 492 525 -hsync -vsync (31.5 kHz d)
[   116.808] (II) modeset(0): Modeline "512x384"x120.0   32.50  512 524 592 672  384 385 388 403 doublescan -hsync -vsync (48.4 kHz d)
[   116.808] (II) modeset(0): Modeline "400x300"x120.6   20.00  400 420 484 528  300 300 302 314 doublescan +hsync +vsync (37.9 kHz d)
[   116.808] (II) modeset(0): Modeline "400x300"x112.7   18.00  400 412 448 512  300 300 301 312 doublescan +hsync +vsync (35.2 kHz d)
[   116.808] (II) modeset(0): Modeline "320x240"x120.1   12.59  320 328 376 400  240 245 246 262 doublescan -hsync -vsync (31.5 kHz d)
[   116.824] (II) modeset(0): EDID for output VGA-1
[   116.824] (II) modeset(0): Output LVDS-1 connected
[   116.824] (II) modeset(0): Output VGA-1 disconnected
[   116.824] (II) modeset(0): Using exact sizes for initial modes
[   116.824] (II) modeset(0): Output LVDS-1 using initial mode 1024x600 +0+0
[   116.824] (II) modeset(0): Using default gamma of (1.0, 1.0, 1.0) unless otherwise stated.
[   116.824] (==) modeset(0): DPI set to (96, 96)
[   116.824] (II) Loading sub module "fb"
[   116.825] (II) LoadModule: "fb"
[   116.825] (II) Loading /usr/local/lib/xorg/modules/libfb.so
[   116.849] (II) Module fb: vendor="X.Org Foundation"
[   116.849]    compiled for 1.18.4, module version = 1.0.0
[   116.849]    ABI class: X.Org ANSI C Emulation, version 0.4
[   116.849] (II) UnloadModule: "vesa"
[   116.849] (II) Unloading vesa
[   116.849] (==) Depth 24 pixmap format is 32 bpp
[   116.857] Require OpenGL version 2.1 or later.
[   116.857] (EE) modeset(0): Failed to initialize glamor at ScreenInit() time.
[   116.857] (EE)
Fatal server error:
[   116.857] (EE) AddScreen/ScreenInit failed for driver 0
[   116.857] (EE)
[   116.857] (EE)
Please consult the The X.Org Foundation support
    at http://wiki.x.org
 for help.
[   116.857] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[   116.857] (EE)
[   116.867] (EE) Server terminated with error (1). Closing log file.
```

I'm confused by the output. /usr/local/etc/X11/xorg.conf.d only holds a keyboard-us-intl.conf, but no display configuration. I searched pkg for 'OpenGL' but am stuck there -- too many choices...

Hopefully someone found out before and tells me the trick to be done!

TIA


----------



## Minbari (Dec 10, 2017)

meine said:


> I mainly work in terminal (no GUI) and added `i915kms_load="YES"` to my /boot/loader.conf. With this my Asus 1005HA netbook displays the terminal properly at 1024x600, both as root and normal user. I use FreeBSD 11.1-RELEASE #0 r321309.
> 
> Sometimes I want to use a GUI (i3 window manager) do display PDF files, pictures, etc. Without the `i915kms_load="YES"` -- if commented with '#' in /boot/loader.conf -- `startx` properly starts the i3 WM for a normal user. The default display is then at 640x480. ~/.xinitrc has a line with `exec startx /usr/local/bin/i3`



What type of cpu you have?! Till gen3 all works well after that the video drives are kinda tricky.


----------



## chrbr (Dec 10, 2017)

meine said:


> ~/.xinitrc has a line with  exec startx /usr/local/bin/i3


May be it should be `exec /usr/local/bin/i3` instead, without the startx in between.


----------



## meine (Dec 10, 2017)

chrbr said:


> May be it should be `exec /usr/local/bin/i3` instead, without the startx in between.



Originally it was, but it made no difference.


----------



## Minbari (Dec 10, 2017)

chrbr said:


> May be it should be `exec /usr/local/bin/i3` instead, without the startx in between.


 It should be just exec i3 in .xinitrc.

Here is my .xinitrc:


```
#!/bin/sh
#         __         __ __            
# .--.--.|__|.-----.|__|  |_.----.----.
# |_   _||  ||     ||  |   _|   _|  __|
# |__.__||__||__|__||__|____|__| |____|
#                                     
# xinitrc (FreeBSD 11.1, Thinkpad T430, Hostname: amy_bsd)

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/local/etc/X11/xinit/.Xresources
sysmodmap=/usr/local/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then
    xrdb -merge "$userresources"
fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /usr/local/etc/X11/xinit/xinitrc.d ] ; then
    for f in /usr/local/etc/X11/xinit/xinitrc.d/?*.sh ; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

# keybinds of choice
pkill -x xbindkeys
killall -9 xbindkeys
xbindkeys -f $HOME/.xbindkeysrc -n &

# user preference utility for X
xset +fp $HOME/.fonts/

# Display resolution & Display Power Management
xrandr -s 1600x900
xscreensaver -no-splash &
redshift &
#xset -dpms; xset s off  # turn on/off display power

# Keyboard layout for the current X session
setxkbmap ro

# Locale language for Xorg
LANG="ro_RO.UTF-8"; export LANG
LC_ALL="ro_RO.UTF-8"; export LC_ALL
MM_CHARSET="ro_RO.UTF-8"; export MM_CHARSET


exec i3
```


----------



## meine (Dec 10, 2017)

Minbari said:


> What type of cpu you have?! Till gen3 all works well after that the video drives are kinda tricky.



Following the tech site my Asus Eee PC 1005HA has an Intel Atom N280, 1,66GHz, motherboard Intel 945GSE. Video chip is an Intel GMA 950, max resolution 1024x600.


----------



## chrbr (Dec 10, 2017)

Minbari said:


> It should be just exec i3 in .xinitrc.


I have just tried it. It works with the full path to the executable. But you are right, I have had just the name without path in my .xinitrc, too.


meine said:


> Originally it was, but it made no difference.


Ok, then I have only one idea. Please try `exec twm` instead of `exec i3`. It should not help because X does not start, but who knows? I am running out of ideas...


----------



## Minbari (Dec 10, 2017)

Did you install *xf86-video-intel* driver?! After that  add xrandr -s 1024x600 in .xinitrc.


----------



## thebardian (Dec 10, 2017)

```
Video driver loaded at boot time
If you want to automatically load a video driver at boot time, we recommend to do it from /etc/rc.conf:

kld_list="radeonkms"
Loading the driver from /boot/loader.conf is not recommended and may not even work. Loading i915kms like this is known to cause a hang early in boot with a black screen.
```
It should not be necessary to load a video driver at boot time unless you spend a lot of time in the console, but it sounds to me you just want to go straight to slim/mate anyways. Now about this one line to load the KMS driver at boot, as you see quoted above, it is recommended to use /etc/rc.conf. But if you do need to load
a driver at boot time, this should be the way to do it for intel using /etc/rc.conf

```
kld_list="i915kms"
```
Keep in mind that setting this has absolutely nothing to do with your xorg/mate desktop experience. It helps to know the intel drivers have 3 parts,
-Kernel Modesetting Driver, included with the kernel. (Typically only used to give better experience on TTY console, but some people find the driver more stable and use it for Xorg, too, instead of xf86-video-intel)
-xf86-video-intel driver (install with pkg, the infamous driver from intel.)
-mesa-dri (dependency should be pulled in already, this is needed for graphic acceleration stuff)

More importantly, Install the xf86-video-intel driver and it should all "just work!"

If you want to experiment between drivers and configuration options, you can try setting xf86-video-intel specific options, or even uninstalling xf86-video-intel entirely and instructing xorg to fallback on using the KMS driver. Try both the KMS or the xf86-video-intel driver and see which works best for you by creating the following file:
/etc/X11/xorg.conf.d/20-intel.conf

for xf86-video-intel,

```
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "AccelMethod" "SNA"
Option "TearFree" "true"
EndSection
```
Note the "TearFree" option, I have had really great luck with this! A lot of people do not know about it. Using this option, I do not even need a compositor like compton.

for kernel modesetting,

```
Section "Module"
Load "modesetting"
EndSection

Section "Device"
Identifier "Intel Graphics"
Driver "modesetting"
EndSection
```
Note: Some users who have newer hardware are required to do something similar, by installing the drm-next-kmod package and enabling its' modules within 12.0-CURRENT to gain support for the newer hardware. It seems the future of intel graphics is moving toward the modesetting driver, apparently it is a more maintainable and stable codebase.

Regarding setting multi-display and resolution, I like the little app "lxrandr". It only creates a .desktop file in ~/.config/autostart, however, and the trouble is many window managers do not load it. I just put in my .xinitrc a line to grep and cut the xrandr command from the lxrandr generated file, problem solved:


```
# use lxrandr generated display settings
$(cat $HOME/.config/autostart/lxrandr-autostart.desktop \
| grep Exec \
| cut -d "'" -f 2)
```
Finally, regarding the xorg-minimal meta pkg. Installing xorg-minimal will give you the minimal pkgs you need for working Xorg server / desktop experience... Or just install each one manually, makes no difference:

Xorg : x11-servers/xorg-server
mouse_drv.so : x11-drivers/xf86-input-mouse
kbd_drv.so : x11-drivers/xf86-input-keyboard
xinit : x11/xinit
xauth : x11/xauth
vesa_drv.so : x11-drivers/xf86-video-vesa
Note the last one, the vesa generic driver. It may be uninstalled if you are using a specific, eg. more performant driver! Or you can keep it handy, as a backup, I guess. The tricky part is, if for whatever reason your intel driver gets uninstalled/borked, xorg will just automatically fall back to a lesser driver, and not even let you know about it. Performance loss may be felt, however. I see this often with people complaining about video performance, and don't even realize they are using the "wrong" or generic driver.


----------



## meine (Dec 10, 2017)

Minbari said:


> It should be just exec i3 in .xinitrc.



Tried, didn't work.


----------



## meine (Dec 10, 2017)

Minbari said:


> Did you install *xf86-video-intel* driver?! After that  add xrandr -s 1024x600 in .xinitrc.



TNX, you won the contest  The instructions you gave made me launch i3 successfully with just typing `startx` at the user prompt!


----------



## Márcio Rezende (Sep 13, 2018)

meine said:


> TNX, you won the contest  The instructions you gave made me launch i3 successfully with just typing `startx` at the user prompt!



Exactly same happened to me. First I've configured i915, testing with (as seen here)


```
kldload i915kms
hw.vga.textmode=1
```
and after test, configure that parameter in `/boot/loader.conf`

So I installed twm and ... boom ... Neither X nor twm. Following Minbari's instructions, it worked. It looks like the trick lies in the xf86-video-intel driver installed.
and after testing I configured this parameter in /boot/loader.conf

I'm testing with an old netbook (acer aspire one ZG5) and in the past I used to have same problem when installing linux on my old asus (same maine model). After all netbook with these chipsets usually stuck initially, but seems to work well after some tweaks.


----------

