6

The pi is configured to start into text mode so that no xorg libraries are loaded during normal operation. Yet I would like to be able to occasionally run an xorg desktop session when connected to an HDMI display.

I already have enabled HDMI display with:

hdmi_drive=2 hdmi_force_hotplug=1 

The HDMI screen is working in text mode. I have no keyboard connected to the pi and therefore would like to control it via ssh which is already working.

I tried starting the xorg session via ssh with startx -- -layout HDMI but this did not work for obvious reasons, since xorg is not gonna run through a ssh connection.

So the question is how to start xorg on the physical HDMI display via an ssh connection?

Running e.g.

startx -- vt7 

results in the following error:

(EE) xf86OpenConsole: Cannot open virtual console 7 (Permission denied) 

Using export DISPLAY=:0.0 did not make any difference.

I am currently using the workaround of changing the boot type using sudo raspi-config > Boot Options > Desktop GUI but would like to be able to start xorg on-demand via an ssh session.

4
  • what happens if you run startx when you're logged in with ssh? Commented Sep 15, 2018 at 12:43
  • it fails with an error message Commented Sep 15, 2018 at 12:52
  • an error message What error message? Commented Sep 15, 2018 at 13:27
  • added error message to the question Commented Sep 16, 2018 at 0:25

2 Answers 2

1

Raspberry Pi OS uses systemd to organize userland. In traditional unix, the text console with user logins was one run level (2?). The graphical desktop under control of a "greeter" was another (6?). Systemd replaces that setup with a selection of target states. The target states of interest here are called "multi-user" and "graphical."

To find out the currently active targets:

$ sudo systemctl list-units --type target --state active 

To start a greeter/desktop on a system that's already at multi-user,

$ sudo systemctl isolate graphical.target 

To shut down all the stuff the graphical.target brought up, returning to multi-user.

$ sudo systemctl isolate multi-user.target 

You can try to get around systemd with xinit and startx, but they won't handle the environment as well.

0

Given that you have no keyboard, I assume you want to run X for some specific program, other than a login screen. Specify that program as an argument to xinit, for example run xinit /usr/bin/chromium.

6
  • I want to run the full-blown desktop and use some kind of virtual onscreen keyboard which I can operate with a USB mouse. The temporary workaround I'm using is running raspi-config and enabling passwordless xorg autostart but that loads xorg unconditionally on every boot.. Commented Sep 15, 2018 at 13:00
  • in fact, found a working onscreen keyboard: apt-get install matchbox-keyboard Commented Sep 15, 2018 at 13:17
  • Can you xinit your window manager? Commented Sep 15, 2018 at 19:42
  • not when I am connected via ssh Commented Sep 15, 2018 at 20:53
  • Can you please provide details of the command and the corresponding error message? Commented Sep 15, 2018 at 22:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.