#!/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 "$@"