(07-11-2024, 08:29 AM)Romanz Wrote: The system boots up, the display appears on the oled display. If I go to terminal and enter the command "sudo systemctl stop mpd_oled" the display goes out. If I type "sudo systemctl start mpd_oled" at once, the display appears. If I press the button and run the script, the display goes out. The next press does not help. If I type the command "sudo systemctl start mpd_oled" in the terminal, there is no response either. Only rebooting moode helps.
Now it's clearer...
So:
1. at startup everything is OK
2. you can switch it OFF by pressing the button
3. you cannot, then, switch it back ON neither with the button, nor with the command.
Sounds strange... like the script somehow does not terminate, or there are some errors that prevent it to be run any further after the first invoke...
I would try the following, then:
1. add echo lines in the two IF branches, so to see which path is taken by the script, so that it looks like this:
Code:
#!/bin/bash
if (systemctl is-active --quiet mpd_oled); then
echo "MPD_OLED is active, turning it OFF..."
sudo systemctl stop mpd_oled
echo "Done."
else
echo "MPD_OLED is not active, turning it ON..."
sudo systemctl start mpd_oled
echo "Done."
fi
2. after startup, instead of pressing the buttons, just open a terminal, and call the script on the command-line, and report what you see as the output of the script.