You are not logged in.

#1 2010-07-15 19:34:42

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

[solved] ThinkAlert

Hi all,

is this tool available for arch, perhaps as part of some existing package?

http://www.mike.tl/other/ThinkAlert.html

Thanks in advance & kind regards,
jamesbond007.

Last edited by jamesbond007 (2010-07-20 19:58:19)

Offline

#2 2010-07-15 19:37:31

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: [solved] ThinkAlert

jamesbond007 wrote:

Hi all,

is this tool available for arch, perhaps as part of some existing package?

http://www.mike.tl/other/ThinkAlert.html

Thanks in advance & kind regards,
jamesbond007.

Depends on what you want to do with it.
AUR has this http://aur.archlinux.org/packages.php?O … _Search=Go

which allows you to blink the light on incoming kopete /pidgin messages. There is also a tpb package in community (i believe) which may have included the light functionality, I am not a 100% sure. If all else fails, I could package it up for you in AUR. (Can we call dibs on building packages big_smile ? )

Last edited by Inxsible (2010-07-15 19:38:50)


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2010-07-15 19:50:51

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

Re: [solved] ThinkAlert

Hi Inxsible,

thanks for your quick answer.

Inxsible wrote:

Depends on what you want to do with it.
AUR has this http://aur.archlinux.org/packages.php?O … _Search=Go

I would like to use it from within my own scripts, so the plugins for pidgin and kopete do not really help me.

Inxsible wrote:

There is also a tpb package in community (i believe) which may have included the light functionality, I am not a 100% sure.

I inspected the filelist of the tpb package and I think it does not contain what I would like to have. Unfortunately, I don't have my thinkpad here right now, I have left it at the office.

Inxsible wrote:

If all else fails, I could package it up for you in AUR.

That would be very kind of you! smile - I already read the basics about creating PKGBUILDs, because I would like to learn it myself - but I guess my knowledge about compiling and packaging software is still close to nothing. smile

Thanks in advance,
jamesbond007.

Offline

#4 2010-07-15 19:53:45

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: [solved] ThinkAlert

Ok, I will try to get you a PKGBUILD later tonight. I am at work right now and supposedly should be doing what my boss pays me for wink tongue


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#5 2010-07-15 23:32:28

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: [solved] ThinkAlert

Here's the package in AUR as promised.

Please test it out and let me know if it installs correctly.

Last edited by Inxsible (2010-07-15 23:33:14)


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#6 2010-07-16 09:39:27

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

Re: [solved] ThinkAlert

Inxsible wrote:

Here's the package in AUR as promised.

Thank you very much!

Inxsible wrote:

Please test it out and let me know if it installs correctly.

Well yes, it installs correctly without any issues using yaourt. But I have a problem when I try to call /usr/bin/thinkalert from the command line: While this does work as root, it does not work as a regular user.

As root:

# /usr/bin/thinkalert
thinkalert <on|off>
thinkalert <times> [interval (microseconds)]
thinkalert <times> <on period (microseconds)> <off period (microseconds)>

# /usr/bin/thinkalert 2
<no output, light flashes two times as expected>

As regular user:

> /usr/bin/thinkalert
Unable to open the ThinkLight interface: Permission denied

> /usr/bin/thinkalert 2
Unable to open the ThinkLight interface: Permission denied

Now the question is: How can I get this to work as a regular user? Is this a configuration issue (e.g. permission for a device needs to be changed) or is a modification of the thinkalert package necessary?

Thanks in advance & kind regards,
jamesbond007.

Offline

#7 2010-07-16 09:47:40

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

Re: [solved] ThinkAlert

I guess this is the problem:

> ls -l /proc/acpi/ibm/light
-rw-r--r-- 1 root root 0 Jul 16 11:41 /proc/acpi/ibm/light

Doing "chmod a+w /proc/acpi/ibm/light" (as root) seems to solve the problem temporarily. But as the proc file system is a pseudo-file system, I guess that this "solution" will only last until the next reboot. So what do I need to do to solve the problem permanently?

