diff options
| author | Anton Bobov <anton@bobov.name> | 2026-06-11 22:55:19 +0500 |
|---|---|---|
| committer | Anton Bobov <anton@bobov.name> | 2026-07-24 14:21:48 +0500 |
| commit | f2b5d1dce60be79a85af5e10f524275ef813f288 (patch) | |
| tree | 707dd1c0180993d0528338f947bc997a5689adc3 | |
| parent | 320287ab1aabfdf047d092f604294b7c2240a82e (diff) | |
add XFCE DPI toggle script
| -rwxr-xr-x | toggle-dpi | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/toggle-dpi b/toggle-dpi new file mode 100755 index 0000000..2d6da1c --- /dev/null +++ b/toggle-dpi @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Toggles between standard and high-DPI settings for XFCE desktop environment. + +set -euo pipefail + +if ! command -v xfconf-query &>/dev/null; then + echo "Error: Requires xfconf-query (from xfce4-settings package)" >&2 + exit 1 +fi + +: "${DPI_DEFAULT:=96}" # Standard DPI for <=1080p displays +: "${DPI_4K:=130}" # Typical DPI for 4K displays + +_xfq() { + xfconf-query -c xsettings -p /Xft/DPI "$@" +} + +main() { + local current_dpi + current_dpi=$(_xfq) + + local next_dpi + case "$current_dpi" in + "$DPI_DEFAULT") next_dpi="$DPI_4K" ;; + "$DPI_4K") next_dpi="$DPI_DEFAULT" ;; + *) + echo "Warning: Current DPI ($current_dpi) not in toggle range. Preserving value." >&2 + next_dpi="$current_dpi" + ;; + esac + + _xfq -s "$next_dpi" +} + +main "$@" |
