r/NixOS•
futureZenik

startx no keyboard or mouse (exwm)

I know using startx is taboo with nixos. Basically I'm running exwm, and I have to pass some special configuration lines to get Java apps working. The only way I've ever got this working is with using startx.

If I do startx, I get no keyboard and mouse as root or as user. I also tried chmod 777'ing stuff in /dev/input, but to no avail. How can I get startx keyboard + mouse input working?

Here's my working (but w\o user input).xinitrc below...

# Disable access control for the current user.

xhost +SI:localuser:$USER

# Make Java applications aware this is a non-reparenting window manager.

wmname LG3D

export _JAVA_AWT_WM_NONREPARENTING=1

# Set default cursor.

xsetroot -cursor_name left_ptr

# Set keyboard repeat rate.

xset r rate 200 60

# Finally start Emacs

exec emacs

Relevant installed packages include:

xorg.xf86inputkeyboard xorg.xf86inputlibinput xorg.xf86inputmouse xorg.xf86inputevdev xorg.xhost wmname

I've tried to do things the nixos way by running the above commands , but for some reason these commands only work when executed through the .xinitrc and startx.

# services.xserver = {

# enable = true;

# layout = "us";

# xkbVariant = "dvp";

# libinput = {

# enable = true;

# };

# desktopManager = {

# default = "emacs";

# session = [ {

# manage = "desktop";

# name = "emacs";

# start = ''

# xhost +SI:localuser:$USER &

# wmname LG3D &

# export _JAVA_AWT_WM_NONREPARENTING=1 &

# xsetroot -cursor_name left_ptr &

# xset r rate 200 60 &

# ${pkgs.emacs}/bin/emacs &

# waitPID=$!

# '';

# } ];

# };

# };

Posted Jan 19, 2020, 5:06 AM UTC

23
futureZenikOP•

Update 2:

I finally got startx working. I referenced this link https://nixos.wiki/wiki/Using_X_without_a_Display_Manager

I changed to my X setup to:

services.xserver = { enable = true; layout = "us"; xkbVariant = "dvp"; libinput = { enable = true; }; displayManager = { startx.enable = true; }; };

I believe you need to specifically enable startx in the config, otherwise it won't work.

I also prepended my .xinitrc with:

if test -z "$DBUS_SESSION_BUS_ADDRESS"; then eval $(dbus-launch --exit-with-session --sh-syntax) fi systemctl --user import-environment DISPLAY XAUTHORITY

if command -v dbus-update-activation-environment >/dev/null 2>&1; then dbus-update-activation-environment DISPLAY XAUTHORITY fi

Regardless, everything is fully functional now.

2
futureZenikOP•

I found a temporary solution so I can at least live my life and be productive...

I boot xfce (using its xfce4wm), launch (pre-load) the java apps that I need, load emacs, click 'yes' to replace wm (run exwm). After that, I'm running exwm, albeit with the xfce panel always showing taking up some space. Existing Java apps works that I 'preloaded', however launching new one is still broken I.E. you can only preload. At least its mostly functional for what I need.

If I have to reboot, I will have to run 'xfwm4 --replace' to reset xfce4, then run the above again. You bet your ass I'm not rebooting anytime soon (and not closing these Java apps).

Update: nevermind, this got broken somehow. I'm stuck in default xfce4 for now.

1
kyber70•

Just to say, I appreciate you documenting the issues and work here. I probably need to do the same thing soon - and have a similarly complicated xinitrc file - eg. my Java ide requires wmname LG3D to be set etc. So I am likely to revisit this in future.

1