# $Id$ provide basic-video # todo monitor gfxcard helper_graphic_add_configs() { local path="$1" local conf # exit ERR if path does not exist [[ ! -d ${path} ]] && return 1 for conf in $(find "${path}" -mindepth 1 -maxdepth 1 -type f -name \*.conf | sort) do cat "${conf}" >> "${CONFIG}" done } # everything from xorg conf but inputdevices. they are handled properly trough udev! helper_graphic_rebuild_xorg_conf_d() { local CONFIG local conf # rebuild 25-gfxcard.conf # always clear the config CONFIG="/etc/X11/xorg.conf.d/25-device.conf" clearconfig # but only add lines if some values are found in config.d dir if path_not_empty ${MCORE_CONFIG_PATH}/xorg/device then addconfig 'Section "Device"' helper_graphic_add_configs ${MCORE_CONFIG_PATH}/xorg/device addconfig 'EndSection' fi # rebuild 25-module.conf # always clear the config CONFIG="/etc/X11/xorg.conf.d/25-module.conf" clearconfig # but only add lines if some values are found in config.d dir if path_not_empty ${MCORE_CONFIG_PATH}/xorg/module then addconfig 'Section "Module"' helper_graphic_add_configs ${MCORE_CONFIG_PATH}/xorg/module addconfig 'EndSection' fi # rebuild 25-screen.conf # always clear the config CONFIG="/etc/X11/xorg.conf.d/25-screen.conf" clearconfig # but only add lines if some values are found in config.d dir if path_not_empty ${MCORE_CONFIG_PATH}/xorg/screen then addconfig 'Section "Screen"' addconfig ' Identifier "Screen0"' addconfig ' Monitor "Monitor0"' helper_graphic_add_configs ${MCORE_CONFIG_PATH}/xorg/screen addconfig 'EndSection' fi } help_graphic_resolution() { mecho "set graphic.resolution [resolution]" mecho " 800x600, 1024x768, 1280x1024 etc" } help_graphic_refresh() { mecho "set graphic.refresh [refresh rate]" mecho " 60, 100 - all values are Hz" } help_graphic_depth() { mecho "set graphic.depth [color-depth]" mecho " 1, 4, 8, 15, 16, 24 - all values are bits" } help_graphic_driver() { mecho "get graphic.driver [action]" mecho " Shows current selected or system available graphic drivers." mecho " Available actions:" mecho " system - show available drivers on the system" mecho " current - shows the current selected driver used by Xorg" mecho mecho "set graphic.driver [driver]" mecho " Selects the graphic card driver used by Xorg." } # set_graphic_resolution ${value} set_graphic_resolution() { local resolution="$1" local CONFIG local depth [[ -z ${resolution} ]] && help_graphic_resolution && return 1 CONFIG="${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf" clearconfig # do it for all supported color depth for depth in 1 4 8 15 16 24 do addconfig ' SubSection "Display"' addconfig " Depth ${depth}" addconfig " Modes \"${resolution}\"" addconfig ' ViewPort 0 0' addconfig ' EndSubSection' done if pidof X then x11runas "xrandr --size ${resolution}" fi helper_graphic_rebuild_xorg_conf_d } # set_graphic_depth ${value} set_graphic_depth() { local depth="$1" local CONFIG [[ -z ${depth} ]] && help_graphic_depth && return 1 # do it only for supported color depths case "${depth}" in 1|4|8|15|16|24) CONFIG="${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf" clearconfig addconfig " DefaultDepth ${depth}" ;; *) help_graphic_depth && return 1 ;; esac # if pidof X # then # x11runas "xrandr --size ${value}" # fi helper_graphic_rebuild_xorg_conf_d mecho "X11 restart required!" } # set_graphic_refresh ${value} set_graphic_refresh() { local value="$1" [[ -z ${value} ]] && help_graphic_refresh && return 1 #echo "${value}" > ${SETTINGSPATH}/xorg/refresh if pidof X then x11runas "xrandr --refresh ${value}" fi helper_graphic_rebuild_xorg_conf_d } set_graphic_driver() { local driver="$1" local driverdir="/usr/lib/xorg/modules/drivers" local CONFIG [[ -z ${driver} ]] && help_graphic_driver && return 1 if [[ -f ${driverdir}/${driver}_drv.so ]] then CONFIG="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" clearconfig addconfig " Identifier \"Card0\"" addconfig " Driver \"${driver}\"" helper_graphic_rebuild_xorg_conf_d mecho "X11 restart required!" else eecho "Driver '${driver}' does not exist on this system. Aborted!" fi } get_graphic_driver() { local action="$1" local driverdir="/usr/lib/xorg/modules/drivers" local driver local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" local i case "${action}" in current) if [[ -f ${config} ]] then driver=$(grep Driver "${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:') mecho "${driver}" else mecho "none" fi ;; system) for i in $(find ${driverdir} -mindepth 1 -maxdepth 1 -type f | sort) do driver="${driver} $(basename ${i} _drv.so)" done mecho "${driver}" ;; *) help_graphic_driver return 1 ;; esac }