this post was submitted on 08 Dec 2024
13 points (93.3% liked)
Android
9407 readers
1 users here now
A place to discuss anything related to Android or Android adjacent.
INFO:
-
No attacking others based on their phone preferences. Criticizing OEMs/devices is allowed. Attacking users because a different brand/device works for them isn't.
-
Obvious spam will be removed.
-
Anything directly or indirectly related to Android is allowed.
Check Out Our Partner Communities:
founded 4 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
*edit: it was late and I was throwing ideas. I made a solution that actually works in another comment.
I'm thinking you could have separate color profiles with a script that to change the file using symbolic link?
(I don't know what I'm doing, I'm a figure it out as I go type, but maybe it'll work. Please help!)
You'd need something like shizuku (allows shell operation permission) or root to be able to read the system dark mode status.
Using shizuku you could call it by
rish -c 'cmd uimode night'
Which would show
Night mode: yes / no
If you did that you could us an
if
statement (I don't really know how to write that out confidently at the moment)And use that fuction to change the symbolic link to the color.properties file instead of the
at
a specific time I used below.So you keep 2 (or more) color profiles in separate files and call those locations to link to based on time of day / uimode.
You could put the script in the .boot (to automatically start) or .shortcut (to start with the widget) Or maybe add the command to run the script in the termux bash_bashrc or profile file to have it execute on each session launch.
#!/bin/sh
at 1200 #noon
ln -sf [/path/to/new_file] ~/.termux/color.properties
at 1900 #7pm
ln -sf [/path/to/new_file] ~/.termux/color.properties
I personally do not use shizuku because i reboot my system a lot and i do not have wifi connection to setup it again just using phone.
But this solution helps with most part of problem, i can configure bash to check time, if it is 2000 to 7000 use dark theme otherwise light theme.
If i can somehow get current system theme without root/adb, it will be better.
Anyway, thanks for help. I will use this setup for now ☺️
Trying various methods without adb/shizuku give:
Exception occurred while executing 'night':
java.lang.SecurityException: getNightModeCustomType requires MODIFY_DAY_NIGHT_MODE permission
cmd uimode gives the options but executing any options ends in error.
Anything beyond that is beyond me.
But, maybe this can help if you want to do the real programming stuff I can't
https://stackoverflow.com/questions/44170028/android-how-to-detect-if-night-mode-is-on-when-using-appcompatdelegate-mode-ni#44170179
Another thing I think might be needed is to add a line to reload termux.properties I created an alias because the command is so long. trs=termux-reload-settings