Hi. This is a question for a rooted Droid /Milestone, but should be applicable to other models as well. I'd like to know if there's a command or any other functionality I can use to "lock" the brightness setting so that other applications can't change it.
I know it's possible, because there's an app in the Market called AdjBrightness (looks like the developer posts here, as well) that is capable of locking it, but I don't quite need all the functionality it provides, and I can't work out how to reverse its home row backlight disabling, which means I ALSO have to run LEDs Hack... I'd like to just write something simple for my specific settings to replace both.
I'm trying to create a very short script I can run with Tasker and set to a widget that will accomplish 3 things: Disable the home row backlights, set the brightness to 2/255, and then "lock" that setting so that other apps can't affect it. I want to run Aldiko for reading in pretty much total darkness, and this is the ideal setting for me.
So far, I can get it set properly using the following:
su
echo 2 > /sys/class/leds/lcd-backlight/brightness
echo 0 > /sys/class/leds/button-backlight/brightness
and with Tasker I can run that as a script and set it to a widget, with another widget to complement it that runs:
su
echo 100 > /sys/class/leds/lcd-backlight/brightness
echo 1 > /sys/class/leds/button-backlight/brightness
which reverses the process and sets everything back to normal.
What I need is to figure out how to lock in that "2" brightness setting, which at this time persists only until some other app affects the brightness. When I run Aldkio, its built-in brightness control feature overrides my setting and lights the thing back up too bright.
So, can this be done with a script? I imagine a chown command that temporarily takes ownership of that function could work, but I'm not smart enough to know how, and I've exhausted Google and the forum search. As I mentioned, this thing would always be run with a complimentary script that could later reverse the chown and give it back to whatever process it ought to belong to... I KNOW it's possible because there's at least one app that does it perfectly; the AdjBrightness setting change persists after I open Aldiko, indeed it persists basically forever; you've got to kill the app or reboot to be able to adjust the brightness with any other means.
Can anyone point me in the right direction?
Bump? Still trying to figure this out.
Bump
Still wondering if there's a way to do this.
+ 1 - if you find a way to lock it via command line, do post back, as will i
i am currently using adjbrightness it to control my button backlights on my dell streak
its great as it locks it on for that session. but after reboot have to manually renable
so i have written an execute entry in tasker to control all or just some of the leds for various notifications
but would love a command line way to lock these as adjbrightness does, i cant find out how its doing that!!!
jdb1981 said:
Hi. This is a question for a rooted Droid /Milestone, but should be applicable to other models as well. I'd like to know if there's a command or any other functionality I can use to "lock" the brightness setting so that other applications can't change it.
I know it's possible, because there's an app in the Market called AdjBrightness (looks like the developer posts here, as well) that is capable of locking it, but I don't quite need all the functionality it provides, and I can't work out how to reverse its home row backlight disabling, which means I ALSO have to run LEDs Hack... I'd like to just write something simple for my specific settings to replace both.
I'm trying to create a very short script I can run with Tasker and set to a widget that will accomplish 3 things: Disable the home row backlights, set the brightness to 2/255, and then "lock" that setting so that other apps can't affect it. I want to run Aldiko for reading in pretty much total darkness, and this is the ideal setting for me.
So far, I can get it set properly using the following:
su
echo 2 > /sys/class/leds/lcd-backlight/brightness
echo 0 > /sys/class/leds/button-backlight/brightness
and with Tasker I can run that as a script and set it to a widget, with another widget to complement it that runs:
su
echo 100 > /sys/class/leds/lcd-backlight/brightness
echo 1 > /sys/class/leds/button-backlight/brightness
which reverses the process and sets everything back to normal.
What I need is to figure out how to lock in that "2" brightness setting, which at this time persists only until some other app affects the brightness. When I run Aldkio, its built-in brightness control feature overrides my setting and lights the thing back up too bright.
So, can this be done with a script? I imagine a chown command that temporarily takes ownership of that function could work, but I'm not smart enough to know how, and I've exhausted Google and the forum search. As I mentioned, this thing would always be run with a complimentary script that could later reverse the chown and give it back to whatever process it ought to belong to... I KNOW it's possible because there's at least one app that does it perfectly; the AdjBrightness setting change persists after I open Aldiko, indeed it persists basically forever; you've got to kill the app or reboot to be able to adjust the brightness with any other means.
Can anyone point me in the right direction?
Click to expand...
Click to collapse
In my device adjbrightness app lock the brightness just by changing the permission of "/sys/.. /brightness" file to 444. So even system can't change the brightness value if requested by any other apps. To unlock the brightness permission of "/sys... /brightness" is restored to previous state, 644.
So in terminal the commands can be "for changing brightness to 2 and lock it"
su
echo 2>/sys/class/leds/lcd-backlight/brightness
chmod 444 /sys/class/leds/lcd-backlight/brightness
"for unlock and restore "
su
chmod 644 /sys/class/leds/lcd-backlight/brightness
echo 100> /sys/class/leds/lcd-backlight/brightness
Same goes for button backlight brightness file
But I found it "not suitable" for my device even with adjbrightness. If I lock brightness using adjbrightness after my screen turns off normally or by using power button , I can't turn it on using power button, so I have to open the battery and reboot the device. Same thing happens if I do it using "commands" or script. So "something" should be done so that the permission of ".. /brightness" file is set to 644 before the screen turns off normally or by other means.And after the screen is on the file permission will be 444 again. I think it may be done using tasker but still don't know how.
Hope someone will help.
Thanks.
Hi
I am not sure why, but I can't turn off screen, with "echo 0 >" into brightness.
It seems that there is some minimum brightness somewhere which I need to configure ?
I really struggle with it.
Any idea how to do that ?
Thanks,
Ranchu
Related
Have you ever tried having your phone lay on a table for some time and when you come back to pick it up, it had almost burned through the table because of the battery heat do to an app running the CPU on a constant 100%?
Or have you tried waking up two hours to late for work, because you alarm did not go off do to the phones battery running dry during the night?
Bad applications or problems with some back-end processes is a problem for most people. To get some help with this problem, I have been running the Watchdog app for the last 3 years. It is a great application that will alert you whenever an app or a process is running wild in the background. However there is one issue with this app. It only alerts you when there is a problem. This does not help much if you are to far away from the phone, if your phone is in silent mode or if you are sleeping.
I wrote the developer of the app to see if there was any plans for making a tasker plug-in so that profiles can be made to handle this. I have yet to get an answer. In the mean time, I have made a complete watchdog profile for tasker that does what the watchdog app does, only this profile will auto terminate any wild processes if the screen is turned off. If the screen is on, it will to what the watchdog app does and alert you of the problem. It could be that you was playing a game or running a benchmark, so auto terminate while the screen is on, would not be a good idea.
The profile however, will drain more battery than the watchdog app does. Because of this I have set the check interval for 15 minutes instead of the 5 minutes I used on the app. This reduces the drain to about the same amount.
And to save even more power, I have included a Data control profile that will turn off data/wifi/sync when the screen is off, as long as you are not connected to a power source or if you are downloading, uploading or streaming. In this case the profile will wait until this state changes before turning off anything. And while off, tasker will alow sync (email and such) once every 15 minutes.
Both profiles is included in the attached download below.
Important!
The watchdog profile will need a proper busybox installed with proper symlinks for sed, grep and awk. It will also need a toolbox that supports top and ps with arguments.
You can run the update script from the Busybox Installer thread to make sure that your phone will work with this profile.
Changelog (2012-11-18)
Reduced the time from where the screen turns off, to the time Data/Sync is disabled
Data/Sync will now turn back on when the screen is unlocked rather than turned on. No need to waste power if you just want to check the time or notifications (Which can be done from lock screen in Android 4.x)
Fixed the 15 minutes data check when the screen is off. It only executed once after the screen was turned off
_______________________
Wow! Your watchdog implementation looks great! Will adopt it on my phone over the weekend.
Now I have only one battery-drain-controlling dream left - being able to find out the apps holding the wakelock for too long to kill them automatically. The reason for this is that sometimes I find battery drain to go from usual 1% per hour to 10% per hour just because some badly written app has not released the wakelock.
Alte.78 said:
Wow! Your watchdog implementation looks great! Will adopt it on my phone over the weekend.
Now I have only one battery-drain-controlling dream left - being able to find out the apps holding the wakelock for too long to kill them automatically. The reason for this is that sometimes I find battery drain to go from usual 1% per hour to 10% per hour just because some badly written app has not released the wakelock.
Click to expand...
Click to collapse
Are you talking about BetterBatteryStats? I know that it tells you exactly how long since a point in time (which can be manually customized) that certain programs/tasks hold wakelocks.
But not sure about any kind of specific stratification that displays only programs that hold the lock too long to kill them automatically (assuming that's what you are wanting?).
And OP, these sound great - I'm importing them as we speak :highfive:
dk_zero-cool said:
Important!
The watchdog profile will need a proper busybox installed with proper symlinks for sed, grep and awk. It will also need a toolbox that supports top and ps with arguments.
_______________________
Click to expand...
Click to collapse
I got all excited when reading about this until I read the Important section. After watchdog everything started getting confusing . I know I read somewhere about busybox but the other terms are all new to me...could someone explain it with a little more details on what I have to get/set up in order for this to work??
2am said:
I got all excited when reading about this until I read the Important section. After watchdog everything started getting confusing . I know I read somewhere about busybox but the other terms are all new to me...could someone explain it with a little more details on what I have to get/set up in order for this to work??
Click to expand...
Click to collapse
The profile is using some linux commands to get a list of all current processes and their CPU usage. These commands needs to be available in order for the profile to work.
If you are using a custom ROM, then you are most likely to have all what is needed. Especially if you are using a more current custom ROM.
In order to test this, download a terminal app or enter an ADB shell (Hope you know what this is) and see if the command line
Code:
top -n 1 | sed -e 1,7d | grep -e '[0-9]\+%' | awk '{print $3}'
returns anything. If it does (Except errors), then you will have all that is needed.
Alternatively you could check my Better Busybox Integration thread which will make sure that your phone is setup to work with this.
dk_zero-cool said:
The profile is using some linux commands to get a list of all current processes and their CPU usage. These commands needs to be available in order for the profile to work.
If you are using a custom ROM, then you are most likely to have all what is needed. Especially if you are using a more current custom ROM.
In order to test this, download a terminal app or enter an ADB shell (Hope you know what this is) and see if the command line
Code:
top -n 1 | sed -e 1,7d | grep -e '[0-9]\+%' | awk '{print $3}'
returns anything. If it does (Except errors), then you will have all that is needed.
Alternatively you could check my Better Busybox Integration thread which will make sure that your phone is setup to work with this.
Click to expand...
Click to collapse
well I entered that command and got
invalid argument "-n". and then a bunch of other lines after that...and I checked your other thread and there's even more code language ...ugh, I think this is one of those threads that I need to leave alone because it's too much for me to handle...sucks too cause your set up sounds really awesome...thanx for trying to help me though
2am said:
well I entered that command and got
invalid argument "-n". and then a bunch of other lines after that...and I checked your other thread and there's even more code language ...ugh, I think this is one of those threads that I need to leave alone because it's too much for me to handle...sucks too cause your set up sounds really awesome...thanx for trying to help me though
Click to expand...
Click to collapse
I will make a more simple command fix for you tomorrow that will make your phone work with this without having you enter any code.
dk_zero-cool said:
I will make a more simple command fix for you tomorrow that will make your phone work with this without having you enter any code.
Click to expand...
Click to collapse
ah thank you soo much!!!
2am said:
ah thank you soo much!!!
Click to expand...
Click to collapse
I have updated the Busybox Installer script to make sure that it will work on newer devices other than MTD, and I have added a custom toolbox binary that will contain the proper options for these profiles.
Just check the first post at the buttom in the Important section. Fallow the link, download the installer and run it in your recovery. After that you can import the profiles from this thread into your Tasker application.
I created a simple Python script that brings up a menu to select different brightness levels by way of opening up the /sys/class/leds/backlight/brightness file and writes whatever value that you want to set the level at. An example would be 255 would be the max brightness and of course 1 would be almost no light. I like using this script because it allows me to set the brightness way lower than the stock lowest without use of an app like Screen Filter. There's a couple other scripts I wrote for toggling the keyboard and soft button leds too and I have the same issue with them.
This script will only work if I beforehand goto that specific file in Root Explorer and enable the read and write permissions for Others. Once I reboot the device though, those are always reset to disabled. If I run the script without enabling these of course I'll get a permission denied error.
How would I go about making those settings stick? I'm thinking I might have to incorporate some Java somewhere in the Python to do this but I'm not sure. I haven't learned Java yet
Can anyone give me some advice or some kind of direction? I will greatly appreciate any help and will thank you with hitting the Thanks button
you can write a start-up script that will chmod the file/s when the device is turned on.
chevyowner said:
you can write a start-up script that will chmod the file/s when the device is turned on.
Click to expand...
Click to collapse
Thanks so much for your advice....now I can kill two birds with one stone....not only will I achieve my objective but also learn some about those other scripts you speak of
Please note, you do these at your own risk, I am not responsible for anything breaking!!
Set your wallpaper to an all black wallpaper, this will save your battery some-what. Turn on adaptive brightness THEN turn your screen brightness all the way down. Turn on battery saver. Enable "DND" and set it to complete silence, you'll still get calls and texts. If you're rooted and want to change your display dentisy, do this:
*needs to be rooted*
Download build prop editor from the play store, grant permissions with SuperSU, edit, go to the bottom of the list and add this:
ro.sf.lcd_density=380
Save the file, close the app, open the app and reboot. Congratulations, your DPI has now been changed.
Go in to your sound and disable all sound in other, change your ring tone and notification to none. Disable sound for media, notification and ring tone.
Enable developer options, turn ON HW overlay. disable all animations to 0. Show all ANR's and background processes to no background apps.
Download BBS FROM HERE (XDA) and wakelock detector, you'll see what is consuming your battery. AMPERE will also tell you your charge rate and discharge rate, very good app.
Go in to your apps, disable everything you're not going to use, movies, music etc. BLOCK notifications for apps you don't want. change your permissions on your apps if you wish to do so.
You can check your battery's capacity with "kernel auditor" and you can underclock your CPU thus saving battery and it doesn't really effect performance.
Turn off vibration, disable account auto syncing, disable now on tap, go in to your Google settings, security and disable all, phone search and disable all. Date and time, disable automatic date and time, set to NOT 24 hours time display.
If you want to root:
Boot TWRP from here:
https://twrp.me/devices/motorolamotog2016.html
Make sure you have your Motorola drivers if you're on windows and fastboot, if you're on Linux (which I am) do this:
"sudo apt-get install android-tools-adb android-tools-fastboot"
You have developer options enabled, enable USB debugging and accept on your phone for auth.
BOOT in to twrp:
adb reboot bootloader
fastboot boot yourdir/twrp-3.0.2-0-athene.img
Wipe your phone, MAKE SURE to have a backup. Create your SuperSU file:
TWRP > Advanced > Terminal and type: "echo "SYSTEMLESS=true" > /data/.supersu" HIT enter, go to: TWRP > Advanced > File Manager and look for your SuperSU file.
Install your SuperSU Stable from here:
https://download.chainfire.eu/969/SuperSU/UPDATE-SuperSU-v2.76-20160630161323.zip
Make sure it's on your SDCARD. install. Nice, you're rooted.
If you want to install A CUSTOM kernel, download here:
http://forum.xda-developers.com/moto-g4-plus/development/kernel-elementalx-g4-0-01-t3424836
MAKE SURE it's on your SD card, install. nice.
*!!you will lose your official status!!*
Post your tips and tricks here.
*ROOTING is systemless, you will not lost your official status. IF you install the kernel, your official status will BE GONE!!!!*
bwoiisc0tty said:
Set your wallpaper to an all black wallpaper, this will save your battery some-what. Turn on adaptive brightness THEN turn your screen brightness all the way down.
Click to expand...
Click to collapse
I disagree with this. We have an IPS LCD display. Which means that keeping a black screen INCREASES power consumption, because of the way LCD screens work. This would work wonders for an LED screen, but for our phone, keep the colour towards the whiter sides & keep the brightness low.
Buying 15000rs (225$) and you are telling us to disable all the features and not to use..Should I laugh or ignore ? This is not the right way to tell tricks & tips.
#chill
When i try to change my DPI to 380 or 400....
It breaks my camera...
Camera becomes non-responsive, en doesn't give an image anymore....
Only way to fix it again is to do a restore of my ROM.
coolhead said:
When i try to change my DPI to 380 or 400....
It breaks my camera...
Camera becomes non-responsive, en doesn't give an image anymore....
Only way to fix it again is to do a restore of my ROM.
Click to expand...
Click to collapse
Working fine with 400dpi, non rooted device
Sent from my Moto G (4) using XDA-Developers mobile app
I agree that a black background helps on the MotoX 1st gen that has OLED screen, but will not do anything for our LCD screen.
As for keeping at the minimum the apps that run in background, that's good advice. Everyone can decide if those aps are important to them.
I ran diffchecker on the adb system settings output with force 90hz enabled and disabled, and found the setting that switches when you activate "force 90Hz" in the developer settings: "min_refresh_rate=90.0". If you're rooted you can set that with Tasker based on whatever conditions you want, using the shell command function. The code to activate it is "settings put global min_refresh_rate 90.0", and the code to deactivate is "settings delete global min_refresh_rate" (both need "use root" ticked). I've been testing having it triggered on my phone when I'm connected to my home wifi and ambient light is < 15. The home wifi condition is so I don't run into big battery drains when I'm out late at night, and I'm using ambient light rather than screen brightness because as someone pointed out in a Reddit thread, Smooth Display will still run under 75% screen brightness under certain ambient lighting conditions. So far, battery is definitely taking a hit, but it's not a big deal when I'm home and chargers are in easy reach.
tardis_42 said:
I ran diffchecker on the adb system settings output with force 90hz enabled and disabled, and found the setting that switches when you activate "force 90Hz" in the developer settings: "min_refresh_rate=90.0". If you're rooted you can set that with Tasker based on whatever conditions you want, using the shell command function. The code to activate it is "settings put global min_refresh_rate 90.0", and the code to deactivate is "settings delete global min_refresh_rate" (both need "use root" ticked). I've been testing having it triggered on my phone when I'm connected to my home wifi and ambient light is < 15. The home wifi condition is so I don't run into big battery drains when I'm out late at night, and I'm using ambient light rather than screen brightness because as someone pointed out in a Reddit thread, Smooth Display will still run under 75% screen brightness under certain ambient lighting conditions. So far, battery is definitely taking a hit, but it's not a big deal when I'm home and chargers are in easy reach.
Click to expand...
Click to collapse
This is handy, thank you! Quick question though, how do you run an adb system settings output to see the difference when you switch other settings?
TheBobMiller said:
This is handy, thank you! Quick question though, how do you run an adb system settings output to see the difference when you switch other settings?
Click to expand...
Click to collapse
Assuming you have adb running and connecting to your phone fine already, it's pretty easy. Enter adb shell, then run three commands: "settings list global", "settings list system", and "settings list secure". Open up diffchecker.com and copy the results from the shell into one side. Change whatever setting you're interested in on your phone, then run these commands again and copy the output into the other side of the diffchecker window. It'll show you anywhere the output has changed, and that should be your setting - although there might be a couple other differences flagged, eg I think system uptime is in there somewhere.
tardis_42 said:
Assuming you have adb running and connecting to your phone fine already, it's pretty easy. Enter adb shell, then run three commands: "settings list global", "settings list system", and "settings list secure". Open up diffchecker.com and copy the results from the shell into one side. Change whatever setting you're interested in on your phone, then run these commands again and copy the output into the other side of the diffchecker window. It'll show you anywhere the output has changed, and that should be your setting - although there might be a couple other differences flagged, eg I think system uptime is in there somewhere.
Click to expand...
Click to collapse
Thank you so much! I'm not sure how I never knew this but being an avid Tasker user, I should've known this by now. This is gonna really come in so useful for me! Thank you!
How did you find this script <min_refresh_rate> ? Do you max to lock the maximum fps would be <max_refresh_rate>?
Small change to the command; in Android 11 beta 2.5, you have to use "settings put system min_refresh_rate 90.0". Changing the global flag does nothing to the frame rate anymore but changing the system value can force 90hz, even if you have smooth display turned off.
Trixter313 said:
Small change to the command; in Android 11 beta 2.5, you have to use "settings put system min_refresh_rate 90.0". Changing the global flag does nothing to the frame rate anymore but changing the system value can force 90hz, even if you have smooth display turned off.
Click to expand...
Click to collapse
Thank you!
I have been looking for this since beta 2 came out ?
Hi.
I come with a problem that I encountered with my Samsung Galaxy S7 G930F. The problem is that when I set the brightness to 100% and lock the phone, after unlocking it, it sets the brightness to the minimum, but the brightness bar remains at 100%. I did some digging in the files and found a file called "max_brightness" in the "/sys/class/backlight/panel/" directory. Sooo... i launched ADB and typed the following commands:
adb shell
su
cat "/sys/class/backlight/panel/max_brightness"
To my surprise, I got "365" value. I tried to change the value in this file to 255 with "echo 255> / sys / class / backlight / panel / max_brightness", but after executing it nothing happens and the value itself remains unchanged.
I think that changing this value can fix this error, unless someone has a better idea, then please give it below, I will gladly try it, because this error irritates me every time i change the brightness and lock my device.
EDIT: I forgot mention, that i use Havoc-OS v3.7.
Regards!
Perhaps you have auto brightness turned on or some other feature that uses phone sensors, regardless of them, the file you're checking has nothing to do with what you're facing.
This file is inside the Kernel, which means it's value is already specified (as you found it to be 365), and you can't normally change it's value, and definitely not permanently with your current steps.
I'll highlight you a few points:
Any file does have permissions, these permissions controls who can do what to/with the file, and there are owners, these are the users who can do what they actually want to the file. So when you can't change a file's value, you probably don't have the write permission.
SELinux can actually prevent you from modifying a lot of stuff, specially these kernel parameters, so you should set enforce to 0 if you want to have a wider range of freedom.
Using init.rc scripts can be quite helpful in your current situation, all you have to do is set permission, and write the value, and it will be applied when you reboot. (don't forget the selinux state)
I don't understand why you tried 255? as far as I know, that's for color range such as RGB and so ... P.S. that 365 value is your Screen's maximum brightness, the maximum it can get, if you lowered it, it'll seem really dim next time you set brightness to max. Your current brightness is in some other file.
The right way to change a value of such a file is by executing:
Code:
su
setenforce 0
chmod 0644 /sys/class/backlight/panel/max_brightness
echo "255" > /sys/class/backlight/panel/max_brightness
You should report a bug to the ROM developer, either by Forum, DM, or Telegram.