-
-
Save sharunkumar/ca2cd57936e4bac974578d1e8a6b3cf6 to your computer and use it in GitHub Desktop.
@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 |
null keyboard shouldn't be running as your main keyboard the first time you launch scrcpy
yeah, when I wrote the script, my main keyboard would just be a keyboard other than the null keyboard, and it would save that info before setting it to null keyboard.
honestly though it's been a while since I've used this script myself hah. but nice to know that people are still using it 😁
writing your scrcpy commands right next to "call scrcpy"
if you mean command line parameters which you want to pass to scrcpy, yes, that's where you would put them. call scrcpy
is the line where the actual binary is called, and when the executable closes, the restore command block is called, restoring all the settings
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
also if anyone wants to know how to add scrcpy commands to your batch file alongside this script, i found that writing your scrcpy commands right next to "call scrcpy" (the one without anything next to it) makes it to where the script actually works and still keeps your scrcpy settings. i'm not sure if this is meant to be how it works, i'm not a coder. but it worked!