SDL 不适用于非特权 X11 服务器

SDL 不适用于非特权 X11 服务器

我在非 root 用户下将 X 服务器作为 systemd 服务启动

    systemd.services."autovt@tty1".enable = lib.mkForce false;
    systemd.services = {
      startx = {
        enable = true;
        restartIfChanged = true;
        description = "startx";
        wantedBy = [ "multi-user.target" ];
        serviceConfig = {
          User = config.primaryUser.name;
          WorkingDirectory = "~";
          PAMName = "login";
          TTYPath = "/dev/tty1";
          UtmpIdentifier = "tty1";
          UtmpMode = "user";
          UnsetEnvirnment = "TERM";
          ExecStart = "${pkgs.xorg.xinit}/bin/startx -- -keeptty -verbose 3 -depth 16";
          StandardInput = "tty";
          StandardOutput = "journal";
        };
      };
    };

缺乏权限显然导致 SDL 应用程序无法启动

$ dosbox
DOSBox version 0.74-3
Copyright 2002-2019 DOSBox Team, published under GNU GPL.
---
CONFIG:Loading primary settings from config file /user/.dosbox/dosbox-0.74-3.conf
X Error of failed request:  BadAlloc (insufficient resources for operation)
  Major opcode of failed request:  149 ()
  Minor opcode of failed request:  7
  Serial number of failed request:  253
  Current serial number in output stream:  254

$ qemu-system-x86_64 -display sdl
X Error of failed request:  BadAlloc (insufficient resources for operation)
  Major opcode of failed request:  149 ()
  Minor opcode of failed request:  7
  Serial number of failed request:  168
  Current serial number in output stream:  169

如果我在 root 下启动一个新的 Xephyr 会话,则一切正常。

答案1

问题是有这个参数

-depth 16

删除后,SDL 应用程序可以运行

相关内容