blob: c8eddaea4a0d13d151b712b06c34c7e743be1626 [file] [log] [blame]
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Start powerd after x-started"
author "chromium-os-dev@chromium.org"
start on x-started
stop on stopping ui or starting halt or starting reboot
env HOME=/home/chronos
env LOG_DIR=/var/log/power_manager
env RUN_DIR=/var/run/power_manager
env PREFS_DIR=/var/lib/power_manager
env DEFAULT_PREFS_DIR=/usr/share/power_manager
env XAUTHORITY=/home/chronos/.Xauthority
env DISPLAY=:0.0
env USER_ID=1000
respawn
respawn limit 20 60 # if the job respawns 20 times in 60 seconds, stop trying.
script
mkdir -p ${LOG_DIR} ${PREFS_DIR}
chown -R ${USER_ID} ${PREFS_DIR}
chown ${USER_ID} ${LOG_DIR}
chown ${USER_ID} /sys/power/state
# If backlight files don't exist, the wildcard will be treated as a literal, and
# chown will fail. Checking for the existence first will prevent chown failure.
for BACKLIGHT in /sys/class/backlight/*/*; do
if [ -e $BACKLIGHT ]; then
chown ${USER_ID} $BACKLIGHT
fi
done
cd ${HOME}
exec /sbin/minijail --uid=${USER_ID} -- /bin/dash -c ' \
/usr/bin/powerd \
--prefs_dir=${PREFS_DIR} \
--default_prefs_dir=${DEFAULT_PREFS_DIR} \
--log_dir=${LOG_DIR} \
--run_dir=${RUN_DIR} \
> ${LOG_DIR}/powerd.out 2>&1; sleep 2'
end script