December 07, 2019, 07:24:39 pm

News:

Have you visited the Allwinner Chipset wiki? - http://linux-sunxi.org/


LED trigger manipulator with GUI - script!

Started by Jojo, March 24, 2014, 06:24:06 am

Previous topic - Next topic

Jojo

March 24, 2014, 06:24:06 am Last Edit: March 24, 2014, 06:28:17 am by Jojo
Hi,

the idea came to me, that I wanted to change the trigger of the onboard LEDs of my CB2 in a user-friendly way. A noob like me does not want to search trough deep folder structures, type teminal commands and these things  ::) . Terminal rules, of course, but it is not noob friendly ;) .

So I wrote a script that does the work for you  8) ! It is my very first linux script, so please don't be too strict with your critics  :-* ...

For a basic GUI style, I used "dialog" (a program for basic grafical thing in the terminal). This has to be installed first!

sudo apt-get install dialog


The script needs to be started with "root" privileges, because of the trigger file it will edit. After starting the script with

sudo bash LED_Trigger.sh


the script does:

  • look for the "leds" directory on the system (if not, report it)

  • in case of presence look if there is something in the "leds" directory (if not, report it)

  • list up the content of the "leds" directory (which are the present LEDs) in a radio box

  • after choosing a LED from the list, available triggers for that LED are listed in a radio box

  • after choosing a trigger from the list, it asks to really perform the action (setting the trigger)

  • if yes, new trigger is written to the trigger file for the LED

  • if no (or you choose "Cancel" somwhere, the program exits



Note 1:
the labels of the "buttons" are german, they depend on your default system language (in my case it is german).
"OK" means "OK" (who would have thought that  ;D ?!?!)
"Abbrechen" means "Cancel"
"Ja" means "Yes"
"Nein" means "No".

Note 2:
the change is NOT permanentely, to the original trigger will be restored after reboot. Maybe I make another box which asks to save the trigger permanentely. That would lead to an entry in the rc.local...

If you like it, I will improve it by things like
- checking installation of dialog
- more interaction with the user
- sizes of the "widows"
- ...

Please try and let me know your thoughts!
The script is attatched  8) .
Don't think that anyone will take more pains for his answer, as you took for your question.

Jojo

Don't think that anyone will take more pains for his answer, as you took for your question.

ikeeki

Great! included in next releases of qbee-x and cubiuntu.
What did you used for the gui?
zenity imposible, yad neither..

Jojo

Quote from: ikeeki on March 24, 2014, 09:13:13 am
Great! included in next releases of qbee-x and cubiuntu.
What did you used for the gui?
zenity imposible, yad neither..


Thanks :) .
Well, I used "dialog". It is the name of this thing that paints these "beautiful" boxes on the terminal. It seemed to me as the quickest and least complicated way for "interfaces". The result looks ok to me, so I think I will do some more in that direction.

I will try to improve some things and let you know if something is ready!
Don't think that anyone will take more pains for his answer, as you took for your question.

ikeeki


ikeeki

March 24, 2014, 01:38:26 pm #5 Last Edit: March 24, 2014, 01:46:41 pm by ikeeki
Im stupid, tried it in CT, it shows only blue option

Listen:
What about basing future scripts in seding and greping script.bin strings?
Anyways, there will be an always-the-same number of strings there, so it'd be reasonabily safe to modify them depending on:
A-cubietruck or cubieboard 2 word tokken in uEnv files.
B-standar number of files in their corresponding script.bin
c-a standar location for sunxi-tools for all the distros ; /etc/sunxi-tools?

Regards, Isaac.

Jojo

Quote from: ikeeki on March 24, 2014, 01:38:26 pm
Im stupid, tried it in CT, it shows only blue option

Listen:
What about basing future scripts in seding and greping script.bin strings?
Anyways, there will be an always-the-same number of strings there, so it'd be reasonabily safe to modify them depending on:
A-cubietruck or cubieboard 2 word tokken in uEnv files.
B-standar number of files in their corresponding script.bin
c-a standar location for sunxi-tools for all the distros ; /etc/sunxi-tools?

Regards, Isaac.


