1 |
# $Id$ |
# $Id$ |
2 |
|
|
3 |
provide basic-video x0vnc |
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 |
|
# always disable hdmi port on zotac devices atm - fixme make it configurable like alx |
70 |
|
CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/30-fix-zotac.conf" |
71 |
|
clearconfig |
72 |
|
write_zotac_quirk=0 |
73 |
|
if [ -e /sys/devices/virtual/dmi/id/board_vendor ] |
74 |
|
then |
75 |
|
boardvendor="$(< /sys/devices/virtual/dmi/id/board_vendor)" |
76 |
|
# decapitalize |
77 |
|
boardvendor="${boardvendor,,}" |
78 |
|
case ${boardvendor} in |
79 |
|
*zotac*) write_zotac_quirk=1 ;; |
80 |
|
esac |
81 |
|
fi |
82 |
|
# some zotacs has as the board_vendor "filled by o.e.m" |
83 |
|
# so we search the whole devices subtree for zotac vendor matches |
84 |
|
# 0x19da="ZOTAC International (MCO) Ltd." |
85 |
|
if [[ -n $(cat /sys/devices/*/*/subsystem_vendor | grep 0x19da) ]] |
86 |
|
then |
87 |
|
write_zotac_quirk=1 |
88 |
|
fi |
89 |
|
|
90 |
|
if [ -f ${MCORE_CONFIG_PATH}/xorg/device/30-hdmi.conf ] |
91 |
|
then |
92 |
|
source ${MCORE_CONFIG_PATH}/xorg/device/30-hdmi.conf |
93 |
|
case "${graphic_hdmi}" in |
94 |
|
enabled) write_zotac_quirk=0 ;; |
95 |
|
disabled) write_zotac_quirk=1 ;; |
96 |
|
esac |
97 |
|
fi |
98 |
|
|
99 |
|
if [[ ${write_zotac_quirk} = 1 ]] |
100 |
|
then |
101 |
|
addconfig "# Autogenerated by mcored" |
102 |
|
addconfig "Section \"Monitor\"" |
103 |
|
addconfig " Identifier \"LVDS1\"" |
104 |
|
addconfig " Option \"Ignore\" \"True\"" |
105 |
|
addconfig "EndSection" |
106 |
|
fi |
107 |
|
} |
108 |
|
|
109 |
help_graphic_resolution() |
help_graphic_resolution() |
110 |
{ |
{ |
111 |
mecho "set graphic.resolution [resolution]" |
mecho "set graphic.resolution [resolution]" |
112 |
mecho " 800x600, 1024x768, 1280x1024 etc" |
mecho " auto, 800x600, 1024x768, 1280x1024 etc" |
113 |
} |
} |
114 |
|
|
115 |
help_graphic_refresh() |
help_graphic_refresh() |
116 |
{ |
{ |
117 |
mecho "set graphic.refresh [refresh rate]" |
mecho "set graphic.refresh [refresh rate]" |
118 |
mecho " 60, 100 - all values are Hz" |
mecho " auto, 60, 100 - all values are Hz" |
119 |
|
} |
120 |
|
|
121 |
|
help_graphic_depth() |
122 |
|
{ |
123 |
|
mecho "set graphic.depth [color-depth]" |
124 |
|
mecho " auto, 1, 4, 8, 15, 16, 24 - all values are bits" |
125 |
|
} |
126 |
|
|
127 |
|
help_graphic_driver() |
128 |
|
{ |
129 |
|
mecho "get graphic.driver [action]" |
130 |
|
mecho " Shows current selected or system available graphic drivers." |
131 |
|
mecho " Available actions:" |
132 |
|
mecho " system - show available drivers on the system" |
133 |
|
mecho " current - shows the current selected driver used by Xorg" |
134 |
|
mecho |
135 |
|
mecho "set graphic.driver [driver]" |
136 |
|
mecho " Selects the graphic card driver used by Xorg." |
137 |
|
} |
138 |
|
|
139 |
|
help_graphic_hdmi() |
140 |
|
{ |
141 |
|
mecho "set graphic.hdmi [action]" |
142 |
|
mecho " Available actions:" |
143 |
|
mecho " enable - enables the hdmi port" |
144 |
|
mecho " disable - disables the hdmi port" |
145 |
} |
} |
146 |
|
|
147 |
# set_graphic_resolution ${value} |
# set_graphic_resolution ${value} |
148 |
set_graphic_resolution() |
set_graphic_resolution() |
149 |
{ |
{ |
150 |
local value="$1" |
local resolution="${CLASS_ARGV[0]}" |
151 |
[[ -z ${value} ]] && help_graphic_resolution && return 1 |
local CONFIG |
152 |
|
local depth |
153 |
|
[[ -z ${resolution} ]] && help_graphic_resolution && return 1 |
154 |
|
|
155 |
|
CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf" |
156 |
|
|
157 |
|
case ${resolution} in |
158 |
|
*x*) |
159 |
|
clearconfig |
160 |
|
# do it for all supported color depth |
161 |
|
for depth in 1 4 8 15 16 24 |
162 |
|
do |
163 |
|
addconfig ' SubSection "Display"' |
164 |
|
addconfig " Depth ${depth}" |
165 |
|
addconfig " Modes \"${resolution}\"" |
166 |
|
addconfig ' ViewPort 0 0' |
167 |
|
addconfig ' EndSubSection' |
168 |
|
done |
169 |
|
|
170 |
|
if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
171 |
|
then |
172 |
|
x11runas "xrandr --size ${resolution}" |
173 |
|
fi |
174 |
|
;; |
175 |
|
auto) clearconfig ;; |
176 |
|
esac |
177 |
|
|
178 |
echo "${value}" > ${SETTINGSPATH}/xorg/resolution |
helper_graphic_rebuild_xorg_conf_d |
179 |
|
} |
180 |
|
|
181 |
|
# set_graphic_depth ${value} |
182 |
|
set_graphic_depth() |
183 |
|
{ |
184 |
|
local depth="${CLASS_ARGV[0]}" |
185 |
|
local CONFIG |
186 |
|
[[ -z ${depth} ]] && help_graphic_depth && return 1 |
187 |
|
|
188 |
|
CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf" |
189 |
|
|
190 |
|
# do it only for supported color depths |
191 |
|
case "${depth}" in |
192 |
|
1|4|8|15|16|24) |
193 |
|
clearconfig |
194 |
|
addconfig " DefaultDepth ${depth}" |
195 |
|
;; |
196 |
|
auto) clearconfig ;; |
197 |
|
*) help_graphic_depth && return 1 ;; |
198 |
|
esac |
199 |
|
|
200 |
if pidof X |
helper_graphic_rebuild_xorg_conf_d |
201 |
|
if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
202 |
then |
then |
203 |
x11runas "DISPLAY=:0 xrandr --size ${value}" |
mecho "X11 restart required!" |
204 |
fi |
fi |
205 |
} |
} |
206 |
|
|
207 |
# set_graphic_refresh ${value} |
# set_graphic_refresh ${value} |
208 |
set_graphic_refresh() |
set_graphic_refresh() |
209 |
{ |
{ |
210 |
local value="$1" |
local value="${CLASS_ARGV[0]}" |
211 |
[[ -z ${value} ]] && help_graphic_resolution && return 1 |
[[ -z ${value} ]] && help_graphic_refresh && return 1 |
212 |
|
|
213 |
echo "${value}" > ${SETTINGSPATH}/xorg/refresh |
#echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh |
214 |
|
|
215 |
if pidof X |
if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
216 |
then |
then |
217 |
x11runas "DISPLAY=:0 xrandr --refresh ${value}" |
x11runas "xrandr --refresh ${value}" |
218 |
fi |
fi |
|
} |
|
219 |
|
|
220 |
# helper_graphic_addconf $@ |
helper_graphic_rebuild_xorg_conf_d |
|
helper_graphic_addconf() |
|
|
{ |
|
|
echo "$@" >> ${conf} |
|
221 |
} |
} |
222 |
|
|
223 |
helper_graphic_rebuild_xorg_conf() |
set_graphic_driver() |
224 |
{ |
{ |
225 |
local conf="/etc/X11/xorg.conf" |
local driver="${CLASS_ARGV[0]}" |
226 |
|
local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
227 |
# create empty conf |
local CONFIG |
228 |
:> ${conf} |
[[ -z ${driver} ]] && help_graphic_driver && return 1 |
229 |
|
|
230 |
if [ -f ${SETTINGSPATH}/xorg/gfxcard ] |
if [[ ${driver} = auto ]] |
231 |
then |
then |
232 |
helper_graphic_addconf 'Section "Device"' |
decho "Using driver autodetection, doing nothing" |
233 |
helper_graphic_addconf " Identifier \"Builtin Default ${value} Device 0\"" |
elif [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]] |
234 |
helper_graphic_addconf " Driver \"${value}\"" |
then |
235 |
helper_graphic_addconf 'EndSection' |
CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
236 |
|
clearconfig |
237 |
|
addconfig " Identifier \"Card0\"" |
238 |
|
addconfig " Driver \"${driver}\"" |
239 |
|
|
240 |
|
helper_graphic_rebuild_xorg_conf_d |
241 |
|
if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
242 |
|
then |
243 |
|
mecho "X11 restart required!" |
244 |
|
fi |
245 |
|
else |
246 |
|
eecho "Driver '${driver}' does not exist on this system. Aborted!" |
247 |
fi |
fi |
248 |
} |
} |
249 |
|
|
250 |
# set_graphic_gfxcard ${value} |
set_graphic_hdmi() |
|
set_graphic_gfxcard() |
|
251 |
{ |
{ |
252 |
local value="$1" |
local action="${CLASS_ARGV[0]}" |
253 |
|
local CONFIG |
254 |
|
|
255 |
|
case "${action}" in |
256 |
|
enable|disable) |
257 |
|
CONFIG="${MCORE_CONFIG_PATH}/xorg/device/30-hdmi.conf" |
258 |
|
clearconfig |
259 |
|
addconfig "graphic_hdmi=\"${action}\"" |
260 |
|
;; |
261 |
|
*) |
262 |
|
help_graphic_driver |
263 |
|
return 1 |
264 |
|
;; |
265 |
|
esac |
266 |
|
} |
267 |
|
|
268 |
echo "${value}" > ${SETTINGSPATH}/xorg/gfxcard |
get_graphic_driver() |
269 |
helper_graphic_rebuild_xorg_conf |
{ |
270 |
|
local action="${CLASS_ARGV[0]}" |
271 |
|
local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
272 |
|
local driver |
273 |
|
local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
274 |
|
local i |
275 |
|
|
276 |
|
case "${action}" in |
277 |
|
current) |
278 |
|
if [[ -f ${MROOT}/${config} ]] |
279 |
|
then |
280 |
|
driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:') |
281 |
|
rvecho "${driver}" |
282 |
|
else |
283 |
|
rvecho "none" |
284 |
|
fi |
285 |
|
;; |
286 |
|
system) |
287 |
|
driver=$(list_files_in_directory ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 | sed s':_drv.so::g') |
288 |
|
rvecho "${driver}" |
289 |
|
;; |
290 |
|
*) |
291 |
|
help_graphic_driver |
292 |
|
return 1 |
293 |
|
;; |
294 |
|
esac |
295 |
|
} |
296 |
|
|
297 |
if pidof X |
get_graphic_hdmi() |
298 |
|
{ |
299 |
|
local CONFIG="${MCORE_CONFIG_PATH}/xorg/device/30-hdmi.conf" |
300 |
|
if [ -f ${CONFIG} ] |
301 |
then |
then |
302 |
/etc/init.d/single-x11 restart |
rvecho "$(< ${CONFIG})" |
303 |
fi |
fi |
304 |
} |
} |