summaryrefslogtreecommitdiff
path: root/toggle-dpi
blob: 2d6da1c21e3a63f1ee3d0bf3c7b9a42fa28437ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 "$@"