To run a game on my Nexus 5 (5.1), I need to change my screen resolution. I'm trying to write a shell script that will detect the current resolution and change it, basically a toggle.

I know that I can actually change the resolution using wm size XXXXxYYYY, but I don't know how I can check the current resolution. I know very, very little about regex, and I tried to figure out how to pull the results from dumpsys display, but I really had no idea what to do.

How can I get the current screen resolution for a shell script that will use if to check it, like a toggle?


you nearly answered your question already. wm size shows you the current resolution.

Saving the output of the screen reoslution into a shell variable: A=$(wm size | busybox cut -c16-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.