3

I'm trying to display images on a television from a system with no Xserver (Raspbian Buster). I can't get fbi working from a systemd service but it works through ssh terminal.

The following works through ssh...

sudo fbi -T 1 /path/to/image.jpg

But it doesn't work from systemd service (wallpaper.service)...

[Unit]
Description=display image     

[Service]
Type=simple
ExecStart=/usr/bin/fbi -T 1 /path/to/image.jpg

...when I try and run it with...

sudo systemctl daemon-reload
sudo systemctl start wallpaper.service

I tried adding..

StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty1

in the service file with no luck.

Edit:

Output from sudo systemctl status wallpaper.service

● wallpaper.service - random wallpaper change script
   Loaded: loaded (/etc/systemd/system/wallpaper.service; static; vendor preset: enabled)
   Active: inactive (dead) since Wed 2019-08-07 01:34:34 EDT; 12s ago
  Process: 888 ExecStart=/usr/bin/fbi -T 1 -a /home/deanresin/temp/fire.dragon.jpg (code=exited, status=0/SUCCESS)
 Main PID: 888 (code=exited, status=0/SUCCESS)

Aug 07 01:34:34 kl3mmput3r systemd[1]: Started random wallpaper change script.
Aug 07 01:34:34 kl3mmput3r fbi[888]: using "DejaVu Sans Mono-16", pixelsize=16.67 file=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
Aug 07 01:34:34 kl3mmput3r systemd[1]: wallpaper.service: Succeeded.

Output from journalctl -u wallpaper.service

Aug 07 01:34:34 kl3mmput3r systemd[1]: Started random wallpaper change script.
Aug 07 01:34:34 kl3mmput3r fbi[888]: using "DejaVu Sans Mono-16", pixelsize=16.67 file=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
Aug 07 01:34:34 kl3mmput3r systemd[1]: wallpaper.service: Succeeded.

Edit: I read somewhere that fbi must be run from a console - a limitation of the program. Systemd sucks... nothing works from there.

deanresin
  • 432
  • 1
  • 5
  • 22
  • What does `systemctl status wallpaper.service` say? How about `journalctl -u wallpaper.service`? – filbranden Aug 07 '19 at 05:19
  • 1
    I updated the post by your request. – deanresin Aug 07 '19 at 05:27
  • Looks like it's actually running, process `fbi` is up and the service has been running for 22 minutes... Does `fbi` write logs somewhere? You could try to `strace` it to see what it's trying to do... – filbranden Aug 07 '19 at 05:30
  • I think I'm really confused how systemd works. Why would it be actively running? Wouldn't it just run.. do the command and then stop? – deanresin Aug 07 '19 at 05:33
  • The primary purpose of systemd is to run daemons, which are long-running processes... – filbranden Aug 07 '19 at 05:36
  • Ok the previous logs were obsolete as I never stopped the service. This time I stopped the service and then started it again. I updated the logs. It seems it ran fine but the image doesn't show on the screen. It is still the previous image from when I ran the command via ssh. – deanresin Aug 07 '19 at 05:38
  • This time the process is exiting... But claiming success... `(code=exited, status=0/SUCCESS)`. Maybe check more logs of the system (`journalctl -b`) see if you spot something that might explain what's happening? Unfortunately I have no experience with `fbi` so I'm not sure what might be going on here... – filbranden Aug 07 '19 at 05:44
  • fbi is trying to write an image to `/dev/tty1` (`-T 1`). It works from ssh terminal. But it doesn't from systemd. – deanresin Aug 07 '19 at 05:47
  • Systemd roughly fork a process, exec your specified program. Please understand process stop by itself, no matter what, technically. Even though other process (eg. parent or systemd)process might communicate with it (eg. the simplest, sending a signal) ask it to stop, IT STOP BY ITSELF. Then systemd don't ask the started process to stop, at least for your service unit. So think, what happened? Possibly the program called exit() by itself, but there's some process started later also write to framebuffer (or tty, or DRM device). – 炸鱼薯条德里克 Aug 07 '19 at 07:47

1 Answers1

1

You are missing the -d /dev/fb0 option that points to the actual frame buffer device. BTW I am trying to get -T 1 option to work right now, but it fails no matter what I do. There is another answer to a fbi question that states "if no virtual terminal is given /dev/console is used". (I will edit this if I get -T working from systemd)

The following works (to display an image) as a systemd service, and was found in /etc/systemd/system/splashscreen.service:

[Unit]
Description=Splash screen
DefaultDependencies=no
After=local-fs.target

[Service]
#ExecStart=/usr/bin/fbi --noverbose -d -T 1 /dev/fb0 -t 60 -a -l /path/to/some/images.lst
ExecStart=/usr/bin/fbi --noverbose -d /dev/fb0 -t 60 -a -l /path/to/some/images.lst
#ExecStart=/usr/bin/fbi --noverbose -d /dev/fb0 -a /path/to/some/image.png
StandardInput=tty
StandardOutput=tty
#TTYPath=/dev/tty1

[Install]
WantedBy=sysinit.target

The # lines are what I am testing atm, both the 2nd and 3rd ExecStart lines will display an image.

If you switch away from the (default boot) virtual console, you will loose the framebuffer output (the screen is blank/black), although key input still works (q to exit - verified with ps and systemctl). I presume that if you dont switch away, everything will work as expected, but I can not verify that atm, as the OS this came from autoruns a VM as its main OS, which opens on another terminal by default, and which also uses the framebuffer device.

Paul Wratt
  • 194
  • 1
  • 12