Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/modules/basic-video/graphic.client.class.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

mcore-src/trunk/mcore-tools/daemon/client/include/graphic.client.class revision 1248 by niro, Wed Feb 2 20:20:24 2011 UTC mcore-src/trunk/mcore-tools/src/modules/basic-video/graphic.client.class.in revision 2193 by niro, Fri Jan 10 14:40:31 2014 UTC
# Line 1  Line 1 
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="${MROOT}/etc/X11/xorg.conf.d/25-device.conf"
29     clearconfig
30     addconfig "# Autogenerated by mcored"
31     # but only add lines if some values are found in config.d dir
32     if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device
33     then
34     addconfig 'Section "Device"'
35     helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device
36     addconfig 'EndSection'
37     fi
38    
39     # rebuild 25-module.conf
40     # always clear the config
41     CONFIG="${MROOT}/etc/X11/xorg.conf.d/25-module.conf"
42     clearconfig
43     addconfig "# Autogenerated by mcored"
44     # but only add lines if some values are found in config.d dir
45     if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module
46     then
47     addconfig 'Section "Module"'
48     helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module
49     addconfig 'EndSection'
50     fi
51    
52     # rebuild 25-screen.conf
53     # always clear the config
54     CONFIG="${MROOT}/etc/X11/xorg.conf.d/25-screen.conf"
55     clearconfig
56     addconfig "# Autogenerated by mcored"
57     # but only add lines if some values are found in config.d dir
58     if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen
59     then
60     addconfig 'Section "Screen"'
61     addconfig ' Identifier "Screen0"'
62     addconfig ' Monitor "Monitor0"'
63     helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen
64     addconfig 'EndSection'
65     fi
66    }
67    
68  help_graphic_resolution()  help_graphic_resolution()
69  {  {
# Line 14  help_graphic_refresh() Line 77  help_graphic_refresh()
77   mecho "  60, 100 - all values are Hz"   mecho "  60, 100 - all values are Hz"
78  }  }
79    
80    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  # set_graphic_resolution ${value}  # set_graphic_resolution ${value}
99  set_graphic_resolution()  set_graphic_resolution()
100  {  {
101   local value="$1"   local resolution="$1"
102   [[ -z ${value} ]] && help_graphic_resolution && return 1   local CONFIG
103     local depth
104     [[ -z ${resolution} ]] && help_graphic_resolution && return 1
105    
106     CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf"
107     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    
118   echo "${value}" > ${SETTINGSPATH}/xorg/resolution   if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
119     then
120     x11runas "xrandr --size ${resolution}"
121     fi
122    
123   if pidof X   helper_graphic_rebuild_xorg_conf_d
124    }
125    
126    # 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     CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf"
137     clearconfig
138     addconfig " DefaultDepth ${depth}"
139     ;;
140     *) help_graphic_depth && return 1 ;;
141     esac
142    
143     helper_graphic_rebuild_xorg_conf_d
144     if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
145   then   then
146   x11runas "DISPLAY=:0 xrandr --size ${value}"   mecho "X11 restart required!"
147   fi   fi
148  }  }
149    
# Line 32  set_graphic_resolution() Line 151  set_graphic_resolution()
151  set_graphic_refresh()  set_graphic_refresh()
152  {  {
153   local value="$1"   local value="$1"
154   [[ -z ${value} ]] && help_graphic_resolution && return 1   [[ -z ${value} ]] && help_graphic_refresh && return 1
155    
156   echo "${value}" > ${SETTINGSPATH}/xorg/refresh   #echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh
157    
158   if pidof X   if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
159   then   then
160   x11runas "DISPLAY=:0 xrandr --refresh ${value}"   x11runas "xrandr --refresh ${value}"
161   fi   fi
 }  
162    
163  # helper_graphic_addconf $@   helper_graphic_rebuild_xorg_conf_d
 helper_graphic_addconf()  
 {  
  echo "$@" >> ${conf}  
164  }  }
165    
166  helper_graphic_rebuild_xorg_conf()  set_graphic_driver()
167  {  {
168   local conf="/etc/X11/xorg.conf"   local driver="$1"
169     local driverdir="/usr/lib/xorg/modules/drivers"
170     local CONFIG
171     [[ -z ${driver} ]] && help_graphic_driver && return 1
172    
173   # create empty conf   if [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]]
  :> ${conf}  
   
  if [ -f ${SETTINGSPATH}/xorg/gfxcard ]  
174   then   then
175   helper_graphic_addconf 'Section "Device"'   CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf"
176   helper_graphic_addconf "  Identifier   \"Builtin Default ${value} Device 0\""   clearconfig
177   helper_graphic_addconf "  Driver       \"${value}\""   addconfig " Identifier \"Card0\""
178   helper_graphic_addconf 'EndSection'   addconfig " Driver \"${driver}\""
179    
180     helper_graphic_rebuild_xorg_conf_d
181     if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
182     then
183     mecho "X11 restart required!"
184     fi
185     else
186     eecho "Driver '${driver}' does not exist on this system. Aborted!"
187   fi   fi
188  }  }
189    
190  # set_graphic_gfxcard ${value}  get_graphic_driver()
 set_graphic_gfxcard()  
191  {  {
192   local value="$1"   local action="$1"
193     local driverdir="/usr/lib/xorg/modules/drivers"
194   echo "${value}" > ${SETTINGSPATH}/xorg/gfxcard   local driver
195   helper_graphic_rebuild_xorg_conf   local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf"
196     local i
197   if pidof X  
198   then   case "${action}" in
199   /etc/init.d/single-x11 restart   current)
200   fi   if [[ -f ${MROOT}/${config} ]]
201     then
202     driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:')
203     rvecho "${driver}"
204     else
205     rvecho "none"
206     fi
207     ;;
208     system)
209     driver=$(list_files_in_directory ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 | sed s':_drv.so::g')
210     rvecho "${driver}"
211     ;;
212     *)
213     help_graphic_driver
214     return 1
215     ;;
216     esac
217  }  }

Legend:
Removed from v.1248  
changed lines
  Added in v.2193