Bash script to reconfigure the screen orientation when entering or exiting tablet mode
Good

I like most of what you've done so far as is:


Using [[ (double square brackets) for conditionals is a good practice.
Using $() for command substitution instead of the classic backticks is also a good modern shell practice.
Most of your variable substitutions are quoted.  This is a good habit in case the variable contains spaces it won't get broken up by shell parsing.


Could be better

There are some minor things I'd improve:


include the #! line at the top
typically you see folks add their thens to the end of the previous line like if [[ cond ]]; then.  Your outer loop could also be done as while true; do.
the comment gets sort of lost out on the right.  Why not put it on the line above?


Think about

The script is getting invoked every second and chewing up some amount of CPU.  There's probably not much CPU being burned in this case, but one thing to consider is whether this sort of polling could be avoided.  Linux includes inotify as a function to let processes known when a file has changed so they don't have to constantly check the file themselves.  This is available in the shell through inotifywait.  If the file you're checking works with inotifywait you could avoid the sleep.

A bonus you get beyond conserving CPU from skipping sleep is that the script should run with lower latency.  Instead of needing to wait for up to a second to detect the change your script would be invoked within a small fraction of a second.