Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/src/modules/basic-video/graphic.client.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2848 - (show annotations) (download)
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 # $Id$
2
3 provide basic-video
4
5 # 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 local boardvendor
26 local write_zotac_quirk
27
28 # rebuild 25-gfxcard.conf
29 # always clear the config
30 CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-device.conf"
31 clearconfig
32 addconfig "# Autogenerated by mcored"
33 # but only add lines if some values are found in config.d dir
34 if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device
35 then
36 addconfig 'Section "Device"'
37 helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device
38 addconfig 'EndSection'
39 fi
40
41 # rebuild 25-module.conf
42 # always clear the config
43 CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-module.conf"
44 clearconfig
45 addconfig "# Autogenerated by mcored"
46 # but only add lines if some values are found in config.d dir
47 if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module
48 then
49 addconfig 'Section "Module"'
50 helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module
51 addconfig 'EndSection'
52 fi
53
54 # rebuild 25-screen.conf
55 # always clear the config
56 CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-screen.conf"
57 clearconfig
58 addconfig "# Autogenerated by mcored"
59 # but only add lines if some values are found in config.d dir
60 if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen
61 then
62 addconfig 'Section "Screen"'
63 addconfig ' Identifier "Screen0"'
64 addconfig ' Monitor "Monitor0"'
65 helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen
66 addconfig 'EndSection'
67 fi
68
69 # 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 # 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 write_zotac_quirk=0
101 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 *zotac*) write_zotac_quirk=1 ;;
108 esac
109 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
118 if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/xorg/hdmi/hdmi ]
119 then
120 source ${MROOT}/${MCORE_CONFIG_PATH}/xorg/hdmi/hdmi
121 case "${graphic_hdmi}" in
122 enable) write_zotac_quirk=0 ;;
123 disable) write_zotac_quirk=1 ;;
124 esac
125 fi
126
127 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 }
136
137 help_graphic_resolution()
138 {
139 mecho "set graphic.resolution [resolution]"
140 mecho " auto, 800x600, 1024x768, 1280x1024 etc"
141 }
142
143 help_graphic_refresh()
144 {
145 mecho "set graphic.refresh [refresh rate]"
146 mecho " auto, 60, 100 - all values are Hz"
147 }
148
149 help_graphic_depth()
150 {
151 mecho "set graphic.depth [color-depth]"
152 mecho " auto, 1, 4, 8, 15, 16, 24 - all values are bits"
153 }
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 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 # set_graphic_resolution ${value}
176 set_graphic_resolution()
177 {
178 local resolution="${CLASS_ARGV[0]}"
179 local CONFIG
180 local depth
181 [[ -z ${resolution} ]] && help_graphic_resolution && return 1
182
183 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf"
184
185 case ${resolution} in
186 *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
198 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
199 then
200 x11runas "xrandr --size ${resolution}"
201 fi
202 ;;
203 auto) clearconfig ;;
204 esac
205
206 helper_graphic_rebuild_xorg_conf_d
207 }
208
209 # set_graphic_depth ${value}
210 set_graphic_depth()
211 {
212 local depth="${CLASS_ARGV[0]}"
213 local CONFIG
214 [[ -z ${depth} ]] && help_graphic_depth && return 1
215
216 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf"
217
218 # 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 auto) clearconfig ;;
225 *) help_graphic_depth && return 1 ;;
226 esac
227
228 helper_graphic_rebuild_xorg_conf_d
229 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
230 then
231 mecho "X11 restart required!"
232 fi
233 }
234
235 # set_graphic_refresh ${value}
236 set_graphic_refresh()
237 {
238 local value="${CLASS_ARGV[0]}"
239 [[ -z ${value} ]] && help_graphic_refresh && return 1
240
241 #echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh
242
243 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
244 then
245 x11runas "xrandr --refresh ${value}"
246 fi
247
248 helper_graphic_rebuild_xorg_conf_d
249 }
250
251 set_graphic_driver()
252 {
253 local driver="${CLASS_ARGV[0]}"
254 local driverdir="@@LIBDIR@@/xorg/modules/drivers"
255 local CONFIG
256 [[ -z ${driver} ]] && help_graphic_driver && return 1
257
258 if [[ ${driver} = auto ]]
259 then
260 decho "Using driver autodetection, doing nothing"
261 elif [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]]
262 then
263 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf"
264 clearconfig
265 addconfig " Identifier \"Card0\""
266 addconfig " Driver \"${driver}\""
267
268 helper_graphic_rebuild_xorg_conf_d
269 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
270 then
271 mecho "X11 restart required!"
272 fi
273 else
274 eecho "Driver '${driver}' does not exist on this system. Aborted!"
275 fi
276 }
277
278 set_graphic_hdmi()
279 {
280 local action="${CLASS_ARGV[0]}"
281 local CONFIG
282
283 case "${action}" in
284 enable|disable)
285 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/hdmi/hdmi"
286 clearconfig
287 addconfig "graphic_hdmi=\"${action}\""
288 ;;
289 *)
290 help_graphic_driver
291 return 1
292 ;;
293 esac
294 }
295
296 get_graphic_driver()
297 {
298 local action="${CLASS_ARGV[0]}"
299 local driverdir="@@LIBDIR@@/xorg/modules/drivers"
300 local driver
301 local config="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf"
302 local i
303
304 case "${action}" in
305 current)
306 if [[ -f ${MROOT}/${config} ]]
307 then
308 driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:')
309 rvecho "${driver}"
310 else
311 rvecho "none"
312 fi
313 ;;
314 system)
315 driver=$(list_files_in_directory ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 | sed s':_drv.so::g')
316 rvecho "${driver}"
317 ;;
318 *)
319 help_graphic_driver
320 return 1
321 ;;
322 esac
323 }
324
325 get_graphic_hdmi()
326 {
327 local CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/hdmi/hdmi"
328 if [ -f ${CONFIG} ]
329 then
330 rvecho "$(< ${CONFIG})"
331 fi
332 }