Customation, and its dangers for the Update System


matzesu

Forum Addict!
Staff member
Joined
Oct 24, 2008
Messages
13,018
Age
39
Location
Germany,, Saarland, at home
Hellolo,
i wonder: When i customice stuff on the Pyra, like making the Fondsice more reading friendly, or editing the script to move the Charging Indicator from the Power Button to the LID Logo, how much of the Update Process would then screwed up`? Lets say a new Update would bring exactly this Option or would make the Fondsize bigger,

Or dos the Update Process not get harmed from Custom Options`?
 
assume you did your config overrides locally in ~ and not system-wide eg in /etc you config changes should not be blown away.

normally the updated software will be backwards compatible in terms of config and even upgrade local config format first time it's run. but yeah, upgrades are known to break things, esp customizations. suggest only upgrading if there is a clear benefit. unless you like re-customizing.
Post automatically merged:

actually, is there any way of taking an image of the root partition so it's possible to rollback an os update? not that i would ever rollback anything.... (i'm too proud)

But to answer your ultimate question: just do it
 
Last edited:
Î asced because EvilDragon meantioned on Discord, that you could just customize a simple scrippt if you want that the Charging Indicator is on the LID LED..

But im not that big into Linux, and i dont even know the scrippt or which commands needs to edit, and how, so it was maybe just something theoretical..

Whit the Fond Size where much more likely from me to change, as its still quite small , and i dont know which Power Save Options where Originally, and how to put the Alsa Mixer back to Stock, when the Audio Issue was fixed from the Officiall Defs..
 
im not that big into Linux
doch.

I've done something similar in the past, hijacked my caps lock led to indicate mail. there were two fundamental steps: determining if you have mail (check /var/spool/<user>) and update the led (some unix command). then i had a script that was always launched by @reboot in my crontab and basically ran in a loop, checking every minute or something. this was a userland script controlled completely by me. when i upgraded i just need to ensure the unix command was installed and i was good to go.

for you, you need to know how to check the battery level and then set the lid led. if you know the unix commands for these two things then writing a script to join the stuff together should be easy. if you can figure out the two commands the community will be more than happy to help you script this up. later, we can even merge this script into the repo... ^_^
 
Well, im more a "ctrl c ctrl x " User, so copy something on the Terminal or the SD Card, but i think i can make scrippts...

Also im allready help the community whit my Video Stuff ^^
 
Anything in your user directory should not interfere with updates.
System changes may be reverted on update.

@caps lock led: I am having my cpu usage on it, really useful if some background task goes nuts.
Its not a command anymore btw, modern linux exposes device control file for leds so you can just write 1/0 to it. (or 0-255 if its dimable like on the pyra)
 
Well, im more a "ctrl c ctrl x " User, so copy something on the Terminal or the SD Card, but i think i can make scrippts...
In my terminals at least I need to shift+ctrl-C and shift-ctrl-V to copy and paste. The complication is that shift+ctrl-C in firefox launches something complicated in a bottom bar panel thingy,which slows down my working.


Also im allready help the community whit my Video Stuff ^^
Yes indeed you do. I watch them all, even the German ones, and I don't even speak german well. So I must add my thanks for your work there.
 
  • Like
Reactions: rSl
so i found my old script -rwxr-x--x 1 w w 1.5K Nov 17 2001 ledmail*

turns out it uses the setleds command which... exists on my current system!

So i am now wondering if my script will still work after 20+ years of updates, distro changes, hardware, etc. Still work between Mandrake 7 and Ubuntu 20.10?

Would be very cool....

Well it didn't work out of the box, two changes were needed:
1. correct regex to parse setleds output
2. call it inside a sudo sh. i think the /dev/tty1 permissions have changed over the years or somthing sudo sh -c 'setleds -L +caps < /dev/tty1'

But yes my customisation is workable after many many system updates.

i wholeheartedly give a thumbs up to customizations involving perl. ha ha ha

happy days:

PXL_20220813_095452796.jpg
 

Attachments

  • ledmail.txt
    1.5 KB · Views: 109
Last edited:
To use the lid as a battery indicator:
Code:
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", RUN+="/bin/sh -c 'echo 0 > /sys/class/leds/logo\:green\:bottom/brightness; echo 100 > /sys/class/leds/logo\:red\:bottom/brightness; echo 0 > /sys/class/leds/logo\:blue\:bottom/brightness'"
SUBSYSTEM=="power_supply", ATTR{status}=="Charging", RUN+="/bin/sh -c 'echo 100 > /sys/class/leds/logo\:green\:bottom/brightness; echo 100 > /sys/class/leds/logo\:red\:bottom/brightness; echo 0 > /sys/class/leds/logo\:blue\:bottom/brightness'"


SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[5-9][0-9]", RUN+="/bin/sh -c 'echo $attr{capacity} > /sys/class/leds/logo\:green\:top/brightness; echo 0 > /sys/class/leds/logo\:red\:top/brightness; echo 0 > /sys/class/leds/logo\:blue\:top/brightness'"
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[2-4][0-9]", RUN+="/bin/sh -c 'echo $(($attr{capacity} + 50)) > /sys/class/leds/logo\:green\:top/brightness; echo $(($attr{capacity} + 50))> /sys/class/leds/logo\:red\:top/brightness; echo 0 > /sys/class/leds/logo\:blue\:top/brightness'"
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[01]?[0-9]", RUN+="/bin/sh -c 'echo 0 > /sys/class/leds/logo\:green\:top/brightness; echo $(($att{capacity} + 100)) > /sys/class/leds/logo\:red\:top/brightness; echo 0 > /sys/class/leds/logo\:blue\:top/brightness'"