Hm, I am not sure that I understood you right  ??? . The script works on CT, right? Why do you want to grep some entries from the script.bin? I tried to make the script as "universal" as possible. It also works on my desktop PC and on a third system at work, because there are completely no dependencies from the target hardware.
I would like to keep this "universality" (does this word exist?!). What do you think? Do you have some specific ideas?

Greetings
Don't think that anyone will take more pains for his answer, as you took for your question.

ikeeki

Quote from: Jojo on March 24, 2014, 02:57:17 pm
Quote from: ikeeki on March 24, 2014, 01:38:26 pm
Im stupid, tried it in CT, it shows only blue option

Listen:
What about basing future scripts in seding and greping script.bin strings?
Anyways, there will be an always-the-same number of strings there, so it'd be reasonabily safe to modify them depending on:
A-cubietruck or cubieboard 2 word tokken in uEnv files.
B-standar number of files in their corresponding script.bin
c-a standar location for sunxi-tools for all the distros ; /etc/sunxi-tools?

Regards, Isaac.


Hm, I am not sure that I understood you right  ??? . The script works on CT, right? Why do you want to grep some entries from the script.bin? I tried to make the script as "universal" as possible. It also works on my desktop PC and on a third system at work, because there are completely no dependencies from the target hardware.
I would like to keep this "universality" (does this word exist?!). What do you think? Do you have some specific ideas?

Greetings


The script works on CT only partially. Only bule led option.
I meant fex file, not exactly script.bin
I think that the compatibility with other hardware  did not exist, that it was only for cubieboards A20.
When I have my idea more mature, I'll let you know  :)

slovenia

QuoteThe script works on CT only partially. Only bule led option.


It's working perfect on my CT. All LEDs are working - I did not test all functions, but all tested were working as expected.
Debian and Ubuntu images with kernel 3.4.110, 4.3.3, 4.4
http://www.armbian.com

ikeeki

March 24, 2014, 05:58:36 pm #9 Last Edit: March 24, 2014, 06:16:43 pm by ikeeki
Quote from: slovenia on March 24, 2014, 05:28:51 pm
QuoteThe script works on CT only partially. Only bule led option.


It's working perfect on my CT. All LEDs are working - I did not test all functions, but all tested were working as expected.


Uppss, that is quite a surprise, maybe I did not understand what I had to do... Ill re-read everything again and retry, sorry.

-----EDIT----
How embarrasing, yes, it does work, did not see the arrow for continuing the list ----> I'm stupid lOOOOOOOOOOOOOL

But what should I do for finding all leds? It only shows the blue one...
Tested in cubiuntu 0.888


lampra

Quote from: ikeeki on March 24, 2014, 03:11:11 pm
The script works on CT only partially. Only bule led option.
I meant fex file, not exactly script.bin
I think that the compatibility with other hardware  did not exist, that it was only for cubieboards A20.
When I have my idea more mature, I'll let you know  :)


Same here,  only bule led options on CT using Qbee-X

Tokka

Nice job Jojo  :D
i think it is time for cubietech to gift me a cb2 and (or) a ct, or i'll can't help you all  :'(

;D ;D ;D ;D ;D
CB1 (A10) - Qbee-X_TMC

ikeeki

LOOOOOOOOOOOOOOOOOOOL
Troll mode on LOOOOOOOOOOOOOOOOOOOOL

slovenia

I am running my own Debian wheezy and got this screen:

Debian and Ubuntu images with kernel 3.4.110, 4.3.3, 4.4
http://www.armbian.com

Jojo

Quote from: ikeeki on March 24, 2014, 05:58:36 pm
-----EDIT----
How embarrasing, yes, it does work, did not see the arrow for continuing the list ----> I'm stupid lOOOOOOOOOOOOOL

But what should I do for finding all leds? It only shows the blue one...
Tested in cubiuntu 0.888


Hm, this is strange  ??? . Maybe the other LEDs are just not configured in the kernel/script.bin?
My script does nothing else then just looking into the "leds" directory and list up all its content (which should be the available LEDs).

Could you please look into your "leds" folder? Is there more than one LED? The content of my "sys/class/leds" is


  • blue:ph21:led2

  • boxgreen

  • boxred

  • green:ph20:led1

[/i]
And that is what it shown on screenshot 2.

And slovenias screen looks similar to mine, and he is running another distribution  ??? ?!
Don't think that anyone will take more pains for his answer, as you took for your question.