2

I want to use pygame on a raspi to display pictures on the screen connected to the hdmi port of the raspi. I want to do this via a ssh connection.

As a first test, I tried the very basic (and classic) script that tests for the available drivers:

import os
import pygame

disp_no = os.getenv('DISPLAY')
print("I'm running under {}".format(disp_no))

drivers = ['directfb', 'fbcon', 'svgalib']

found = False
for driver in drivers:
    if not os.getenv('SDL_VIDEODRIVER'):
        os.putenv('SDL_VIDEODRIVER', driver)
        os.environ["SDL_FBDEV"] = "/dev/fb0"
    try:
        pygame.display.init()
        print('OK with',driver)
    except pygame.error:
        print('Driver: {0} failed.'.format(driver))
        continue
    found = True
    break

if not found:
   raise Exception('No suitable video driver found!')

Here are the results of my tests :

  1. from a ssh session : no suitable video driver found
  2. from a ssh session as root : OK with directfb
  3. from a tty console (with a keyboard connected to the raspi) : OK with directfb

My question is : why does situation 1 results in a failure. What do I miss and what should I do?

Please note that permissions on /dev/fb0 and all /dev/tty?? are set so that I can read/write without being root. Also note that I don't have the X server running.

Johann Bzh
  • 834
  • 3
  • 10
  • 25
  • This is caused by permissions, there is a good set of answers here: https://unix.stackexchange.com/questions/58961/how-do-i-let-an-sdl-app-not-running-as-root-use-the-console/387144 – Kingsley Oct 13 '19 at 21:03
  • I have the proper permissions on /dev/fb0 and /dev/ttyXX. But from the post you mention Kingsley, I don't see the link with the `daemon’s .service file` thing – Johann Bzh Oct 16 '19 at 19:23

0 Answers0