PINE64
acpi "ac_adapter" events - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=111)
+--- Forum: Linux on Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=114)
+--- Thread: acpi "ac_adapter" events (/showthread.php?tid=11621)



acpi "ac_adapter" events - elijahr - 09-24-2020

Hello, I am running Manjaro on my PBP. I want to modify /etc/acpi/handler.sh to run some scripts when AC power is plugged/unplugged.

My understanding is that this should show up as an `ac_adapter` event in the output of `acpi_listen`. However, there is no such output when I plug/unplug from power. Other events do print. I have Power Manager running and it shows a notification that I've plugged/unplugged from power, so it must be using a different mechanism. How can I hook into AC plug/unplug events?

Code:
$ sudo acpi_listen
button/power PBTN 00000080 00000000
button/power PBTN 00000080 00000000
button/lid LID close
button/lid LID open

Thanks for any ideas!


RE: acpi "ac_adapter" events - MtnSk8 - 09-24-2020

This method may work for you:

[Image: d4cc5a1bda35e34156516c34b4bb9167-full.png]
Cheers!


RE: acpi "ac_adapter" events - elijahr - 09-24-2020

Thank you for the suggestion. I should have specified, I'm using Manjaro with i3 so I don't have the KDE settings.
I did find a way to listen for AC adapter events, using udev, something like this as a rule in /usr/lib/udev/rules.d/:

Code:
ACTION=="change", SUBSYSTEM=="power_supply", RUN+="the_command"



Then I ran sudo udevadm control --reload to reload the udev rules.

In my script, I check whether the AC adapter is plugged in with:

Code:
#!/bin/sh

case $(cat /sys/devices/platform/dc-charger/power_supply/dc-charger/online) in
    0)
      # do something when unplugged
      ;;
    1)
      # do something when plugged in
      ;;
esac