Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/daemon/client/include/graphic.client.class

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2018 - (hide annotations) (download)
Mon Aug 13 11:08:28 2012 UTC (11 years, 9 months ago) by niro
File size: 5113 byte(s)
-support $MROOT variable
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     # but only add lines if some values are found in config.d dir
31 niro 2018 if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device
32 niro 1258 then
33     addconfig 'Section "Device"'
34 niro 2018 helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device
35 niro 1258 addconfig 'EndSection'
36     fi
37    
38     # rebuild 25-module.conf
39     # always clear the config
40 niro 2018 CONFIG="${MROOT}/etc/X11/xorg.conf.d/25-module.conf"
41 niro 1258 clearconfig
42     # but only add lines if some values are found in config.d dir
43 niro 2018 if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module
44 niro 1258 then
45     addconfig 'Section "Module"'
46 niro 2018 helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module
47 niro 1258 addconfig 'EndSection'
48     fi
49    
50     # rebuild 25-screen.conf
51     # always clear the config
52 niro 2018 CONFIG="${MROOT}/etc/X11/xorg.conf.d/25-screen.conf"
53 niro 1258 clearconfig
54     # but only add lines if some values are found in config.d dir
55 niro 2018 if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen
56 niro 1258 then
57     addconfig 'Section "Screen"'
58     addconfig ' Identifier "Screen0"'
59     addconfig ' Monitor "Monitor0"'
60 niro 2018 helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen
61 niro 1258 addconfig 'EndSection'
62     fi
63     }
64    
65 niro 1248 help_graphic_resolution()
66     {
67     mecho "set graphic.resolution [resolution]"
68     mecho " 800x600, 1024x768, 1280x1024 etc"
69     }
70    
71     help_graphic_refresh()
72     {
73     mecho "set graphic.refresh [refresh rate]"
74     mecho " 60, 100 - all values are Hz"
75     }
76    
77 niro 1258 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 niro 1248 # set_graphic_resolution ${value}
96     set_graphic_resolution()
97     {
98 niro 1258 local resolution="$1"
99     local CONFIG
100     local depth
101     [[ -z ${resolution} ]] && help_graphic_resolution && return 1
102 niro 1248
103 niro 2018 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf"
104 niro 1258 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 niro 1248
115 niro 2018 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
116     then
117     x11runas "xrandr --size ${resolution}"
118     fi
119 niro 1258
120     helper_graphic_rebuild_xorg_conf_d
121 niro 1248 }
122    
123 niro 1258 # 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 niro 2018 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf"
134 niro 1258 clearconfig
135     addconfig " DefaultDepth ${depth}"
136     ;;
137     *) help_graphic_depth && return 1 ;;
138     esac
139    
140     helper_graphic_rebuild_xorg_conf_d
141 niro 2018 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
142     then
143     mecho "X11 restart required!"
144     fi
145 niro 1258 }
146    
147 niro 1248 # set_graphic_refresh ${value}
148     set_graphic_refresh()
149     {
150     local value="$1"
151 niro 1258 [[ -z ${value} ]] && help_graphic_refresh && return 1
152 niro 1248
153 niro 2018 #echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh
154 niro 1248
155 niro 2018 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
156     then
157     x11runas "xrandr --refresh ${value}"
158     fi
159 niro 1248
160 niro 1258 helper_graphic_rebuild_xorg_conf_d
161 niro 1248 }
162    
163 niro 1258 set_graphic_driver()
164 niro 1248 {
165 niro 1258 local driver="$1"
166     local driverdir="/usr/lib/xorg/modules/drivers"
167     local CONFIG
168     [[ -z ${driver} ]] && help_graphic_driver && return 1
169 niro 1248
170 niro 2018 if [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]]
171 niro 1258 then
172 niro 2018 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf"
173 niro 1258 clearconfig
174     addconfig " Identifier \"Card0\""
175     addconfig " Driver \"${driver}\""
176 niro 1248
177 niro 1258 helper_graphic_rebuild_xorg_conf_d
178 niro 2018 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
179     then
180     mecho "X11 restart required!"
181     fi
182 niro 1258 else
183     eecho "Driver '${driver}' does not exist on this system. Aborted!"
184 niro 1248 fi
185     }
186    
187 niro 1258 get_graphic_driver()
188 niro 1248 {
189 niro 1258 local action="$1"
190     local driverdir="/usr/lib/xorg/modules/drivers"
191     local driver
192     local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf"
193     local i
194 niro 1248
195 niro 1258 case "${action}" in
196     current)
197 niro 2018 if [[ -f ${MROOT}/${config} ]]
198 niro 1258 then
199 niro 2018 driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:')
200 niro 1643 rvecho "${driver}"
201 niro 1258 else
202 niro 1643 rvecho "none"
203 niro 1258 fi
204     ;;
205     system)
206 niro 2018 for i in $(find ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 -type f | sort)
207 niro 1258 do
208     driver="${driver} $(basename ${i} _drv.so)"
209     done
210 niro 1643 rvecho "${driver}"
211 niro 1258 ;;
212     *)
213     help_graphic_driver
214     return 1
215     ;;
216     esac
217 niro 1248 }