Hi Lennart,<div><br></div><div>Any comments?</div><div><br></div><div>We hope to assign our work with systemd one.<span></span></div><div><br></div><div>Thank you,</div><div>Kyungmin Park</div><div><br></div><div><br>On Monday, March 9, 2015, WaLyong Cho <<a href="mailto:walyong.cho@samsung.com">walyong.cho@samsung.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I want to find best solution on our case. Our product is mobile device.<br>
But I don't think that is only problem of mobile device. That also can<br>
be problem of laptop. So, please comment to me.<br>
<br>
We have some of services are always running after system is started up<br>
as default. They don't need to be running always. They are just needed<br>
only charger is plugged in.<br>
So I thought lets only active them when only charger is plugged in.<br>
<br>
I thought two methods.<br>
<br>
method 1:<br>
Charger also can be detected by udev. So udev hardware activation can be<br>
used.<br>
I wrote below udev rules.<br>
<br>
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_CHARGE_NOW}=="1",<br>
TAG+="systemd", ENV{SYSTEMD_WANTS}+="foo.service"<br>
<br>
It looked working well. foo.service is only activated when charger was<br>
plugged in.<br>
But I have some of problems with hardware activation.<br>
I want to be stopped foo.service when the charger is plugged out. As I<br>
know, this is impossible with udev hardware activation.<br>
To do this, foo.service have to determine the charger state itself and<br>
if the charger is plugged out, it have to stop itself.<br>
And it is working only at the first time.<br>
After foo.service was activated, I stopped foo.service by "systemctl<br>
stop foo.service". And plug out and plug in the charger again. Then<br>
foo.service was not activated. (Is it normal? I did not try to find the<br>
reason. If you say it's a problem, then I will try to find.)<br>
<br>
<br>
method 2:<br>
We have another device daemon. Let's call that as deviced and its<br>
service name is deviced.service. deviced know about plug in/out of the<br>
charger.<br>
So, I made a new charging.target. foo.service have Wants= dependency for<br>
charging.target. (Installed on charging.target.wants.) And I added<br>
"BindsTo=charging.target" to foo.service.<br>
Then foo.service is activated well when the charging.target is entered<br>
to active state. And also deactivated when charging.target was deactivated.<br>
<br>
In this method, there are limitations what some of other daemon is<br>
needed and new charging.target is needed.<br>
<br>
<br>
Is there any more good way for this?<br>
I want to find best appropriate way.<br>
<br>
Thank you in advance for comment.<br>
<br>
WaLyong<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'systemd-devel@lists.freedesktop.org')">systemd-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/systemd-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</blockquote></div>