source: lliurex-rpi-packages/trunk/fuentes/ldm/ltsp/xinitrc.d/I10-xrandr @ 2328

Last change on this file since 2328 was 2328, checked in by kbut, 3 years ago

add new package

File size: 3.8 KB
Line 
1#
2# This script will implement xrandr support based on lts.conf vars
3#
4
5# Only execute xrandr code if XRANDR_DISABLE=False
6if ! boolean_is_true "${XRANDR_DISABLE}"; then
7
8#
9# Backward compatibility for X_MODE_0:
10
11c=0
12for i in ${X_MODE_0}; do
13    c=$(($c+1))
14    [ $c = 1 ] && XRANDR_MODE_0=${i}
15done
16[ $c -gt 1 ] && XRANDR_NEWMODE_0=${X_MODE_0}
17unset c
18
19# Definition of lts.conf vars:
20#     XRANDR_OUTPUT_0 = <name of output 0>
21#     XRANDR_RATE_0 = <rate of output 0>
22#     XRANDR_MODE_0 = <mode of output 0>
23#     XRANDR_NEWMODE_0 = <new mode for output 0>
24#     XRANDR_ROTATE_0 = <rotation of output 0>
25#     XRANDR_REFLECT_0 = <reflection of output 0>
26#     XRANDR_DPI_0 = <dpi of output 0>
27##########  Following are for xrandr < 1.2
28#     XRANDR_SIZE_0 = <size of output 0>
29#     XRANDR_ORIENTATION_0 = <orientation of output 0>
30
31XRANDR="xrandr"
32XRANDR_ARGS=
33
34# If the admin does not specify an output, make requested changes to all connected outputs
35if ! env|grep XRANDR_OUTPUT >/dev/null; then
36    CONNECTED_OUTPUTS=$(xrandr -q|grep ' connected'|sed -e 's/^\([^ ]*\) .*$/\1/')
37    o=0
38    for i in $CONNECTED_OUTPUTS; do
39        eval XRANDR_OUTPUT_${o}=${i}
40        if boolean_is_true "${XRANDR_AUTO_MULTIHEAD:-Y}" && [ ${o} -gt 0 ]; then
41            eval XRANDR_OUTPUT_${o}=\"\$XRANDR_OUTPUT_${o} --left-of ${last_i}\"
42            # If no mode is forced for this screen, and
43            # no mode is forced for any screen, then try to use the preferred
44            # mode for the attached monitor.
45            # But, if no mode is forced for this screen and a mode is forced
46            # for the first screen, use the first screen's mode for this
47            # screen, as well, because the user is most likely wanting
48            # a multiscreen display with the same forced resolution on all
49            # screens.
50            eval THIS_MODE=\$XRANDR_MODE_${o}
51            if [ -z "${THIS_MODE}" ]; then
52                if [ -z "${XRANDR_MODE_0}" ]; then
53                    eval XRANDR_OUTPUT_${o}=\"\$XRANDR_OUTPUT_${o} --auto\"
54                fi
55            fi
56            unset THIS_MODE
57        fi
58        o=$(($o+1))
59        last_i=${i}
60    done
61fi
62
63# Let's support a 9-headed monster - why not?
64for i in 0 1 2 3 4 5 6 7 8; do
65    eval XRANDR_OUTPUT=\$XRANDR_OUTPUT_${i}
66    eval XRANDR_SIZE=\$XRANDR_SIZE_${i}
67    eval XRANDR_ORIENTATION=\$XRANDR_ORIENTATION_${i}
68    eval XRANDR_RATE=\$XRANDR_RATE_${i}
69    eval XRANDR_MODE=\$XRANDR_MODE_${i}
70    eval XRANDR_NEWMODE=\$XRANDR_NEWMODE_${i}
71    eval XRANDR_ROTATE=\$XRANDR_ROTATE_${i}
72    eval XRANDR_REFLECT=\$XRANDR_REFLECT_${i}
73    eval XRANDR_DPI=\$XRANDR_DPI_${i}
74
75    ########### Xrandr > 1.2 Values (preferred)
76    [ -n "${XRANDR_OUTPUT}" ] && XRANDR_ARGS="${XRANDR_ARGS} --output ${XRANDR_OUTPUT}"
77    [ -n "${XRANDR_RATE}" ] && XRANDR_ARGS="${XRANDR_ARGS} --rate ${XRANDR_RATE}"
78    [ -n "${XRANDR_MODE}" ] && XRANDR_ARGS="${XRANDR_ARGS} --mode ${XRANDR_MODE}"
79    [ -n "${XRANDR_NEWMODE}" ] && XRANDR_ARGS="${XRANDR_ARGS} --newmode ${XRANDR_NEWMODE}"
80    [ -n "${XRANDR_ROTATE}" ] && XRANDR_ARGS="${XRANDR_ARGS} --rotate ${XRANDR_ROTATE}"
81    [ -n "${XRANDR_REFLECT}" ] && XRANDR_ARGS="${XRANDR_ARGS} --reflect ${XRANDR_REFLECT}"
82    [ -n "${XRANDR_DPI}" ] && XRANDR_ARGS="${XRANDR_ARGS} --dpi ${XRANDR_DPI}"
83    ############ Support these for xrandr < 1.2
84    [ -n "${XRANDR_SIZE}" ] && XRANDR_ARGS="${XRANDR_ARGS} -s ${XRANDR_SIZE}"
85    [ -n "${XRANDR_ORIENTATION}" ] && XRANDR_ARGS="${XRANDR_ARGS} -o ${XRANDR_ORIENTATION}"
86
87done
88
89[ -n "${XRANDR_ARGS}" ] && ${XRANDR} ${XRANDR_ARGS}
90
91# XRANDR_COMMAND_[0-9] can be a bit less complex and allows defining new modes
92env | sed -n '/^XRANDR_COMMAND_[0-9]=/s///p' | while read command; do
93    # Remove possible "xrandr" in front of the command
94    command=${command#xrandr}
95    xrandr $command
96done
97
98fi # end of XRANDR_DISABLE=False conditional
Note: See TracBrowser for help on using the repository browser.