Annotation of /mcore-src/trunk/mcore-tools/src/modules/basic-video/graphic.client.class.in
Parent Directory | Revision Log
Revision 2828 -
(hide annotations)
(download)
Fri Aug 4 08:40:36 2017 UTC (6 years, 9 months ago) by niro
File size: 6120 byte(s)
Fri Aug 4 08:40:36 2017 UTC (6 years, 9 months ago) by niro
File size: 6120 byte(s)
-always apply zotac hdmi quirk on all zotac devices to fix broken screen resolution with the ica-client in fullscreen mode
1 | niro | 1248 | # $Id$ |
2 | |||
3 | niro | 1258 | provide basic-video |
4 | niro | 1248 | |
5 | niro | 1258 | # todo monitor gfxcard |
6 | helper_graphic_add_configs() | ||
7 | { | ||
8 | local path="$1" | ||
9 | local conf | ||
10 | |||
11 | # exit ERR if path does not exist | ||
12 | [[ ! -d ${path} ]] && return 1 | ||
13 | |||
14 | for conf in $(find "${path}" -mindepth 1 -maxdepth 1 -type f -name \*.conf | sort) | ||
15 | do | ||
16 | cat "${conf}" >> "${CONFIG}" | ||
17 | done | ||
18 | } | ||
19 | |||
20 | # everything from xorg conf but inputdevices. they are handled properly trough udev! | ||
21 | helper_graphic_rebuild_xorg_conf_d() | ||
22 | { | ||
23 | local CONFIG | ||
24 | local conf | ||
25 | niro | 2828 | local boardvendor |
26 | niro | 1258 | |
27 | # rebuild 25-gfxcard.conf | ||
28 | # always clear the config | ||
29 | niro | 2194 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-device.conf" |
30 | niro | 1258 | clearconfig |
31 | niro | 2019 | addconfig "# Autogenerated by mcored" |
32 | niro | 1258 | # but only add lines if some values are found in config.d dir |
33 | niro | 2018 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device |
34 | niro | 1258 | then |
35 | addconfig 'Section "Device"' | ||
36 | niro | 2018 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device |
37 | niro | 1258 | addconfig 'EndSection' |
38 | fi | ||
39 | |||
40 | # rebuild 25-module.conf | ||
41 | # always clear the config | ||
42 | niro | 2194 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-module.conf" |
43 | niro | 1258 | clearconfig |
44 | niro | 2019 | addconfig "# Autogenerated by mcored" |
45 | niro | 1258 | # but only add lines if some values are found in config.d dir |
46 | niro | 2018 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module |
47 | niro | 1258 | then |
48 | addconfig 'Section "Module"' | ||
49 | niro | 2018 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module |
50 | niro | 1258 | addconfig 'EndSection' |
51 | fi | ||
52 | |||
53 | # rebuild 25-screen.conf | ||
54 | # always clear the config | ||
55 | niro | 2194 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-screen.conf" |
56 | niro | 1258 | clearconfig |
57 | niro | 2019 | addconfig "# Autogenerated by mcored" |
58 | niro | 1258 | # but only add lines if some values are found in config.d dir |
59 | niro | 2018 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen |
60 | niro | 1258 | then |
61 | addconfig 'Section "Screen"' | ||
62 | addconfig ' Identifier "Screen0"' | ||
63 | addconfig ' Monitor "Monitor0"' | ||
64 | niro | 2018 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen |
65 | niro | 1258 | addconfig 'EndSection' |
66 | fi | ||
67 | niro | 2828 | |
68 | # always disable hdmi port on zotac devices atm - fixme make it configurable like alx | ||
69 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/30-fix-zotac.conf" | ||
70 | clearconfig | ||
71 | if [ -e /sys/devices/virtual/dmi/id/board_vendor ] | ||
72 | then | ||
73 | boardvendor="$(< /sys/devices/virtual/dmi/id/board_vendor)" | ||
74 | # decapitalize | ||
75 | boardvendor="${boardvendor,,}" | ||
76 | case ${boardvendor} in | ||
77 | *zotac*) | ||
78 | addconfig "# Autogenerated by mcored" | ||
79 | addconfig "Section \"Monitor\"" | ||
80 | addconfig " Identifier \"LVDS1\"" | ||
81 | addconfig " Option \"Ignore\" \"True\"" | ||
82 | addconfig "EndSection" | ||
83 | ;; | ||
84 | esac | ||
85 | fi | ||
86 | niro | 1258 | } |
87 | |||
88 | niro | 1248 | help_graphic_resolution() |
89 | { | ||
90 | mecho "set graphic.resolution [resolution]" | ||
91 | niro | 2813 | mecho " auto, 800x600, 1024x768, 1280x1024 etc" |
92 | niro | 1248 | } |
93 | |||
94 | help_graphic_refresh() | ||
95 | { | ||
96 | mecho "set graphic.refresh [refresh rate]" | ||
97 | niro | 2813 | mecho " auto, 60, 100 - all values are Hz" |
98 | niro | 1248 | } |
99 | |||
100 | niro | 1258 | help_graphic_depth() |
101 | { | ||
102 | mecho "set graphic.depth [color-depth]" | ||
103 | niro | 2813 | mecho " auto, 1, 4, 8, 15, 16, 24 - all values are bits" |
104 | niro | 1258 | } |
105 | |||
106 | help_graphic_driver() | ||
107 | { | ||
108 | mecho "get graphic.driver [action]" | ||
109 | mecho " Shows current selected or system available graphic drivers." | ||
110 | mecho " Available actions:" | ||
111 | mecho " system - show available drivers on the system" | ||
112 | mecho " current - shows the current selected driver used by Xorg" | ||
113 | mecho | ||
114 | mecho "set graphic.driver [driver]" | ||
115 | mecho " Selects the graphic card driver used by Xorg." | ||
116 | } | ||
117 | |||
118 | niro | 1248 | # set_graphic_resolution ${value} |
119 | set_graphic_resolution() | ||
120 | { | ||
121 | niro | 2269 | local resolution="${CLASS_ARGV[0]}" |
122 | niro | 1258 | local CONFIG |
123 | local depth | ||
124 | [[ -z ${resolution} ]] && help_graphic_resolution && return 1 | ||
125 | niro | 1248 | |
126 | niro | 2018 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf" |
127 | niro | 1248 | |
128 | niro | 2823 | case ${resolution} in |
129 | niro | 2813 | *x*) |
130 | clearconfig | ||
131 | # do it for all supported color depth | ||
132 | for depth in 1 4 8 15 16 24 | ||
133 | do | ||
134 | addconfig ' SubSection "Display"' | ||
135 | addconfig " Depth ${depth}" | ||
136 | addconfig " Modes \"${resolution}\"" | ||
137 | addconfig ' ViewPort 0 0' | ||
138 | addconfig ' EndSubSection' | ||
139 | done | ||
140 | niro | 1258 | |
141 | niro | 2813 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
142 | then | ||
143 | x11runas "xrandr --size ${resolution}" | ||
144 | fi | ||
145 | ;; | ||
146 | auto) clearconfig ;; | ||
147 | esac | ||
148 | |||
149 | niro | 1258 | helper_graphic_rebuild_xorg_conf_d |
150 | niro | 1248 | } |
151 | |||
152 | niro | 1258 | # set_graphic_depth ${value} |
153 | set_graphic_depth() | ||
154 | { | ||
155 | niro | 2269 | local depth="${CLASS_ARGV[0]}" |
156 | niro | 1258 | local CONFIG |
157 | [[ -z ${depth} ]] && help_graphic_depth && return 1 | ||
158 | |||
159 | niro | 2813 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf" |
160 | |||
161 | niro | 1258 | # do it only for supported color depths |
162 | case "${depth}" in | ||
163 | 1|4|8|15|16|24) | ||
164 | clearconfig | ||
165 | addconfig " DefaultDepth ${depth}" | ||
166 | ;; | ||
167 | niro | 2813 | auto) clearconfig ;; |
168 | niro | 1258 | *) help_graphic_depth && return 1 ;; |
169 | esac | ||
170 | |||
171 | helper_graphic_rebuild_xorg_conf_d | ||
172 | niro | 2018 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
173 | then | ||
174 | mecho "X11 restart required!" | ||
175 | fi | ||
176 | niro | 1258 | } |
177 | |||
178 | niro | 1248 | # set_graphic_refresh ${value} |
179 | set_graphic_refresh() | ||
180 | { | ||
181 | niro | 2269 | local value="${CLASS_ARGV[0]}" |
182 | niro | 1258 | [[ -z ${value} ]] && help_graphic_refresh && return 1 |
183 | niro | 1248 | |
184 | niro | 2018 | #echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh |
185 | niro | 1248 | |
186 | niro | 2018 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
187 | then | ||
188 | x11runas "xrandr --refresh ${value}" | ||
189 | fi | ||
190 | niro | 1248 | |
191 | niro | 1258 | helper_graphic_rebuild_xorg_conf_d |
192 | niro | 1248 | } |
193 | |||
194 | niro | 1258 | set_graphic_driver() |
195 | niro | 1248 | { |
196 | niro | 2269 | local driver="${CLASS_ARGV[0]}" |
197 | niro | 2194 | local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
198 | niro | 1258 | local CONFIG |
199 | [[ -z ${driver} ]] && help_graphic_driver && return 1 | ||
200 | niro | 1248 | |
201 | niro | 2665 | if [[ ${driver} = auto ]] |
202 | niro | 1258 | then |
203 | niro | 2665 | decho "Using driver autodetection, doing nothing" |
204 | elif [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]] | ||
205 | then | ||
206 | niro | 2018 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
207 | niro | 1258 | clearconfig |
208 | addconfig " Identifier \"Card0\"" | ||
209 | addconfig " Driver \"${driver}\"" | ||
210 | niro | 1248 | |
211 | niro | 1258 | helper_graphic_rebuild_xorg_conf_d |
212 | niro | 2018 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
213 | then | ||
214 | mecho "X11 restart required!" | ||
215 | fi | ||
216 | niro | 1258 | else |
217 | eecho "Driver '${driver}' does not exist on this system. Aborted!" | ||
218 | niro | 1248 | fi |
219 | } | ||
220 | |||
221 | niro | 1258 | get_graphic_driver() |
222 | niro | 1248 | { |
223 | niro | 2269 | local action="${CLASS_ARGV[0]}" |
224 | niro | 2194 | local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
225 | niro | 1258 | local driver |
226 | local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" | ||
227 | local i | ||
228 | niro | 1248 | |
229 | niro | 1258 | case "${action}" in |
230 | current) | ||
231 | niro | 2018 | if [[ -f ${MROOT}/${config} ]] |
232 | niro | 1258 | then |
233 | niro | 2018 | driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:') |
234 | niro | 1643 | rvecho "${driver}" |
235 | niro | 1258 | else |
236 | niro | 1643 | rvecho "none" |
237 | niro | 1258 | fi |
238 | ;; | ||
239 | system) | ||
240 | niro | 2039 | driver=$(list_files_in_directory ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 | sed s':_drv.so::g') |
241 | niro | 1643 | rvecho "${driver}" |
242 | niro | 1258 | ;; |
243 | *) | ||
244 | help_graphic_driver | ||
245 | return 1 | ||
246 | ;; | ||
247 | esac | ||
248 | niro | 1248 | } |