summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/fix-dpi21
1 files changed, 20 insertions, 1 deletions
diff --git a/.local/bin/fix-dpi b/.local/bin/fix-dpi
index b700ea9..afcb4a1 100755
--- a/.local/bin/fix-dpi
+++ b/.local/bin/fix-dpi
@@ -45,14 +45,18 @@ usage() {
printf ' --render-dpi=<auto|auto-hwonly|DPI|XDPIxYDPI>\n'
printf ' Specify what DPI applications should render\n'
printf ' at (default: auto)\n'
+ printf ' --device-dpi=OUTPUT=<DPI|XDPIxYDPI>\n'
+ printf ' Override the hardware-reported DPI for'
+ printf ' the X11 output OUTPUT\n'
}
set -euE -o pipefail
-args=$(getopt -n "${0##*/}" -o 'hn' -l 'help,dry-run,render-dpi:' -- "$@") || errusage
+args=$(getopt -n "${0##*/}" -o 'hn' -l 'help,dry-run,render-dpi:,device-dpi:' -- "$@") || errusage
eval "set -- $args"
arg_dry_run=false
arg_render_dpi=auto
+declare -A arg_device_dpi
while (( $# > 0 )); do
case "$1" in
-h|--help)
@@ -77,6 +81,17 @@ while (( $# > 0 )); do
esac
shift 2
;;
+ --device-dpi)
+ if [[ "$2" != *=* ]]; then
+ errusage 'Invalid --device-dpi=%q' "$2"
+ fi
+ device=${2%=*}
+ dpi=${2##*=}
+ if ! arg_device_dpi["$device"]="$(sanitize "${dpi%%x*}" 2>/dev/null)x$(sanitize "${dpi#*x}" 2>/dev/null)"; then
+ errusage 'Invalid --device-dpi=%q' "$2"
+ fi
+ shift 2
+ ;;
--)
shift
break
@@ -96,6 +111,9 @@ if [[ $arg_render_dpi == auto ]] || [[ $arg_render_dpi == auto-hwonly ]]; then
if [[ $arg_render_dpi == auto-hwonly ]] && [[ $source != X11-RandR-hw ]]; then
continue
fi
+ if [[ $source == X11-RandR-hw ]]; then
+ dpi=${arg_device_dpi["$item"]:-"$dpi"}
+ fi
arg_render_xdpi=$(max "$(round "${dpi%%x*}")" "$arg_render_xdpi")
arg_render_ydpi=$(max "$(round "${dpi#*x}")" "$arg_render_ydpi")
done <<<"$dpis"
@@ -116,6 +134,7 @@ fi
if [[ $source != X11-RandR-hw ]]; then
continue
fi
+ dpi=${arg_device_dpi["$item"]:-"$dpi"}
hw_xdpi="$(sanitize "${dpi%%x*}")"
hw_ydpi="$(sanitize "${dpi#*x}")"