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