| # Copyright 2018 The ChromiumOS Authors | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| description "cecservice" | |
| author "chromium-os-dev@chromium.org" | |
| start on started system-services | |
| # Use 'stop on starting pre-shutdown' so that the pre-stop script blocks | |
| # shutdown. See comments in pre-shutdown.conf and ui.conf for more info. | |
| stop on starting pre-shutdown | |
| respawn | |
| respawn limit 3 10 # if the job respawns 3 times in 10 seconds, stop trying. | |
| oom score -100 | |
| expect fork | |
| exec minijail0 --config /usr/share/minijail/cecservice.conf \ | |
| -- /usr/sbin/cecservice | |
| post-start script | |
| # Wait for daemon to claim its D-Bus name. | |
| minijail0 -u cecservice -G \ | |
| /usr/bin/gdbus wait --system --timeout 15 org.chromium.CecService | |
| # Power on displays on boot if enabled in cros_config. | |
| if [ "$(cros_config /hdmi-cec power-on-displays-on-boot)" = "true" ]; then | |
| # Note, this is a non-blocking call since we don't pass --print-reply. | |
| dbus-send --fixed --system --type=method_call \ | |
| --dest=org.chromium.CecService /org/chromium/CecService \ | |
| org.chromium.CecService.SendWakeUpToAllDevices | |
| fi | |
| end script | |
| pre-stop script | |
| # Power off displays on shutdown if enabled in cros_config. | |
| # The 'initctl status halt' ensures we only do this on shutdown (not reboot). | |
| if [ "$(cros_config /hdmi-cec power-off-displays-on-shutdown)" = \ | |
| "true" ] && \ | |
| ! initctl status halt | grep -q 'stop/waiting'; then | |
| # Use --print-reply to make it a blocking call. The timeout shouldn't be too | |
| # long since it blocks shutdown. Typcial time with two displays is 0.2-1.3s. | |
| dbus-send --fixed --system --type=method_call \ | |
| --print-reply --reply-timeout=2000 \ | |
| --dest=org.chromium.CecService /org/chromium/CecService \ | |
| org.chromium.CecService.SendStandByToAllDevices | |
| fi | |
| end script |