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 |
|
|
26 |
|
# rebuild 25-gfxcard.conf |
27 |
|
# always clear the config |
28 |
|
CONFIG="/etc/X11/xorg.conf.d/25-device.conf" |
29 |
|
clearconfig |
30 |
|
# but only add lines if some values are found in config.d dir |
31 |
|
if path_not_empty ${MCORE_CONFIG_PATH}/xorg/device |
32 |
|
then |
33 |
|
addconfig 'Section "Device"' |
34 |
|
helper_graphic_add_configs ${MCORE_CONFIG_PATH}/xorg/device |
35 |
|
addconfig 'EndSection' |
36 |
|
fi |
37 |
|
|
38 |
|
# rebuild 25-module.conf |
39 |
|
# always clear the config |
40 |
|
CONFIG="/etc/X11/xorg.conf.d/25-module.conf" |
41 |
|
clearconfig |
42 |
|
# but only add lines if some values are found in config.d dir |
43 |
|
if path_not_empty ${MCORE_CONFIG_PATH}/xorg/module |
44 |
|
then |
45 |
|
addconfig 'Section "Module"' |
46 |
|
helper_graphic_add_configs ${MCORE_CONFIG_PATH}/xorg/module |
47 |
|
addconfig 'EndSection' |
48 |
|
fi |
49 |
|
|
50 |
|
# rebuild 25-screen.conf |
51 |
|
# always clear the config |
52 |
|
CONFIG="/etc/X11/xorg.conf.d/25-screen.conf" |
53 |
|
clearconfig |
54 |
|
# but only add lines if some values are found in config.d dir |
55 |
|
if path_not_empty ${MCORE_CONFIG_PATH}/xorg/screen |
56 |
|
then |
57 |
|
addconfig 'Section "Screen"' |
58 |
|
addconfig ' Identifier "Screen0"' |
59 |
|
addconfig ' Monitor "Monitor0"' |
60 |
|
helper_graphic_add_configs ${MCORE_CONFIG_PATH}/xorg/screen |
61 |
|
addconfig 'EndSection' |
62 |
|
fi |
63 |
|
} |
64 |
|
|
65 |
help_graphic_resolution() |
help_graphic_resolution() |
66 |
{ |
{ |
74 |
mecho " 60, 100 - all values are Hz" |
mecho " 60, 100 - all values are Hz" |
75 |
} |
} |
76 |
|
|
77 |
|
help_graphic_depth() |
78 |
|
{ |
79 |
|
mecho "set graphic.depth [color-depth]" |
80 |
|
mecho " 1, 4, 8, 15, 16, 24 - all values are bits" |
81 |
|
} |
82 |
|
|
83 |
|
help_graphic_driver() |
84 |
|
{ |
85 |
|
mecho "get graphic.driver [action]" |
86 |
|
mecho " Shows current selected or system available graphic drivers." |
87 |
|
mecho " Available actions:" |
88 |
|
mecho " system - show available drivers on the system" |
89 |
|
mecho " current - shows the current selected driver used by Xorg" |
90 |
|
mecho |
91 |
|
mecho "set graphic.driver [driver]" |
92 |
|
mecho " Selects the graphic card driver used by Xorg." |
93 |
|
} |
94 |
|
|
95 |
# set_graphic_resolution ${value} |
# set_graphic_resolution ${value} |
96 |
set_graphic_resolution() |
set_graphic_resolution() |
97 |
{ |
{ |
98 |
local value="$1" |
local resolution="$1" |
99 |
[[ -z ${value} ]] && help_graphic_resolution && return 1 |
local CONFIG |
100 |
|
local depth |
101 |
echo "${value}" > ${SETTINGSPATH}/xorg/resolution |
[[ -z ${resolution} ]] && help_graphic_resolution && return 1 |
102 |
|
|
103 |
|
CONFIG="${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf" |
104 |
|
clearconfig |
105 |
|
# do it for all supported color depth |
106 |
|
for depth in 1 4 8 15 16 24 |
107 |
|
do |
108 |
|
addconfig ' SubSection "Display"' |
109 |
|
addconfig " Depth ${depth}" |
110 |
|
addconfig " Modes \"${resolution}\"" |
111 |
|
addconfig ' ViewPort 0 0' |
112 |
|
addconfig ' EndSubSection' |
113 |
|
done |
114 |
|
|
115 |
if pidof X |
if pidof X |
116 |
then |
then |
117 |
x11runas "DISPLAY=:0 xrandr --size ${value}" |
x11runas "xrandr --size ${resolution}" |
118 |
fi |
fi |
119 |
|
|
120 |
|
helper_graphic_rebuild_xorg_conf_d |
121 |
|
} |
122 |
|
|
123 |
|
# set_graphic_depth ${value} |
124 |
|
set_graphic_depth() |
125 |
|
{ |
126 |
|
local depth="$1" |
127 |
|
local CONFIG |
128 |
|
[[ -z ${depth} ]] && help_graphic_depth && return 1 |
129 |
|
|
130 |
|
# do it only for supported color depths |
131 |
|
case "${depth}" in |
132 |
|
1|4|8|15|16|24) |
133 |
|
CONFIG="${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf" |
134 |
|
clearconfig |
135 |
|
addconfig " DefaultDepth ${depth}" |
136 |
|
;; |
137 |
|
*) help_graphic_depth && return 1 ;; |
138 |
|
esac |
139 |
|
|
140 |
|
# if pidof X |
141 |
|
# then |
142 |
|
# x11runas "xrandr --size ${value}" |
143 |
|
# fi |
144 |
|
|
145 |
|
helper_graphic_rebuild_xorg_conf_d |
146 |
|
mecho "X11 restart required!" |
147 |
} |
} |
148 |
|
|
149 |
# set_graphic_refresh ${value} |
# set_graphic_refresh ${value} |
150 |
set_graphic_refresh() |
set_graphic_refresh() |
151 |
{ |
{ |
152 |
local value="$1" |
local value="$1" |
153 |
[[ -z ${value} ]] && help_graphic_resolution && return 1 |
[[ -z ${value} ]] && help_graphic_refresh && return 1 |
154 |
|
|
155 |
echo "${value}" > ${SETTINGSPATH}/xorg/refresh |
#echo "${value}" > ${SETTINGSPATH}/xorg/refresh |
156 |
|
|
157 |
if pidof X |
if pidof X |
158 |
then |
then |
159 |
x11runas "DISPLAY=:0 xrandr --refresh ${value}" |
x11runas "xrandr --refresh ${value}" |
160 |
fi |
fi |
|
} |
|
161 |
|
|
162 |
# helper_graphic_addconf $@ |
helper_graphic_rebuild_xorg_conf_d |
|
helper_graphic_addconf() |
|
|
{ |
|
|
echo "$@" >> ${conf} |
|
163 |
} |
} |
164 |
|
|
165 |
helper_graphic_rebuild_xorg_conf() |
set_graphic_driver() |
166 |
{ |
{ |
167 |
local conf="/etc/X11/xorg.conf" |
local driver="$1" |
168 |
|
local driverdir="/usr/lib/xorg/modules/drivers" |
169 |
# create empty conf |
local CONFIG |
170 |
:> ${conf} |
[[ -z ${driver} ]] && help_graphic_driver && return 1 |
171 |
|
|
172 |
if [ -f ${SETTINGSPATH}/xorg/gfxcard ] |
if [[ -f ${driverdir}/${driver}_drv.so ]] |
173 |
then |
then |
174 |
helper_graphic_addconf 'Section "Device"' |
CONFIG="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
175 |
helper_graphic_addconf " Identifier \"Builtin Default ${value} Device 0\"" |
clearconfig |
176 |
helper_graphic_addconf " Driver \"${value}\"" |
addconfig " Identifier \"Card0\"" |
177 |
helper_graphic_addconf 'EndSection' |
addconfig " Driver \"${driver}\"" |
178 |
|
|
179 |
|
helper_graphic_rebuild_xorg_conf_d |
180 |
|
mecho "X11 restart required!" |
181 |
|
else |
182 |
|
eecho "Driver '${driver}' does not exist on this system. Aborted!" |
183 |
fi |
fi |
184 |
} |
} |
185 |
|
|
186 |
# set_graphic_gfxcard ${value} |
get_graphic_driver() |
|
set_graphic_gfxcard() |
|
187 |
{ |
{ |
188 |
local value="$1" |
local action="$1" |
189 |
|
local driverdir="/usr/lib/xorg/modules/drivers" |
190 |
echo "${value}" > ${SETTINGSPATH}/xorg/gfxcard |
local driver |
191 |
helper_graphic_rebuild_xorg_conf |
local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
192 |
|
local i |
193 |
if pidof X |
|
194 |
then |
case "${action}" in |
195 |
/etc/init.d/single-x11 restart |
current) |
196 |
fi |
if [[ -f ${config} ]] |
197 |
|
then |
198 |
|
driver=$(grep Driver "${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:') |
199 |
|
mecho "${driver}" |
200 |
|
else |
201 |
|
mecho "none" |
202 |
|
fi |
203 |
|
;; |
204 |
|
system) |
205 |
|
for i in $(find ${driverdir} -mindepth 1 -maxdepth 1 -type f | sort) |
206 |
|
do |
207 |
|
driver="${driver} $(basename ${i} _drv.so)" |
208 |
|
done |
209 |
|
mecho "${driver}" |
210 |
|
;; |
211 |
|
*) |
212 |
|
help_graphic_driver |
213 |
|
return 1 |
214 |
|
;; |
215 |
|
esac |
216 |
} |
} |