permalink: spells/use-unsupported-display-resolutions-with-samsung-dex
tags:
- HowTo
- OS/Android
- Application/SamsungDeX
- Application/GoodLock
- Application/ADBThe options below are known to work on Android 14 / Samsung One UI 6.
Samsung DeX (the desktop mode available on higher-end Samsun Android smartphones) can be used with a limited number of (fairly standard) resolutions out-of-the-box. It is possible to use DeX with other resolutions however.
Samsung provides a application, Good Lock, that unlocks a number of customizations for Samsung's version of Android. The MultiStar plugin can be used to enable additional display resolutions under DeX by turning on I ❤️ Samsun DeX > High resolutions for external displays.
The resolutions unlocked by Good Lock will work on the vast majority of modern display. However, occasionally you may want to use a monitor with an "oddball" resolution (like the 2240 x 1400 resolution used by the Lenovo ThinkVision M14d). The Android Debugging Bridge (adb) utility can be used in many of these cases.
pkg install android-toolsadb pair localhost:$PAIRING_PORT.adb connect localhost:$DEBUGGING_PORTadb shell wm size 2240x1400 -d 2adb disconnectIn general, the Android phone itself will use display 0. To determine the number of the external display, you can output the current resolution of a display using adb shell wm size -d #, where # is 0, 1, 2, ...
The display resolution set with adb shell wm size will stick until either a new display resolution is set using adb, adb shell wm size reset -d2 (or whatever the correct display number) is run, or until a new resolution is manually chosen in the Settings app under Samsun DeX > Display resolution.
The script below should (perhaps with minor modifications) automatically set DeX's resolution to the optimal one for your external monitor.
android-tools, and then pair (your local) adb with your (local) device using the steps described above in "Initial setup".adb shell pm grant com.termux android.permission.READ_LOGSAdapted from Set max resolution for external displays Tasker task.
#!/usr/bin/env bash
DISPLAY_NAME="HDMI Screen"
DISPLAY_NUMBER=2
# Exit on error
set -e
# Get local adb port
PORT=$(logcat -d | grep 'adbwifi' | tail -n 1 | sed 's/.* //')
# Locally connect to the wireless debugging port
adb connect localhost:$PORT
# Get the connected display's highest resolution
DISPLAY_RESOLUTION="$(adb shell dumpsys display | grep -m 1 "$DISPLAY_NAME" | awk -F' |=' '/width/ && /height/ {for(i=1;i<=NF;i++) if($i=="width") print $(i+1) "x" $(i+3)}' | tr -d ',' | sort -nr -k1,1 -k2,2 | head -n 1)"
# Set the resolution for DeX
adb shell wm size $DISPLAY_RESOLUTION -d $DISPLAY_NUMBER
# Disconnect adb
adb disconnect
# Notify the user
MESSAGE="$DISPLAY_NAME ($DISPLAY_NUMBER) set to $DISPLAY_RESOLUTION"
if [[ $(which termux-notification | wc -l) -gt 0 ]]; then
termux-notification --icon monitor --title "Samsung DeX" --content "$MESSAGE"
fi
echo "$MESSAGE"
This will (often) generate a popup asking you to confirm log access when run.
There is unfortunately no way to enable local adb in non-rooted devices without a WiFi connection.
On-screen text will sometimes look terrible after switching resolutions for some combinations of cables/monitors, even when the same device/cable/monitor works fine on a different combination!