nandomtl
Posts: 5
Joined: Tue Feb 25, 2020 12:45 am

2 monitors, 2 applications, RPi 4B

Tue Feb 25, 2020 1:23 am

Assume two applications running on a RPi 4B, each one using a screen (connected to the HDMI ports).

Requirements:

Both applications are started at boot time.
Each application must use a specific screen (think of something like a screen for engine information and the other for GPS mapping).
The RPi is dedicated to running these applications, so no keyboard or mouse. The applications run full screen.

How does one go about this? I found information on how to start an application during boot, but nothing about associating application X to display Y...

(I am new to the forum, please advise if I am violating any rule)

User avatar
HermannSW
Posts: 2042
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: 2 monitors, 2 applications, RPi 4B

Tue Feb 25, 2020 10:50 pm

There is only one framebuffer, so you cannot use two displays in console mode for anything else than mirroring output.

With X11 you can place both displays with xrandr, and you can make your applications appear on one or the other display by using "-geometry" options:
viewtopic.php?f=63&t=254176&p=1595920#p1595310
Image
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

nandomtl
Posts: 5
Joined: Tue Feb 25, 2020 12:45 am

Re: 2 monitors, 2 applications, RPi 4B

Thu Feb 27, 2020 6:02 pm

Thank you for your comment.

I read your other posts, but could not figure how to use that information to address my requirements:

Two apps, each running full screen on their respective monitors, and started at boot time (or immediately thereafter).
RPi 4B dedicated to these apps; no keyboard or mouse attached.

Here's what I tried: based on t this article by Shawn Hymel (https://learn.sparkfun.com/tutorials/ho ... tartup/all), I decided to start the applications by using systemd. Therefore, I created two services - code listed below.
The way I specified the monitors was based on this post: https://stackoverflow.com/questions/784 ... 32#1210332

Services definition:

Code: Select all

[Unit]
Description=Start Clock1 (clock+.py on display 0)

[Service]
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
ExecStart=/usr/bin/python3 /home/pi/Python_code/sparkfun-clock+.py
Restart=always
RestartSec=10s
KillMode=process
TimeoutSec=infinity

[Install]
WantedBy=graphical.target

Code: Select all

[Unit]
Description=Start Clock2 (clock++.py on display 1)

[Service]
Environment=DISPLAY=:0.1
Environment=XAUTHORITY=/home/pi/.Xauthority
ExecStart=/usr/bin/python3 /home/pi/Python_code/sparkfun-clock++.py
Restart=always
RestartSec=10s
KillMode=process
TimeoutSec=infinity

[Install]
WantedBy=graphical.target

The result is that one application runs full screen on the main monitor (display :0), but the other one does not get started.
Here is a display status:

Code: Select all

[email protected]:~ $ systemctl status clock2.service
● clock2.service - Start Clock2 (clock++.py on display 1)
   Loaded: loaded (/lib/systemd/system/clock2.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Thu 2020-02-27 09:45:49 EST; 4s ago
  Process: 6478 ExecStart=/usr/bin/python3 /home/pi/Python_code/sparkfun-clock++.py (code=exited, status=1/FAILURE)
 Main PID: 6478 (code=exited, status=1/FAILURE)
...and here is a display of the active screens:

Code: Select all

[email protected]:~ $ xrandr --screen 0
Screen 0: minimum 320 x 200, current 2944 x 1080, maximum 7680 x 7680
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 477mm x 268mm
   1920x1080     60.00*+  60.00    50.00    59.94    59.99  
   1600x1200     60.00  
   1680x1050     59.88  
   1280x1024     75.02    60.02  
   1440x900      59.90  
   1280x960      60.00  
   1366x768      59.79  
   1152x864      75.00  
   1280x720      60.00    60.00    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00    50.00  
   720x480       60.00    60.00    59.94    59.94    59.94  
   640x480       75.00    72.81    66.67    60.00    59.94    59.94  
   720x400       70.08  
HDMI-2 connected 1024x600+1920+0 (normal left inverted right x axis y axis) 154mm x 86mm
   1024x600      72.65*+
   640x480       59.94  
Any ideas, comments and suggestions are welcome

User avatar
HermannSW
Posts: 2042
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: 2 monitors, 2 applications, RPi 4B

Thu Feb 27, 2020 7:33 pm

I used two 23" monitors with AIX back in 1995 when I started working at IBM.
There the displays where ":0.0" and ":0.1".
If I remember correctly, ":0.1" did not work on Raspbian when I did above screenshot and tests.
I don't have 2nd monitor for Pi4B here, so please start X11 normally and see whether you get output for:

Code: Select all

DISPLAY=:0.1 xclock
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

nandomtl
Posts: 5
Joined: Tue Feb 25, 2020 12:45 am

Re: 2 monitors, 2 applications, RPi 4B

Thu Feb 27, 2020 9:14 pm

yes, logic dictates that 0.1 should work... however:

Code: Select all

[email protected]:~ $ DISPLAY=:0.1 xclock
Error: Can't open display: :0.1
I tried a number of variations, such as 1.0, HDMI1, HDMI-1, but no luck

Danke für den Versuch

User avatar
HermannSW
Posts: 2042
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: 2 monitors, 2 applications, RPi 4B

Sat Feb 29, 2020 9:45 am

You cannot use "fullscreen", but achieve the same effect. In the scrot screenshot I showed I would start both applications in :0.0, one of Size 1360x768 at coordinate 0,0, one of size 1024x768 at top left coordinate 1920,0. That way both applications show fullscreen on both displays.
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

nandomtl
Posts: 5
Joined: Tue Feb 25, 2020 12:45 am

Re: 2 monitors, 2 applications, RPi 4B

Sat Feb 29, 2020 8:54 pm

Hallo, Hermann

I was thinking of that too, although I am not sure how I would implement the idea.
I'll try that as soon as I figure it out - but I still think there should be a more straightforward way of doing this...

Enjoy the weekend, and thank you!

nandomtl
Posts: 5
Joined: Tue Feb 25, 2020 12:45 am

Re: 2 monitors, 2 applications, RPi 4B

Wed Mar 04, 2020 8:19 pm

I found that devilspie2 does what I need: http://www.linux-magazine.com/Issues/20 ... Devilspie2
(tested on an RPi 4B, 2GB, two HDMI monitors)

Return to “Advanced users”