Edit : This post describe how to run arbitrary scrip, with root-user system commands, launched from a graphical desk widget.
This being said, to reach this specific goal (turn the screen upside-down), I prefer the solution hinted by Paul in its 1st reply, even if it’s way more difficult to install GravityBox than to write a one-liner script. GravityBox (for whom like detailed settings) is great.
I recently bought a car cradle for my FP2, to help reading the screen when following the GPS (OSMand~).
It appeared that when in this support and fixation item, the USB port of the phone was not available anymore to keep it powered.
I though : ok, just turn the phone 180° before to put it in the cradle ; but Android accepts to turn the screen orientation in every direction except this one, it’s a software limitation, hardcoded somewhere, you’re not allowed to use the phone with the ear-speaker at the bottom and the might-existing hardware buttons on top (I read somewhere).
I don’t like artificial limitations… Being root on the phone, I learnt that you can temporarily force the screen orientation to the fixed position of your choice (here portrait, upside down) using this command:
settings put system user_rotation 2
Ok but it’s not so convenient to type this command each time you start your car engine…
After some tries I found that turning this command into shell script, ran through Termux, may help in the process: vi upside-down.sh
su 0 settings put system user_rotation 2
Here, and despite the versions of man I found for the unix
su command, you have to specify that you want to become the
0 user (so root) and then write the command to be executed (not using the
-c option switch…).
To get it really convenient, Termux offers a Termux-widget complementary app, which allows to display a list of the scripts present in
$HOME/.shortcuts/ as an Android desktop widget.
So here we are, before starting your car engine you now just have to click on the upside-down.sh script, and grant the SuperUser privilege, to have OSMand~ working upside down, and keep the phone plugged into a cradle (or using an external soundcard…).
(Still, a question I have is : why does Termux-widget needs so much permission to work ? If someone knows ?)