Skip to content

Instantly share code, notes, and snippets.

@Jeff-Soares
Last active July 28, 2023 23:51
Show Gist options
  • Save Jeff-Soares/4a5f5ca7f8d67e7b57fa6a34985b8236 to your computer and use it in GitHub Desktop.
Save Jeff-Soares/4a5f5ca7f8d67e7b57fa6a34985b8236 to your computer and use it in GitHub Desktop.
powershell script to change device pixel density and font scale through shortcuts (target: pwsh -command "& 'C:\..\density.ps1' +")
$param = $args[0]
$density_output = adb shell wm density
$matches = ([regex]'\d+').Matches($density_output)
$current_density = [int] $matches[$matches.size - 1].Value
if ($param -eq "-") {
adb shell wm density ($current_density - 50)
} elseif ($param -eq "+") {
adb shell wm density ($current_density + 50)
} else {
adb shell wm density reset
}
$param = $args[0]
$current_font_scale = [float] (adb shell settings get system font_scale)
if ($param -eq "-") {
adb shell settings put system font_scale ($current_font_scale - 0.15)
} elseif ($param -eq "+") {
adb shell settings put system font_scale ($current_font_scale + 0.15)
} else {
adb shell settings put system font_scale 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment