Last active
July 12, 2024 23:37
-
-
Save sharunkumar/ca2cd57936e4bac974578d1e8a6b3cf6 to your computer and use it in GitHub Desktop.
Windows wrapper batch file for disabling keyboard and setting brightness before using scrcpy to connect. Settings are restores after scrcpy disconnects. Based on script by Volodymyr Shymanskyy. https://gist.github.com/vshymanskyy/a44ff7af2848653e91f269910cb9d50f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| rem Requires Null Keyboard https://play.google.com/store/apps/details?id=com.wparam.nullkeyboard | |
| rem Author: Sharun Kumar | |
| setlocal ENABLEDELAYEDEXPANSION | |
| for /F %%i in ('adb shell settings get system screen_brightness') do set brightness=%%i | |
| for /F %%i in ('adb shell settings get secure default_input_method') do set ime=%%i | |
| for /F "tokens=1,2,3,4,5,6,7,8" %%G in ('adb shell media volume --get') do ( | |
| set vol=%%J | |
| set volrange=%%M | |
| ) | |
| for /F "tokens=1,2,3,4,5,6,7,8 delims=[.]" %%G in ("!volrange!") do ( | |
| set volmin=%%G | |
| set volmax=%%H | |
| ) | |
| call :Setup | |
| call scrcpy | |
| call :Restore | |
| goto :EOF | |
| :Setup | |
| echo setting up | |
| echo current brightness is !brightness! | |
| echo current ime is !ime! | |
| echo current volume is !vol! in range !volmin! to !volmax! | |
| rem Wakeup to process commands faster | |
| adb shell input keyevent KEYCODE_WAKEUP | |
| rem Always-on screen | |
| adb shell svc power stayon usb | |
| rem Set brightness | |
| adb shell settings put system screen_brightness_mode 0 | |
| adb shell settings put system screen_brightness 0 | |
| rem Disable Keyboard | |
| adb shell ime set com.wparam.nullkeyboard/.NullKeyboard | |
| rem Show Touches | |
| adb shell settings put system show_touches 1 | |
| rem Set Max Volume | |
| adb shell media volume --set !volmax! | |
| goto :EOF | |
| :Restore | |
| echo restoring settings... | |
| adb shell svc power stayon false | |
| adb shell settings put system screen_brightness_mode 1 | |
| adb shell settings put system screen_brightness !brightness! | |
| adb shell ime set !ime! | |
| adb shell settings put system show_touches 0 | |
| adb shell media volume --set !vol! | |
| goto :EOF |
Author
Author
honestly though if I were to use the script now, I would just re-write it to PowerShell, which is a lot more readable and maintainable
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you mean command line parameters which you want to pass to scrcpy, yes, that's where you would put them.
call scrcpyis the line where the actual binary is called, and when the executable closes, the restore command block is called, restoring all the settings