# $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 local boardvendor local write_zotac_quirk # rebuild 25-gfxcard.conf # always clear the config CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-device.conf" clearconfig addconfig "# Autogenerated by mcored" # but only add lines if some values are found in config.d dir if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device then addconfig 'Section "Device"' helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device addconfig 'EndSection' fi # rebuild 25-module.conf # always clear the config CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-module.conf" clearconfig addconfig "# Autogenerated by mcored" # but only add lines if some values are found in config.d dir if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module then addconfig 'Section "Module"' helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module addconfig 'EndSection' fi # rebuild 25-screen.conf # always clear the config CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-screen.conf" clearconfig addconfig "# Autogenerated by mcored" # but only add lines if some values are found in config.d dir if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen then addconfig 'Section "Screen"' addconfig ' Identifier "Screen0"' addconfig ' Monitor "Monitor0"' helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen addconfig 'EndSection' fi # always disable hdmi port on zotac devices atm - fixme make it configurable like alx CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/30-fix-zotac.conf" clearconfig write_zotac_quirk=0 if [ -e /sys/devices/virtual/dmi/id/board_vendor ] then boardvendor="$(< /sys/devices/virtual/dmi/id/board_vendor)" # decapitalize boardvendor="${boardvendor,,}" case ${boardvendor} in *zotac*) write_zotac_quirk=1 ;; esac fi # some zotacs has as the board_vendor "filled by o.e.m" # so we search the whole devices subtree for zotac vendor matches # 0x19da="ZOTAC International (MCO) Ltd." if [[ -n $(cat /sys/devices/*/*/subsystem_vendor | grep 0x19da) ]] then write_zotac_quirk=1 fi if [ -f ${MCORE_CONFIG_PATH}/xorg/device/30-hdmi.conf ] then source ${MCORE_CONFIG_PATH}/xorg/device/30-hdmi.conf case "${graphic_hdmi}" in enabled) write_zotac_quirk=0 ;; disabled) write_zotac_quirk=1 ;; esac fi if [[ ${write_zotac_quirk} = 1 ]] then addconfig "# Autogenerated by mcored" addconfig "Section \"Monitor\"" addconfig " Identifier \"LVDS1\"" addconfig " Option \"Ignore\" \"True\"" addconfig "EndSection" fi } help_graphic_resolution() { mecho "set graphic.resolution [resolution]" mecho " auto, 800x600, 1024x768, 1280x1024 etc" } help_graphic_refresh() { mecho "set graphic.refresh [refresh rate]" mecho " auto, 60, 100 - all values are Hz" } help_graphic_depth() { mecho "set graphic.depth [color-depth]" mecho " auto, 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." } help_graphic_hdmi() { mecho "set graphic.hdmi [action]" mecho " Available actions:" mecho " enable - enables the hdmi port" mecho " disable - disables the hdmi port" } # set_graphic_resolution ${value} set_graphic_resolution() { local resolution="${CLASS_ARGV[0]}" local CONFIG local depth [[ -z ${resolution} ]] && help_graphic_resolution && return 1 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf" case ${resolution} in *x*) 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 [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] then x11runas "xrandr --size ${resolution}" fi ;; auto) clearconfig ;; esac helper_graphic_rebuild_xorg_conf_d } # set_graphic_depth ${value} set_graphic_depth() { local depth="${CLASS_ARGV[0]}" local CONFIG [[ -z ${depth} ]] && help_graphic_depth && return 1 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf" # do it only for supported color depths case "${depth}" in 1|4|8|15|16|24) clearconfig addconfig " DefaultDepth ${depth}" ;; auto) clearconfig ;; *) help_graphic_depth && return 1 ;; esac helper_graphic_rebuild_xorg_conf_d if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] then mecho "X11 restart required!" fi } # set_graphic_refresh ${value} set_graphic_refresh() { local value="${CLASS_ARGV[0]}" [[ -z ${value} ]] && help_graphic_refresh && return 1 #echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] then x11runas "xrandr --refresh ${value}" fi helper_graphic_rebuild_xorg_conf_d } set_graphic_driver() { local driver="${CLASS_ARGV[0]}" local driverdir="@@LIBDIR@@/xorg/modules/drivers" local CONFIG [[ -z ${driver} ]] && help_graphic_driver && return 1 if [[ ${driver} = auto ]] then decho "Using driver autodetection, doing nothing" elif [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]] then CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" clearconfig addconfig " Identifier \"Card0\"" addconfig " Driver \"${driver}\"" helper_graphic_rebuild_xorg_conf_d if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] then mecho "X11 restart required!" fi else eecho "Driver '${driver}' does not exist on this system. Aborted!" fi } set_graphic_hdmi() { local action="${CLASS_ARGV[0]}" local CONFIG case "${action}" in enable|disable) CONFIG="${MCORE_CONFIG_PATH}/xorg/device/30-hdmi.conf" clearconfig addconfig "graphic_hdmi=\"${action}\"" ;; *) help_graphic_driver return 1 ;; esac } get_graphic_driver() { local action="${CLASS_ARGV[0]}" local driverdir="@@LIBDIR@@/xorg/modules/drivers" local driver local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" local i case "${action}" in current) if [[ -f ${MROOT}/${config} ]] then driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:') rvecho "${driver}" else rvecho "none" fi ;; system) driver=$(list_files_in_directory ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 | sed s':_drv.so::g') rvecho "${driver}" ;; *) help_graphic_driver return 1 ;; esac } get_graphic_hdmi() { local CONFIG="${MCORE_CONFIG_PATH}/xorg/device/30-hdmi.conf" if [ -f ${CONFIG} ] then rvecho "$(< ${CONFIG})" fi }