From f2b5d1dce60be79a85af5e10f524275ef813f288 Mon Sep 17 00:00:00 2001 From: Anton Bobov Date: Thu, 11 Jun 2026 22:55:19 +0500 Subject: add XFCE DPI toggle script --- toggle-dpi | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 toggle-dpi 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 "$@" -- cgit v1.2.3