OSDN Git Service

e2407ff0cbfecd88de84ccf65d6520e5e35c586f
[instantos/instantOS.git] / programs / instantdpi
1 #!/bin/bash
2
3 # apply instantOS dpi settings
4
5 DPI="$(iconf dpi)"
6
7 resetdpi() {
8     echo "resetting dpi"
9     sed -i '/^Xft\.dpi/d' ~/.Xresources
10 }
11
12 appendpi() {
13     echo "setting dpi to $DPI"
14     echo "Xft.dpi: $DPI" >>~/.Xresources
15 }
16
17 if [ -z "$DPI" ]; then
18     resetdpi
19     exit
20 fi
21
22 [ "$DPI" -eq "$DPI" ] || exit
23
24 # resetting
25 if [ "$DPI" = "96" ]; then
26     resetdpi
27     exit
28 fi
29
30 if ! [ -e .Xresources ]; then
31     echo "initializing xresources"
32     touch ~/.Xresources
33     appendpi "$DPI"
34 else
35     if grep -q '^Xft.dpi' ~/.Xresources; then
36         resetdpi
37     fi
38     appendpi "$DPI"
39 fi