Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

OPI PC: Run script on power button push?

Featured Replies

Hello all,

I was wondering if it is possible to run some sort of script when the power button on the Orange Pi PC is pressed?

I was thinking I could use this to run a safe shutdown script of some kind, rather than having to SSH in every time.

 

I've tried looking into the GPIOs but I could never get the button to show up in the list of available inputs. Any advice?

 

Thanks for any input. :)

  • Author

Looks interesting, but I don't think the orange pi power button is recognised as a normal key event :\.

The button is configured here and by default it is defined to enter suspend to RAM state. Unfortunately I forgot how to define the action (must have been back in February when we changed that). You could try to test acpid out and report back.

  • Author

Thanks tkaiser, your second link definitely pointed the way.

acpid appears to work great, and is exactly what I was looking for.

 

Extra question, anyway to blink the power led from a shell script?

  • Author

Actually NVM

 

to set red led to on use:

sudo sh -c "echo 255 > /sys/class/leds/red_led/brightness" 

to set red led to off use:

sudo sh -c "echo 0 > /sys/class/leds/red_led/brightness"

same for green led just "/sys/class/leds/green_led" instead

Regarding leds there's a bit more to say. In Armbian we define the leds in a different way than most if not all of the other available OS images for Orange Pis (OpenELEC being the other exception). With our led definition (see ssvb's commit) we can use different triggers, eg. let the green led blink, switch it off or on you would do:

echo heartbeat >/sys/class/leds/*green*/trigger
echo none >/sys/class/leds/*green*/trigger
echo default-on >/sys/class/leds/*green*/trigger

Adjusting brightness is also possible and in case you set the timer trigger two more sysfs nodes appear you can use to set on/off interval:

root@orangepiplus2e:/sys/class/leds/green_led# echo timer >/sys/class/leds/*green*/trigger
root@orangepiplus2e:/sys/class/leds/green_led# ls -al
total 0
drwxr-xr-x 3 root root    0 Jan  1  1970 .
drwxr-xr-x 4 root root    0 Jan  1  1970 ..
-rw-r--r-- 1 root root 4096 May 25 13:59 brightness
-rw-r--r-- 1 root root 4096 May 25 14:00 delay_off
-rw-r--r-- 1 root root 4096 May 25 14:00 delay_on
lrwxrwxrwx 1 root root    0 May 25 13:59 device -> ../../../leds-gpio
-r--r--r-- 1 root root 4096 May 25 13:59 max_brightness
drwxr-xr-x 2 root root    0 May 25 13:55 power
lrwxrwxrwx 1 root root    0 May 25 13:59 subsystem -> ../../../../../class/leds
-rw-r--r-- 1 root root 4096 May 25 14:00 trigger
-rw-r--r-- 1 root root 4096 Jan  1  1970 uevent

To get a list of all available triggers simply do a 'cat /sys/class/leds/*green*/trigger'.

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.