I want to use my orange pi power button to suspend and resume system and have some troubles with check state. So I wrote shell script for this but it won't work; it's only suspending.

When I click the button in suspend mode, the resumed and suspends again in a few seconds. I can't find a way to resume it.

It seems likely that systemctl is-system-running is returning running in the suspended state. My script is:

VALID_P=`systemctl is-system-running`
echo $VALID_P
if [ "$VALID_P" = "running" ]; then
    systemctl suspend
    systemctl default
  • 2
    If the system is suspended, would systemctl return anything, or even run? – Kusalananda Jul 4 '17 at 15:20
  • when i executing "systemctl suspend" from suspended system, it awake system for a few sec and make it suspend again – Evgeniy Russkikh Jul 4 '17 at 15:21
  • 1
    How do you do that if the system is suspended? – Kusalananda Jul 4 '17 at 15:23
  • it is hardware button connected to GPIO of my Orange Pi that execute script above when pressed – Evgeniy Russkikh Jul 4 '17 at 15:25
  • So, when you press the button, the system un-suspends, runs the script which finds out that the system is now not suspended, and then, because the system is not suspended, suspends it again. What's the question? – Kusalananda Jul 4 '17 at 15:27

In the end I used this script:

if [ -e "$file" ]
  rm /home/pi/loltest
  touch /home/pi/loltest
  systemctl suspend

Works OK in armbian. I still have some problems with it in RetroArch or EmulationStation - they just hang after resume.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.