[ltp] Re: How does a uevent work for dock/undock on thinkpads?

Daniel Castro linux-thinkpad@linux-thinkpad.org
Tue, 10 Feb 2009 18:20:51 +0000


--001485f796e214664e0462948c61
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Thank you very much. This helped a lot and I got it working, it is quite
easy actually. I'll post it on ThinkWiki.

Just one more question:

So whenever a ACPI (lid open or close) or HAL (dock or undock) event is
called and runs the script that scripts is run as root. And I'm calling from
there another script which is on my home directory.
If I run the script on my directory with my user it works fine. But when
root runs the scripts it will not find the command.

More specifically I'm trying to change the status of Piding using
purple-remote and it will throw an error saying:
/home/myuser/lid_scripts/pidginaway: line 5: No: command not found

The script pidginaway just contains:
`purple-remote "setstatus?status=away&message=My laptop's lid is closed
which means I'm moving around... Should be back soon!"`

Same sort of thing would happen for the HAL dock/undock event.

I tried running the script from the first call root does as:
su -l myuser -c "/path/to/the/script"

Anyone knows what I'm missing?

Thanks!

2009/2/8 Stefan Monnier <monnier@iro.umontreal.ca>

> > I know nothing about udev or HAL. Is there a simple way to do what
> > I want to do?  I would appreciate if anyone could give any help
> > or direction.
>
> It should be possible to write a simple file to put into
> /etc/udev/rules.d that will run your script whenever you dock or undock.
> The problem is to figure out what these events look like so you can
> write rules that match.
>
> A first step might be to add a /etc/udev/rules.d/00-trace.rules
> that just contains:
>
>   NAME==".*", RUN+="printenv | logger -t udevd"
>
> this will spam your syslog with a lot of info about each and every
> udev event.  Then you can look for the ones that correspond to
> docking&undocking.
>
>
>        Stefan
>
> --
> The linux-thinkpad mailing list home page is at:
> http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
>
>


-- 
________________________

Daniel Castro, M.Sc.
+353 083-318-2058
dancasmo@gmail.com
castromd@tcd.ie
________________________

--001485f796e214664e0462948c61
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Thank you very much. This helped a lot and I got it working, it is quite ea=
sy actually. I&#39;ll post it on ThinkWiki.<br><br>Just one more question:<=
br><br>So whenever a ACPI (lid open or close) or HAL (dock or undock) event=
 is called and runs the script that scripts is run as root. And I&#39;m cal=
ling from there another script which is on my home directory.<br>
If I run the script on my directory with my user it works fine. But when ro=
ot runs the scripts it will not find the command.<br><br>More specifically =
I&#39;m trying to change the status of Piding using purple-remote and it wi=
ll throw an error saying:<br>
/home/myuser/lid_scripts/pidginaway: line 5: No: command not found<br><br>T=
he script pidginaway just contains:<br>`purple-remote &quot;setstatus?statu=
s=3Daway&amp;message=3DMy laptop&#39;s lid is closed which means I&#39;m mo=
ving around... Should be back soon!&quot;`<br>
<br>Same sort of thing would happen for the HAL dock/undock event.<br><br>I=
 tried running the script from the first call root does as:<br>su -l myuser=
 -c &quot;/path/to/the/script&quot;<br><br>Anyone knows what I&#39;m missin=
g?<br>
<br>Thanks!<br><br><div class=3D"gmail_quote">2009/2/8 Stefan Monnier <span=
 dir=3D"ltr">&lt;<a href=3D"mailto:monnier@iro.umontreal.ca">monnier@iro.um=
ontreal.ca</a>&gt;</span><br><blockquote class=3D"gmail_quote" style=3D"bor=
der-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-=
left: 1ex;">
<div class=3D"Ih2E3d">&gt; I know nothing about udev or HAL. Is there a sim=
ple way to do what<br>
&gt; I want to do? &nbsp;I would appreciate if anyone could give any help<b=
r>
&gt; or direction.<br>
<br>
</div>It should be possible to write a simple file to put into<br>
/etc/udev/rules.d that will run your script whenever you dock or undock.<br=
>
The problem is to figure out what these events look like so you can<br>
write rules that match.<br>
<br>
A first step might be to add a /etc/udev/rules.d/00-trace.rules<br>
that just contains:<br>
<br>
 &nbsp; NAME=3D=3D&quot;.*&quot;, RUN+=3D&quot;printenv | logger -t udevd&q=
uot;<br>
<br>
this will spam your syslog with a lot of info about each and every<br>
udev event. &nbsp;Then you can look for the ones that correspond to<br>
docking&amp;undocking.<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Stefan<br>
<font color=3D"#888888"><br>
--<br>
The linux-thinkpad mailing list home page is at:<br>
<a href=3D"http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpa=
d" target=3D"_blank">http://mailman.linux-thinkpad.org/mailman/listinfo/lin=
ux-thinkpad</a><br>
<br>
</font></blockquote></div><br><br clear=3D"all"><br>-- <br>________________=
________<br><br>Daniel Castro, M.Sc.<br>+353 083-318-2058<br><a href=3D"mai=
lto:dancasmo@gmail.com">dancasmo@gmail.com</a><br><a href=3D"mailto:castrom=
d@tcd.ie">castromd@tcd.ie</a><br>
________________________<br>

--001485f796e214664e0462948c61--