summaryrefslogtreecommitdiff
path: root/toggle-dpi
diff options
context:
space:
mode:
Diffstat (limited to 'toggle-dpi')
-rwxr-xr-xtoggle-dpi35
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 "$@"