Change screen brightness by hour
Forum rules
Porteus Kiosk section of the forum is unmaintained now. Its kept in a 'read only' mode for archival purposes.
Please use the kiosk contact page for directing your queries: https://porteus-kiosk.org/contact.html
Porteus Kiosk section of the forum is unmaintained now. Its kept in a 'read only' mode for archival purposes.
Please use the kiosk contact page for directing your queries: https://porteus-kiosk.org/contact.html
Change screen brightness by hour
How to change screen brightness by hour?
For as an example one would like the screen have 100 brightness 10:00 and dim it after 20:00 to 75%
Kind regards,
Jan
For as an example one would like the screen have 100 brightness 10:00 and dim it after 20:00 to 75%
Kind regards,
Jan
-
- Black ninja
- Posts: 75
- Joined: 28 Oct 2017, 13:40
- Distribution: 4.0 XFCE, Manjaro
- Location: .bay.de
Change screen brightness by hour
Screen brightness can be set by pushing a value to a specific file, you may need to look up how your device is named, for me its "amdgpu_bl0".
you can write a short script that pushes a value depending on daytime and let this script execute by a cron job every 15 minutes or whatever you need. i can provide a small sample script later if you need
Code: Select all
/sys/class/backlight/<your_device>/brightness
Change screen brightness by hour
" i can provide a small sample script later if you need"
Yes please, send example.
How to obtain the device screen name? Is there a common alias (for the primary screen) that could be used directly?
Kind regads,
Jan
Yes please, send example.
How to obtain the device screen name? Is there a common alias (for the primary screen) that could be used directly?
Kind regads,
Jan
- fanthom
- Moderator Team
- Posts: 5667
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Change screen brightness by hour
Once you figure out the script part you may program cron as described here:
http://porteus-kiosk.org/faq.html#22
http://porteus-kiosk.org/faq.html#22
Please add [Solved] to your thread title if the solution was found.
-
- Black ninja
- Posts: 75
- Joined: 28 Oct 2017, 13:40
- Distribution: 4.0 XFCE, Manjaro
- Location: .bay.de
Change screen brightness by hour
A very short sample script could look like this:
You need to replace the hours and brightness values to something that matches your need.
Instead of directly tee-ing to a specified file, you could enumerate through the directories in /sys/class/backlight/ and set it for all displays. If i have time later i will add this to the script.
Code: Select all
#!/bin/bash
HOUR=`date +%H`
# replace the values with the hours you want to change the brightness
# for easier comparing we use the 24-hours-scheme
if (( $HOUR < 8 )) || (( $HOUR > 13 )); then
# replace with the required brightness value
BRIGHT=50
else
# replace with the required brightness value
BRIGHT=100
fi
# replace "radeon_bl0" with the corresponding dir on your system
echo $BRIGHT | tee /sys/class/backlight/radeon_bl0/brightness
Instead of directly tee-ing to a specified file, you could enumerate through the directories in /sys/class/backlight/ and set it for all displays. If i have time later i will add this to the script.
Change screen brightness by hour
Thanks!
Yes, would be very nice to have the script to enumerate through the directories in /sys/class/backlight/
Kind regards,
Jan
Yes, would be very nice to have the script to enumerate through the directories in /sys/class/backlight/
Kind regards,
Jan
Change screen brightness by hour
Hi.fanthom wrote: ↑06 Sep 2018, 18:23Once you figure out the script part you may program cron as described here:
http://porteus-kiosk.org/faq.html#22
Is there any other way to inject the script to cron?
Can it be loaded and included to Porteus Kiosk thru run_command and wget?
Kind regards,
Jan
- fanthom
- Moderator Team
- Posts: 5667
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Change screen brightness by hour
"Can it be loaded and included to Porteus Kiosk thru run_command and wget?"
I believe you could download and replace whole /etc/crontab file with 'run_command='.
Let us know if this method works so i'll update the FAQ.
I believe you could download and replace whole /etc/crontab file with 'run_command='.
Let us know if this method works so i'll update the FAQ.
Please add [Solved] to your thread title if the solution was found.
Change screen brightness by hour
Any help such as exact commands would be helpful.
Thanks
I assume I have to put something like this to run_command=
Kind regards,
Jan
Thanks
I assume I have to put something like this to run_command=
Code: Select all
wget https://domain.com/files/script.sh -O /home/script.sh; chown -R 1000:1000 /home/script.sh; chmod +X /home/script.sh; echo '* * * * * root su - -c "/home/script.sh" ' >> /etc/crontab;
Jan
Change screen brightness by hour
That seems not working, any thoughts?
- fanthom
- Moderator Team
- Posts: 5667
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Change screen brightness by hour
I though you want to update crontab file.
Anyway - this is enough to run the script:
Mind it will be executed by root every minute.
Also - its better to download files to /opt as /home may be refreshed (depends on your persistence level).
Anyway - this is enough to run the script:
Code: Select all
wget https://domain.com/files/script.sh -O /home/script.sh; echo '* * * * * root su - -c "sh /home/script.sh"' >> /etc/crontab;
Also - its better to download files to /opt as /home may be refreshed (depends on your persistence level).
Please add [Solved] to your thread title if the solution was found.
Change screen brightness by hour
Hi. Thanks!
The executing seems to work, but I think permissions (and owner?) should be changed for /sys/class/backlight/ to be able to read and modify the brightness file?
The executing seems to work, but I think permissions (and owner?) should be changed for /sys/class/backlight/ to be able to read and modify the brightness file?
- fanthom
- Moderator Team
- Posts: 5667
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Change screen brightness by hour
With this configuration:
You have instructed the cron to run the command as root.
You may add following line to your script to confirm this:
Code: Select all
* * * * * root
You may add following line to your script to confirm this:
Code: Select all
whoami >> /opt/script.log
Please add [Solved] to your thread title if the solution was found.
Change screen brightness by hour
Thanks!
Found out that there was a missing $-sign in my script and there were some other issues too..
Now finally got it up and running!
Kind regards,
Jan
Found out that there was a missing $-sign in my script and there were some other issues too..
Now finally got it up and running!
Kind regards,
Jan
Last edited by jet on 20 Sep 2018, 12:05, edited 2 times in total.
Change screen brightness by hour
Hi.
How to close and restart the browser (Chrome) from a script?
How to close and restart the browser (Chrome) from a script?