Contents of /mcore-src/trunk/mcore-tools/src/modules/basic-video/graphic.client.class.in
Parent Directory | Revision Log
Revision 2828 -
(show 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 | # $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 | |
27 | # rebuild 25-gfxcard.conf |
28 | # always clear the config |
29 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-device.conf" |
30 | clearconfig |
31 | addconfig "# Autogenerated by mcored" |
32 | # but only add lines if some values are found in config.d dir |
33 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device |
34 | then |
35 | addconfig 'Section "Device"' |
36 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device |
37 | addconfig 'EndSection' |
38 | fi |
39 | |
40 | # rebuild 25-module.conf |
41 | # always clear the config |
42 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-module.conf" |
43 | clearconfig |
44 | addconfig "# Autogenerated by mcored" |
45 | # but only add lines if some values are found in config.d dir |
46 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module |
47 | then |
48 | addconfig 'Section "Module"' |
49 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module |
50 | addconfig 'EndSection' |
51 | fi |
52 | |
53 | # rebuild 25-screen.conf |
54 | # always clear the config |
55 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-screen.conf" |
56 | clearconfig |
57 | addconfig "# Autogenerated by mcored" |
58 | # but only add lines if some values are found in config.d dir |
59 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen |
60 | then |
61 | addconfig 'Section "Screen"' |
62 | addconfig ' Identifier "Screen0"' |
63 | addconfig ' Monitor "Monitor0"' |
64 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen |
65 | addconfig 'EndSection' |
66 | fi |
67 | |
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 | } |
87 | |
88 | help_graphic_resolution() |
89 | { |
90 | mecho "set graphic.resolution [resolution]" |
91 | mecho " auto, 800x600, 1024x768, 1280x1024 etc" |
92 | } |
93 | |
94 | help_graphic_refresh() |
95 | { |
96 | mecho "set graphic.refresh [refresh rate]" |
97 | mecho " auto, 60, 100 - all values are Hz" |
98 | } |
99 | |
100 | help_graphic_depth() |
101 | { |
102 | mecho "set graphic.depth [color-depth]" |
103 | mecho " auto, 1, 4, 8, 15, 16, 24 - all values are bits" |
104 | } |
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 | # set_graphic_resolution ${value} |
119 | set_graphic_resolution() |
120 | { |
121 | local resolution="${CLASS_ARGV[0]}" |
122 | local CONFIG |
123 | local depth |
124 | [[ -z ${resolution} ]] && help_graphic_resolution && return 1 |
125 | |
126 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf" |
127 | |
128 | case ${resolution} in |
129 | *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 | |
141 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
142 | then |
143 | x11runas "xrandr --size ${resolution}" |
144 | fi |
145 | ;; |
146 | auto) clearconfig ;; |
147 | esac |
148 | |
149 | helper_graphic_rebuild_xorg_conf_d |
150 | } |
151 | |
152 | # set_graphic_depth ${value} |
153 | set_graphic_depth() |
154 | { |
155 | local depth="${CLASS_ARGV[0]}" |
156 | local CONFIG |
157 | [[ -z ${depth} ]] && help_graphic_depth && return 1 |
158 | |
159 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf" |
160 | |
161 | # 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 | auto) clearconfig ;; |
168 | *) help_graphic_depth && return 1 ;; |
169 | esac |
170 | |
171 | helper_graphic_rebuild_xorg_conf_d |
172 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
173 | then |
174 | mecho "X11 restart required!" |
175 | fi |
176 | } |
177 | |
178 | # set_graphic_refresh ${value} |
179 | set_graphic_refresh() |
180 | { |
181 | local value="${CLASS_ARGV[0]}" |
182 | [[ -z ${value} ]] && help_graphic_refresh && return 1 |
183 | |
184 | #echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh |
185 | |
186 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
187 | then |
188 | x11runas "xrandr --refresh ${value}" |
189 | fi |
190 | |
191 | helper_graphic_rebuild_xorg_conf_d |
192 | } |
193 | |
194 | set_graphic_driver() |
195 | { |
196 | local driver="${CLASS_ARGV[0]}" |
197 | local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
198 | local CONFIG |
199 | [[ -z ${driver} ]] && help_graphic_driver && return 1 |
200 | |
201 | if [[ ${driver} = auto ]] |
202 | then |
203 | decho "Using driver autodetection, doing nothing" |
204 | elif [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]] |
205 | then |
206 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
207 | clearconfig |
208 | addconfig " Identifier \"Card0\"" |
209 | addconfig " Driver \"${driver}\"" |
210 | |
211 | helper_graphic_rebuild_xorg_conf_d |
212 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
213 | then |
214 | mecho "X11 restart required!" |
215 | fi |
216 | else |
217 | eecho "Driver '${driver}' does not exist on this system. Aborted!" |
218 | fi |
219 | } |
220 | |
221 | get_graphic_driver() |
222 | { |
223 | local action="${CLASS_ARGV[0]}" |
224 | local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
225 | local driver |
226 | local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
227 | local i |
228 | |
229 | case "${action}" in |
230 | current) |
231 | if [[ -f ${MROOT}/${config} ]] |
232 | then |
233 | driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:') |
234 | rvecho "${driver}" |
235 | else |
236 | rvecho "none" |
237 | fi |
238 | ;; |
239 | system) |
240 | driver=$(list_files_in_directory ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 | sed s':_drv.so::g') |
241 | rvecho "${driver}" |
242 | ;; |
243 | *) |
244 | help_graphic_driver |
245 | return 1 |
246 | ;; |
247 | esac |
248 | } |