#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2024 ROCNIX (https://github.com/archr-linux/Arch-R)

# Store current LED state and turn of LEDS as they prevent the device from sleeping while on

. /etc/profile

### Get the current LED state and store it
PRE_SLEEP_LED_STATE=$(get_setting "led.color")
if [ ! -n "${PRE_SLEEP_LED_STATE}" ]; then
  PRE_SLEEP_LED_STATE="battery"
  set_setting "led.color" "battery"
fi

set_setting sleep.led.color "${PRE_SLEEP_LED_STATE}"

### Turn off LEDS
/usr/bin/ledcontrol "off"