Offline

#8 2010-07-16 14:52:32

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: [solved] ThinkAlert

Ok.

I just followed the instructions on the website that you linked, to build the PKGBUILD and they chown the thinkalert to root. He hasn't mentioned why.

I guess if I remove the chown, then your regular user could use it as well. Later tonight !!

Last edited by Inxsible (2010-07-16 14:53:25)


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#9 2010-07-16 18:51:45

akuschki
Member
Registered: 2009-10-17
Posts: 40

Re: [solved] ThinkAlert

I would rather use a shell script than C executable for something simple as this, so I wrote something quick and dirty. Maybe somebody else is interested as well:

#!/bin/sh

[[ $# < 2 || $# > 3 ]] && echo "Wrong number of arguments: $# 
Usage:

thinkalert <times> [interval (s)]

or 

thinkalert <times> <on period (s)> <off period (s)>
" && exit 64


light=/proc/acpi/ibm/light
onperiod=$2
[[ $# = 2 ]] && offperiod=$2 || offperiod=$3



for ((i=1;i<=$1;i++))
do  
    echo on > $light
    sleep $onperiod
    echo off > $light
    [[ $i = $1 ]] && exit 0 || sleep $offperiod
done

As for the permissions, personally I would rather add my user to sudoers for the thinkalert command by adding something like this to the sudoers file:

username ALL=NOPASSWD:/home/username/bin/thinkalert

Then you can use the command like this in your scripts without being prompted for your password:

sudo thinkalert 5 0.3 1

Last edited by akuschki (2010-07-16 20:02:12)

Offline

#10 2010-07-20 18:59:07

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

Re: [solved] ThinkAlert

Hi akuschki,

thank you very much for your script, which I can adapt for my own purposes. I did not realize before that it is really so simple! smile

One question remains: As I don't have sudo installed, is there another approach to solve the permission problem? - I was thinking about using the suid-bit, but IIRC, the suid-bit does not work for scripts (only for binary executables).

Kind regards,
jamesbond007.

Offline

#11 2010-07-20 19:20:16

akuschki
Member
Registered: 2009-10-17
Posts: 40

Re: [solved] ThinkAlert

You're welcome. Unfortunately I don't know anything about the suid-bit business: problems like this are the reason I use sudo; it just seems to be the sanest way of handling these permission problems. Any particular reason why you prefer not to use sudo? (let me guess: you're a minimalist and detest bloat smile

The only other things I can think of are -  as mentioned above - using chown or chmod to change  /proc/acpi/ibm/light at every startup,  or alternatively executing your script as super user. The former seems to be much preferable. But there might be other ways and I am sure you can get an answer on the thinkpad-linux mailing list if you ask there (http://mailman.linux-thinkpad.org/mailm … x-thinkpad). The developer of thinkpad-acpi (and hence /proc/acpi/ibm/light) is there as well.

Last edited by akuschki (2010-07-20 19:22:22)

Offline

#12 2010-07-20 19:43:13

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

Re: [solved] ThinkAlert

akuschki wrote:

Any particular reason why you prefer not to use sudo?

No, not really. I just never used it and thus have no experience in using it. That's all. smile

If I install sudo, can I still use the root user and do everything like I did it before? I mean just use /etc/sudoers to solve the permission problem, and otherwise continue to ignore sudo? Would that work?

Offline

#13 2010-07-20 19:52:57

akuschki
Member
Registered: 2009-10-17
Posts: 40

Re: [solved] ThinkAlert

jamesbond007 wrote:

If I install sudo, can I still use the root user and do everything like I did it before? I mean just use /etc/sudoers to solve the permission problem, and otherwise continue to ignore sudo? Would that work?

yes sure. you can always do su to become the super user even when sudo is installed. or you can use sudo -s, which has the same effect but some advantages.

Offline

#14 2010-07-20 19:55:50

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

Re: [solved] ThinkAlert

Thanks again for your help, akuschki and Inxsible! --> Thread marked as solved.

Offline

Board footer

Powered by FluxBB