SUBSYSTEM=="power_supply", ATTR{status}=="Charging", ATTR{capacity}=="[0-4][0-9]", RUN+="/bin/sh -c 'echo 0 > /sys/class/leds/logo\:green\:top/brightness; echo $(($attr{capacity} + 50)) > /sys/class/leds/logo\:red\:top/brightness; echo 0 > /sys/class/leds/logo\:blue\:top/brightness'"
SUBSYSTEM=="power_supply", ATTR{status}=="Charging", ATTR{capacity}=="[5-7][0-9]", RUN+="/bin/sh -c 'echo $(($attr{capacity} + 50)) > /sys/class/leds/logo\:green\:top/brightness; echo $(($attr{capacity} + 50)) > /sys/class/leds/logo\:red\:top/brightness; echo 0 > /sys/class/leds/logo\:blue\:top/brightness'"
SUBSYSTEM=="power_supply", ATTR{status}=="Charging", ATTR{capacity}=="[8-9][0-9]", RUN+="/bin/sh -c 'echo $attr{capacity} > /sys/class/leds/logo\:green\:top/brightness; echo 0 > /sys/class/leds/logo\:red\:top/brightness; echo 0 > /sys/class/leds/logo\:blue\:top/brightness'"
Add this to /lib/udev/rules.d/pyra-charge-led.rules
You could create another file in the same directory, then it wouldn't get overwritten if an update replaces that file.
You'll need to run sudo udevadm control --reload to update the rules.

I haven't tested the low point. Hope it works. It is also very slow to update from plugging in and unplugging. Not sure if that is a udev thing but probably the state of the charging driver.

Summary. Bottom logo will be red discharging, yellow charging.
Discharging, top goes green (99%-50%), yellow (49%-20%) then red.
Charging, top goes red (0-49%), yellow (50%-79%) then green.

Happy to hear comments about whether running multiple commands from a RUN section is ok.
 
Last edited:
so i found my old script
Ooh... Perl. By they way you wrote it, it's before "Modern Perl". Glad I can still read it fluently. Learned that the HEREDOC can be do-ed... interesting form. Props to your own getopts.
I like the more concise
Perl:
$LED = ${$args{'-l'}}[0] || "caps" ;
over your
Perl:
$LED = $args{ -l } ? ${ $args{ -l } }[ 0 ] : "caps" ;


Do you like this more minimal form or do you like defined() more?
Perl:
$LED = $args{ -l }->[0] || "caps" ;


I like the way Perl is a write-any-way-you-like, instead of a write-it-only-this-way. Or the un-assuming way of doing things. You want to read a 1.7GB file into a variable as a string? Sure, why not.
Hope Perl7 makes a good comeback with speeds rivaling Python again, when it was so much slower.
They are now quite equal, it seems: https://programming-language-benchmarks.vercel.app/perl-vs-python
 
Last edited:
By they way you wrote it, it's before "Modern Perl"
this is abuse and violates core forum principles. to gallows with you! oh your refusing..
Hope Perl7 makes a good comeback with speeds rivaling Python again,
perl is faster than python. it's not really a fair comparison because python developers are relative idiots (and mostly actual relatives actually). I did a bubblesort shootout between perl, python, kdb/q and java. perl was #2.
 
Last edited:
How do I apply this script? I found it impossible the way I thought it works:
Do I add the script under the existing script on the file? Do I make a new file and just put the script in? I allready copied the original file to a safe folder, but I can’t edit the file in udev..
 
To edit the file using pluma, you will need to use
Bash:
sudo pluma /lib/udev/rules.d/pyra-charge-led.rules
It might not work if your DISPLAY variable is not set automatically under root. (on my Debian I have kate, and it dies with "Executing Kate with sudo is not possible due to unfixable security vulnerabilities.")
to activate, use "sudo udevadm control --reload" or just reboot.

note of warning: You should put all custom stuff in /etc not in /lib (disclaimer: I don't have a Pyra in my hands to verify this, but if it's Debian, then this rule should apply)
/lib/udev/rules.d/ Contains default rules files. Do not edit these files. /etc/udev/rules.d/*.rules Contains customized rules files. You can modify these files or create them. However, files with identical file names replace each other. Files in /etc have the highest priority and take precedence over files with the same name in /lib.
* make sure the files ends with .rules and not .rules.txt
* there is this udevadm test command, but I'm too noob to give instructions on how to use/test.
 
Last edited:
Ok so this means it’s loads now the unmodified File in etc instead of the modified in lib..
so I should try to modifie the file in etc ..

I allready made the mistake using the file in lib..
 
It’s now looks so when I have the os running, the lid closed and the charging cable in:
47d76d12fac45f31dc81b0f59cfb0f9c.jpg

Yah man! Upside down Rasta Flag... schön!
Post automatically merged:

@pimaster It looks beautiful! (judged by watching @matzesu 's screenshots). Thanks for that code. Will bookmark your post for later.
 
Last edited:
  • Like
Reactions: rSl
I don’t even know if this was just the normal colors or it was because of the scrippt
When I have the Pyra now on the charge whyle the OS is off its only show the Powerbutton LED..
 
Back
Top