Annotation of /mcore-src/trunk/mcore-tools/src/modules/basic-video/graphic.client.class.in
Parent Directory | Revision Log
Revision 2848 -
(hide annotations)
(download)
Thu Jul 25 09:51:37 2019 UTC (4 years, 9 months ago) by niro
File size: 8297 byte(s)
Thu Jul 25 09:51:37 2019 UTC (4 years, 9 months ago) by niro
File size: 8297 byte(s)
-helper_graphic_rebuild_xorg_conf_d(): rebuild 25-monitor.conf and 25-serverlayout.conf to honor screensaver settings
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 | 2830 | local write_zotac_quirk |
27 | niro | 1258 | |
28 | # rebuild 25-gfxcard.conf | ||
29 | # always clear the config | ||
30 | niro | 2194 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-device.conf" |
31 | niro | 1258 | clearconfig |
32 | niro | 2019 | addconfig "# Autogenerated by mcored" |
33 | niro | 1258 | # but only add lines if some values are found in config.d dir |
34 | niro | 2018 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device |
35 | niro | 1258 | then |
36 | addconfig 'Section "Device"' | ||
37 | niro | 2018 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device |
38 | niro | 1258 | addconfig 'EndSection' |
39 | fi | ||
40 | |||
41 | # rebuild 25-module.conf | ||
42 | # always clear the config | ||
43 | niro | 2194 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-module.conf" |
44 | niro | 1258 | clearconfig |
45 | niro | 2019 | addconfig "# Autogenerated by mcored" |
46 | niro | 1258 | # but only add lines if some values are found in config.d dir |
47 | niro | 2018 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module |
48 | niro | 1258 | then |
49 | addconfig 'Section "Module"' | ||
50 | niro | 2018 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module |
51 | niro | 1258 | addconfig 'EndSection' |
52 | fi | ||
53 | |||
54 | # rebuild 25-screen.conf | ||
55 | # always clear the config | ||
56 | niro | 2194 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-screen.conf" |
57 | niro | 1258 | clearconfig |
58 | niro | 2019 | addconfig "# Autogenerated by mcored" |
59 | niro | 1258 | # but only add lines if some values are found in config.d dir |
60 | niro | 2018 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen |
61 | niro | 1258 | then |
62 | addconfig 'Section "Screen"' | ||
63 | addconfig ' Identifier "Screen0"' | ||
64 | addconfig ' Monitor "Monitor0"' | ||
65 | niro | 2018 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen |
66 | niro | 1258 | addconfig 'EndSection' |
67 | fi | ||
68 | niro | 2828 | |
69 | niro | 2848 | # rebuild 25-monitor.conf |
70 | # always clear the config | ||
71 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-monitor.conf" | ||
72 | clearconfig | ||
73 | addconfig "# Autogenerated by mcored" | ||
74 | # but only add lines if some values are found in config.d dir | ||
75 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/monitor | ||
76 | then | ||
77 | addconfig 'Section "Monitor"' | ||
78 | addconfig ' Identifier "Monitor0"' | ||
79 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/monitor | ||
80 | addconfig 'EndSection' | ||
81 | fi | ||
82 | |||
83 | # rebuild 25-serverlayout.conf | ||
84 | # always clear the config | ||
85 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-serverlayout.conf" | ||
86 | clearconfig | ||
87 | addconfig "# Autogenerated by mcored" | ||
88 | # but only add lines if some values are found in config.d dir | ||
89 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/serverlayout | ||
90 | then | ||
91 | addconfig 'Section "ServerLayout"' | ||
92 | addconfig ' Identifier "ServerLayout0"' | ||
93 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/serverlayout | ||
94 | addconfig 'EndSection' | ||
95 | fi | ||
96 | |||
97 | niro | 2828 | # always disable hdmi port on zotac devices atm - fixme make it configurable like alx |
98 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/30-fix-zotac.conf" | ||
99 | clearconfig | ||
100 | niro | 2830 | write_zotac_quirk=0 |
101 | niro | 2828 | if [ -e /sys/devices/virtual/dmi/id/board_vendor ] |
102 | then | ||
103 | boardvendor="$(< /sys/devices/virtual/dmi/id/board_vendor)" | ||
104 | # decapitalize | ||
105 | boardvendor="${boardvendor,,}" | ||
106 | case ${boardvendor} in | ||
107 | niro | 2830 | *zotac*) write_zotac_quirk=1 ;; |
108 | niro | 2828 | esac |
109 | niro | 2830 | fi |
110 | # some zotacs has as the board_vendor "filled by o.e.m" | ||
111 | # so we search the whole devices subtree for zotac vendor matches | ||
112 | # 0x19da="ZOTAC International (MCO) Ltd." | ||
113 | if [[ -n $(cat /sys/devices/*/*/subsystem_vendor | grep 0x19da) ]] | ||
114 | then | ||
115 | write_zotac_quirk=1 | ||
116 | fi | ||
117 | niro | 2844 | |
118 | niro | 2846 | if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/xorg/hdmi/hdmi ] |
119 | niro | 2844 | then |
120 | niro | 2846 | source ${MROOT}/${MCORE_CONFIG_PATH}/xorg/hdmi/hdmi |
121 | niro | 2844 | case "${graphic_hdmi}" in |
122 | niro | 2845 | enable) write_zotac_quirk=0 ;; |
123 | disable) write_zotac_quirk=1 ;; | ||
124 | niro | 2844 | esac |
125 | fi | ||
126 | |||
127 | niro | 2830 | if [[ ${write_zotac_quirk} = 1 ]] |
128 | then | ||
129 | addconfig "# Autogenerated by mcored" | ||
130 | addconfig "Section \"Monitor\"" | ||
131 | addconfig " Identifier \"LVDS1\"" | ||
132 | addconfig " Option \"Ignore\" \"True\"" | ||
133 | addconfig "EndSection" | ||
134 | fi | ||
135 | niro | 1258 | } |
136 | |||
137 | niro | 1248 | help_graphic_resolution() |
138 | { | ||
139 | mecho "set graphic.resolution [resolution]" | ||
140 | niro | 2813 | mecho " auto, 800x600, 1024x768, 1280x1024 etc" |
141 | niro | 1248 | } |
142 | |||
143 | help_graphic_refresh() | ||
144 | { | ||
145 | mecho "set graphic.refresh [refresh rate]" | ||
146 | niro | 2813 | mecho " auto, 60, 100 - all values are Hz" |
147 | niro | 1248 | } |
148 | |||
149 | niro | 1258 | help_graphic_depth() |
150 | { | ||
151 | mecho "set graphic.depth [color-depth]" | ||
152 | niro | 2813 | mecho " auto, 1, 4, 8, 15, 16, 24 - all values are bits" |
153 | niro | 1258 | } |
154 | |||
155 | help_graphic_driver() | ||
156 | { | ||
157 | mecho "get graphic.driver [action]" | ||
158 | mecho " Shows current selected or system available graphic drivers." | ||
159 | mecho " Available actions:" | ||
160 | mecho " system - show available drivers on the system" | ||
161 | mecho " current - shows the current selected driver used by Xorg" | ||
162 | mecho | ||
163 | mecho "set graphic.driver [driver]" | ||
164 | mecho " Selects the graphic card driver used by Xorg." | ||
165 | } | ||
166 | |||
167 | niro | 2844 | help_graphic_hdmi() |
168 | { | ||
169 | mecho "set graphic.hdmi [action]" | ||
170 | mecho " Available actions:" | ||
171 | mecho " enable - enables the hdmi port" | ||
172 | mecho " disable - disables the hdmi port" | ||
173 | } | ||
174 | |||
175 | niro | 1248 | # set_graphic_resolution ${value} |
176 | set_graphic_resolution() | ||
177 | { | ||
178 | niro | 2269 | local resolution="${CLASS_ARGV[0]}" |
179 | niro | 1258 | local CONFIG |
180 | local depth | ||
181 | [[ -z ${resolution} ]] && help_graphic_resolution && return 1 | ||
182 | niro | 1248 | |
183 | niro | 2018 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf" |
184 | niro | 1248 | |
185 | niro | 2823 | case ${resolution} in |
186 | niro | 2813 | *x*) |
187 | clearconfig | ||
188 | # do it for all supported color depth | ||
189 | for depth in 1 4 8 15 16 24 | ||
190 | do | ||
191 | addconfig ' SubSection "Display"' | ||
192 | addconfig " Depth ${depth}" | ||
193 | addconfig " Modes \"${resolution}\"" | ||
194 | addconfig ' ViewPort 0 0' | ||
195 | addconfig ' EndSubSection' | ||
196 | done | ||
197 | niro | 1258 | |
198 | niro | 2813 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
199 | then | ||
200 | x11runas "xrandr --size ${resolution}" | ||
201 | fi | ||
202 | ;; | ||
203 | auto) clearconfig ;; | ||
204 | esac | ||
205 | |||
206 | niro | 1258 | helper_graphic_rebuild_xorg_conf_d |
207 | niro | 1248 | } |
208 | |||
209 | niro | 1258 | # set_graphic_depth ${value} |
210 | set_graphic_depth() | ||
211 | { | ||
212 | niro | 2269 | local depth="${CLASS_ARGV[0]}" |
213 | niro | 1258 | local CONFIG |
214 | [[ -z ${depth} ]] && help_graphic_depth && return 1 | ||
215 | |||
216 | niro | 2813 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf" |
217 | |||
218 | niro | 1258 | # do it only for supported color depths |
219 | case "${depth}" in | ||
220 | 1|4|8|15|16|24) | ||
221 | clearconfig | ||
222 | addconfig " DefaultDepth ${depth}" | ||
223 | ;; | ||
224 | niro | 2813 | auto) clearconfig ;; |
225 | niro | 1258 | *) help_graphic_depth && return 1 ;; |
226 | esac | ||
227 | |||
228 | helper_graphic_rebuild_xorg_conf_d | ||
229 | niro | 2018 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
230 | then | ||
231 | mecho "X11 restart required!" | ||
232 | fi | ||
233 | niro | 1258 | } |
234 | |||
235 | niro | 1248 | # set_graphic_refresh ${value} |
236 | set_graphic_refresh() | ||
237 | { | ||
238 | niro | 2269 | local value="${CLASS_ARGV[0]}" |
239 | niro | 1258 | [[ -z ${value} ]] && help_graphic_refresh && return 1 |
240 | niro | 1248 | |
241 | niro | 2018 | #echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh |
242 | niro | 1248 | |
243 | niro | 2018 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
244 | then | ||
245 | x11runas "xrandr --refresh ${value}" | ||
246 | fi | ||
247 | niro | 1248 | |
248 | niro | 1258 | helper_graphic_rebuild_xorg_conf_d |
249 | niro | 1248 | } |
250 | |||
251 | niro | 1258 | set_graphic_driver() |
252 | niro | 1248 | { |
253 | niro | 2269 | local driver="${CLASS_ARGV[0]}" |
254 | niro | 2194 | local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
255 | niro | 1258 | local CONFIG |
256 | [[ -z ${driver} ]] && help_graphic_driver && return 1 | ||
257 | niro | 1248 | |
258 | niro | 2665 | if [[ ${driver} = auto ]] |
259 | niro | 1258 | then |
260 | niro | 2665 | decho "Using driver autodetection, doing nothing" |
261 | elif [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]] | ||
262 | then | ||
263 | niro | 2018 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
264 | niro | 1258 | clearconfig |
265 | addconfig " Identifier \"Card0\"" | ||
266 | addconfig " Driver \"${driver}\"" | ||
267 | niro | 1248 | |
268 | niro | 1258 | helper_graphic_rebuild_xorg_conf_d |
269 | niro | 2018 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
270 | then | ||
271 | mecho "X11 restart required!" | ||
272 | fi | ||
273 | niro | 1258 | else |
274 | eecho "Driver '${driver}' does not exist on this system. Aborted!" | ||
275 | niro | 1248 | fi |
276 | } | ||
277 | |||
278 | niro | 2844 | set_graphic_hdmi() |
279 | { | ||
280 | local action="${CLASS_ARGV[0]}" | ||
281 | local CONFIG | ||
282 | |||
283 | case "${action}" in | ||
284 | enable|disable) | ||
285 | niro | 2846 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/hdmi/hdmi" |
286 | niro | 2844 | clearconfig |
287 | addconfig "graphic_hdmi=\"${action}\"" | ||
288 | ;; | ||
289 | *) | ||
290 | help_graphic_driver | ||
291 | return 1 | ||
292 | ;; | ||
293 | esac | ||
294 | } | ||
295 | |||
296 | niro | 1258 | get_graphic_driver() |
297 | niro | 1248 | { |
298 | niro | 2269 | local action="${CLASS_ARGV[0]}" |
299 | niro | 2194 | local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
300 | niro | 1258 | local driver |
301 | niro | 2846 | local config="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
302 | niro | 1258 | local i |
303 | niro | 1248 | |
304 | niro | 1258 | case "${action}" in |
305 | current) | ||
306 | niro | 2018 | if [[ -f ${MROOT}/${config} ]] |
307 | niro | 1258 | then |
308 | niro | 2018 | driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:') |
309 | niro | 1643 | rvecho "${driver}" |
310 | niro | 1258 | else |
311 | niro | 1643 | rvecho "none" |
312 | niro | 1258 | fi |
313 | ;; | ||
314 | system) | ||
315 | niro | 2039 | driver=$(list_files_in_directory ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 | sed s':_drv.so::g') |
316 | niro | 1643 | rvecho "${driver}" |
317 | niro | 1258 | ;; |
318 | *) | ||
319 | help_graphic_driver | ||
320 | return 1 | ||
321 | ;; | ||
322 | esac | ||
323 | niro | 1248 | } |
324 | niro | 2844 | |
325 | get_graphic_hdmi() | ||
326 | { | ||
327 | niro | 2846 | local CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/hdmi/hdmi" |
328 | niro | 2844 | if [ -f ${CONFIG} ] |
329 | then | ||
330 | rvecho "$(< ${CONFIG})" | ||
331 | fi | ||
332 | } |