Ben_Pai | c53430a | 2019-07-15 16:19:02 +0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Toggle the state of identify LED Group |
| 3 | |
| 4 | SERVICE="xyz.openbmc_project.LED.GroupManager" |
| 5 | INTERFACE="xyz.openbmc_project.Led.Group" |
| 6 | PROPERTY="Asserted" |
| 7 | |
| 8 | # Get current state |
| 9 | object=$(busctl tree $SERVICE --list | grep identify) |
Ben Pai | dfef3e0 | 2020-03-02 13:32:10 +0800 | [diff] [blame] | 10 | led=$(cat /sys/devices/platform/leds/leds/front-id/brightness) |
Ben_Pai | c53430a | 2019-07-15 16:19:02 +0800 | [diff] [blame] | 11 | if [ "$led" == "0" ]; then |
| 12 | busctl set-property $SERVICE $object $INTERFACE $PROPERTY b false |
| 13 | else |
| 14 | busctl set-property $SERVICE $object $INTERFACE $PROPERTY b true |
| 15 | fi |
| 16 | |
| 17 | state=$(busctl get-property $SERVICE $object $INTERFACE $PROPERTY \ |
| 18 | | awk '{print $NF;}') |
| 19 | |
| 20 | if [ "$state" == "false" ]; then |
| 21 | target='true' |
| 22 | else |
| 23 | target='false' |
| 24 | fi |
| 25 | |
| 26 | # Set target state |
| 27 | busctl set-property $SERVICE $object $INTERFACE $PROPERTY b $target |