You are not logged in.
Pages: 1
Hey Guys,
i want to run a script each time my computer boots up
problem is since i compiled a new kernel, my screen backlight will go very dark once open-rc starts booting up
i tried the bootloader thing that people suggest on the internet but it only works randomly sometimes
so i wrote this short script that i want to execute with root rights during startup
brightness="/sys/class/backlight/intel_backlight/brightness"
if [[ -f $brightness ]] && [[ "$(cat $brightness)" != "3000" ]]; then
tee $brightness <<< 3000
fi
i tried to add it into /etc/rc.local but that does nothing...
any ideas how to make it work?
Offline
Translate all BASHisms to standard SH because:
$ head -1 /etc/rc.local
#!/bin/sh -e
*๐๐๐๐๐๐!*
Offline
For me that script its fine, so try to guest when and who are running /etc/rc.local
I suggest put something like this on your /etc/rc.local to debug your startup:
date >> /var/log/rc.local.test
if the file its not created, maybe its because /etc/rc.local hasnt execution permissions.
Offline
(yeti@kumari:23)/tmp$ cat -n meep.sh
1 #!/bin/sh -e
2
3 if [[ 1 = 1 ]] ; then
4 echo 'boo!'
5 fi
6
7 tee <<< Moo.
(yeti@kumari:23)/tmp$ ./meep.sh
./meep.sh: 3: ./meep.sh: [[: not found
./meep.sh: 7: ./meep.sh: Syntax error: redirection unexpected
*๐๐๐๐๐๐!*
Offline
Translate all BASHisms to standard SH because:
I tried it with just
brightness="/sys/class/backlight/intel_backlight/brightness"
tee $brightness <<< 3000
but that didn't work, i guess im terrible with SH
anyway i solved the problem by changing the rc.local from #!/bin/sh -e to #!/usr/bin/zsh
thx guys
Offline
Try this:
brightness="/sys/class/backlight/intel_backlight/brightness"
if [ -f $brightness ] && [ "$(cat $brightness)" != "3000" ]; then
echo 3000 > $brightness
fi
Edit: Corrected code error.
Last edited by ilargi (2018-11-15 12:29:35)
Offline
Try...
echo 3000 > $brightness
Such "tee" tricks typically are used because "sudo echo something >somewhere" still does the output redirection as the calling user because the redirection is done before "sudo" is run. "sudo tee somewhere" writes with "root" rights to "somewhere" because "tee" opens "somewhere" and that happens with "root" superpowers due to "sudo". This all does not really matter in "rc.local" because the whole script already runs with "root" rights.
Switching the interpreter of "rc.local" to "/usr/bin/zsh" is not a good idea because "zsh" is not an essential package. System scripts should use "/bin/sh".
But ok: It's your system.
*๐๐๐๐๐๐!*
Offline
Try this:
brightness="/sys/class/backlight/intel_backlight/brightness" if [ -f $brightness ] && [ "$(cat $brightness)" != "3000" ]; then tee $brightness 3000 fi
tee $brightness 3000
...will wait for input instead of writing "3000" to the desired location. And create a file named "3000".
Can you please try your code before publishing it?
*๐๐๐๐๐๐!*
Offline
I stand corrected.
Changed code in original message.
Offline
Changed code in original message.
Thanks!
*๐๐๐๐๐๐!*
Offline
Pages: 1