xref: /openbmc/openbmc/meta-ibm/recipes-phosphor/gpio/id-button/toggle_identify_led.sh (revision 9b8716888b838a9985a313d8c2ed287497d851e7)
1e1615142SBrad Bishop#!/bin/sh
2e1615142SBrad Bishop# Toggle the state of identify LED Group
3e1615142SBrad Bishop
4e1615142SBrad BishopSERVICE="xyz.openbmc_project.LED.GroupManager"
5e1615142SBrad BishopINTERFACE="xyz.openbmc_project.Led.Group"
6e1615142SBrad BishopPROPERTY="Asserted"
7e1615142SBrad Bishop
8e1615142SBrad Bishop# Get current state
9e1615142SBrad Bishopobject=$(busctl tree $SERVICE --list | grep identify)
10e1615142SBrad Bishopled=$(cat /sys/devices/platform/leds/leds/front-id/brightness)
11*9b871688SPatrick Williamsif [ "$led" = "0" ]; then
12*9b871688SPatrick Williams	busctl set-property $SERVICE "$object" $INTERFACE $PROPERTY b false
13e1615142SBrad Bishopelse
14*9b871688SPatrick Williams	busctl set-property $SERVICE "$object" $INTERFACE $PROPERTY b true
15e1615142SBrad Bishopfi
16e1615142SBrad Bishop
17*9b871688SPatrick Williamsstate=$(busctl get-property $SERVICE "$object" $INTERFACE $PROPERTY \
18e1615142SBrad Bishop	  |  awk '{print $NF;}')
19e1615142SBrad Bishop
20*9b871688SPatrick Williamsif [ "$state" = "false" ]; then
21e1615142SBrad Bishop    target='true'
22e1615142SBrad Bishopelse
23e1615142SBrad Bishop    target='false'
24e1615142SBrad Bishopfi
25e1615142SBrad Bishop
26e1615142SBrad Bishop# Set target state
27*9b871688SPatrick Williamsbusctl set-property $SERVICE "$object" $INTERFACE $PROPERTY b $target
28