Date: Sat, 20 Jan 2018 14:43:01 +0100 From: Ralf Mardorf <ralf.mardorf@rocketmail.com> To: freebsd-questions@freebsd.org Subject: Re: xfce4 reverts to mirrored dislays Message-ID: <20180120144301.170645e6@archlinux.localdomain> In-Reply-To: <20180120141518.7a85ed99@planb.netng.org> References: <c89fe0ea-d072-2a4b-ad02-74041e3bd181@nethead.se> <20180120125636.6ad88128.freebsd@edvax.de> <20180120134001.65ddb697@archlinux.localdomain> <20180120141518.7a85ed99@planb.netng.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 20 Jan 2018 14:15:18 +0100, Vladimir Botka wrote: >+1. FWIW, example of xrandr: Unfortunately I can't provide such a plain example, however apart from irrelevant content in xorg.conf.d/ and some irrelevant customization scripts, a dirty hacked scripted named xdh-feh calls another dirty hacked script /usr/local/bin/xdh. I doubt in a hurry dirty written scripts do help a lot, however, a script could work around issues that GUIs using xrandr don't. I recommend to use Google (not another search engine, because sometimes Google unfortunately still provides the best hits on top), if the man page doesn't help. [rocketmouse@archlinux ~]$ cat /etc/X11/xorg.conf Section "Monitor" Identifier "HDMI2" DisplaySize 526 296 Option "PreferredMode" "1920x1080" Option "Primary" "true" EndSection Section "Monitor" Identifier "VGA1" DisplaySize 367 278 Modeline "1024x768" 65.00 1024 1048 1184 1344 768 771 777 806 Option "PreferredMode" "1024x768" Option "RightOf" "HDMI2" EndSection Section "Device" Identifier "Card0" Driver "intel" #Driver "vesa" EndSection Section "ServerFlags" Option "BlankTime" "0" Option "StandbyTime" "0" Option "SuspendTime" "0" Option "OffTime" "0" EndSection [rocketmouse@archlinux ~]$ cat /usr/local/bin/xdh #!/bin/dash version=2017-08-10 exit_status=0 xdh_usage() { case $1 in too_many_arguments) printf "\ntoo many arguments\n" exit_status=127 ;; missing_argument) printf "\nmissing argument\n" exit_status=128 ;; unknown_argument) printf "\nunknown argument\n" exit_status=129 ;; unknown_second_argument) printf "\nunknown second argument\n" exit_status=130 ;; esac cat<<EOF X dualhead $version xdh --help display this help xdh --help default dislay default monitor presets LCD xdh --hdmi the same as 'default' xdh --hdmi default HDMI2 LCD monitor 1920x1080 16:9 and VGA1 CRT monitor off LCD left and CRT right xdh --dual the same as 'default' xdh --dual default HDMI2 LCD monitor 1920x1080 16:9 and VGA1 CRT monitor 1152x864 90Hz xdh --dual music-1 HDMI2 LCD monitor 1920x1080 16:9 and VGA1 CRT monitor 1440x960 86Hz xdh --dual music-2 HDMI2 LCD monitor 1920x1080 16:9 and VGA1 CRT monitor 1368x768 90Hz xdh --dual no-risk HDMI2 LCD monitor 1920x1080 16:9 and VGA1 CRT monitor 1024x768 60Hz CRT xdh --tube the same as 'default' xdh --tube default HDMI2 LCD monitor off 16:9 and VGA1 CRT monitor 1152x864 90Hz xdh --tube music-1 HDMI2 LCD monitor off 16:9 and VGA1 CRT monitor 1440x960 86Hz xdh --tube music-2 HDMI2 LCD monitor off 16:9 and VGA1 CRT monitor 1368x768 90Hz xdh --tube no-risk HDMI2 LCD monitor off 16:9 and VGA1 CRT monitor 1024x768 60Hz CRT same as LCD xdh --same the same as 'default' xdh --same default HDMI2 LCD monitor 1024x768 "4:3"and VGA1 CRT monitor 1024x768 60Hz xdh --same noscale HDMI2 LCD monitor 1024x768 "16:9"and VGA1 CRT monitor 1024x768 60Hz Misc xdh --list the same as 'default' xdh --list default lists the state of the outputs, showing the existing modes for each of them, with a '+' after the preferred modes and a '*' after the current mode xdh --list verbose lists verbose state of outputs xdh --list screen display screen information xdh --asra the same as 'default' xdh --asra default HDMI2 LCD aspect ratio 16:9 xdh --asra 4:3 HDMI2 LCD aspect ratio 4:3 xdh --mode the same as 'default' xdh --mode default add modes for xdh xdh --mode expunge remove modes for xdh xdh --xrdb display output of 'xrdb -query' xdh --xrdb xresorc edit using "\$EDITOR" and merge "\$HOME/.Xresources" Detailed output XDH_DETAILED=true xdh OPTION [OPTION] EOF } xdh_default_presets () { cat<<EOF X dualhead $version Default monitor presets LCD xdh --hdmi HDMI2 LCD monitor 1920x1080 16:9 and VGA1 CRT monitor off LCD left and CRT right xdh --dual HDMI2 LCD monitor 1920x1080 16:9 and VGA1 CRT monitor 1152x864 90Hz CRT xdh --tube HDMI2 LCD monitor off 16:9 and VGA1 CRT monitor 1152x864 90Hz CRT same as LCD xdh --same HDMI2 LCD monitor 1024x768 "4:3"and VGA1 CRT monitor 1024x768 60Hz EOF } xdh_mode () { in_use=$(xrandr | grep \* | grep xdh | awk '{ print $1 }') for mode_line in "1440x960_86hz_xdh_music-1, 170.77 1440 1544 1704 1968 960 961 964 1009"\ "1368x768_90hz_xdh_music-2, 134.55 1368 1464 1608 1848 768 769 772 809"\ "1152x864_90hz_xdh_default, 128.42 1152 1232 1360 1568 864 865 868 910"\ "1024x768_60hz_xdh_no-risk, 65.00 1024 1048 1184 1344 768 771 777 806" do name=$(echo $mode_line | cut -f1 -d,) case "$name" in "$in_use") ;; *) mode=$(echo $mode_line | cut -f2 -d,) case $XDH_DETAILED in true) echo "xrandr --delmode VGA1 $name" xrandr --delmode VGA1 "$name" echo "xrandr --rmmode $name" xrandr --rmmode "$name" ;; *) xrandr --delmode VGA1 "$name" 2>/dev/null xrandr --rmmode "$name" 2>/dev/null ;; esac case $1 in add) xrandr --newmode "$name" $mode -hsync -vsync &&\ xrandr --addmode VGA1 "$name" exstat=$? output=$(expr $exit_status + $exstat) exit_status=$output ;; esac ;; esac done return $exit_status } hdmi2_aspect_ratio () { case $1 in 4:3) scale=1.33333333x1 ;; *) scale=1x1 ;; esac xrandr --output HDMI2 --scale $scale } xdh_xrandr () { case "$1" in off) xrandr --output VGA1 --off --output HDMI2 --mode "$2" ;; *) case $2 in off) xrandr --output VGA1 --mode "$1" --output HDMI2 --off ;; *) xrandr --output VGA1 --mode "$1" --$2 HDMI2 --output HDMI2 --mode "$3" ;; esac ;; esac } case $1 in --help) case $2 in default) xdh_default_presets ;; *) xdh_usage ;; esac exit ;; --xrdb) case $3 in "") case $2 in "") xrdb -query ;; xresorc) printf "xrdb -query\n" xrdb -query "$EDITOR" "$HOME/.Xresources" printf "\nxrdb -merge \"$HOME/.Xresources\"\n" xrdb -merge "$HOME/.Xresources" printf "\nxrdb -query\n" xrdb -query ;; *) xdh_usage unknown_second_argument ;; esac ;; *) xdh_usage too_many_arguments ;; esac exit $exit_status ;; esac arg1=${1:-no_argument} arg2=${2:-default} arg3=${3:-no_argument} case $arg3 in no_argument) case $arg1 in --hdmi) case $arg2 in default) xdh_mode add &&\ xdh_xrandr off "1920x1080" &&\ hdmi2_aspect_ratio 16:9 ;; *) xdh_usage unknown_second_argument ;; esac ;; --dual) case $arg2 in default) xdh_mode add &&\ xdh_xrandr "1152x864_90hz_xdh_default" right-of "1920x1080" &&\ hdmi2_aspect_ratio 16:9 ;; music-1) xdh_mode add &&\ xdh_xrandr "1440x960_86hz_xdh_music-1" right-of "1920x1080" &&\ hdmi2_aspect_ratio 16:9 ;; music-2) xdh_mode add &&\ xdh_xrandr "1368x768_90hz_xdh_music-2" right-of "1920x1080" &&\ hdmi2_aspect_ratio 16:9 ;; no-risk) xdh_mode add &&\ xdh_xrandr "1024x768_60hz_xdh_no-risk" right-of "1920x1080" &&\ hdmi2_aspect_ratio 16:9 ;; *) xdh_usage unknown_second_argument ;; esac ;; --same) case $arg2 in default) xdh_mode add &&\ xdh_xrandr "1024x768_60hz_xdh_no-risk" same-as "1024x768" &&\ hdmi2_aspect_ratio 4:3 ;; noscale) xdh_mode add &&\ xdh_xrandr "1024x768_60hz_xdh_no-risk" same-as "1024x768" &&\ hdmi2_aspect_ratio 16:9 ;; *) xdh_usage unknown_second_argument ;; esac ;; --tube) case $arg2 in default) xdh_mode add &&\ xdh_xrandr "1152x864_90hz_xdh_default" off &&\ hdmi2_aspect_ratio 16:9 ;; music-1) xdh_mode add &&\ xdh_xrandr "1440x960_86hz_xdh_music-1" off &&\ hdmi2_aspect_ratio 16:9 ;; music-2) xdh_mode add &&\ xdh_xrandr "1368x768_90hz_xdh_music-2" off &&\ hdmi2_aspect_ratio 16:9 ;; no-risk) xdh_mode add &&\ xdh_xrandr "1024x768_60hz_xdh_no-risk" off &&\ hdmi2_aspect_ratio 16:9 ;; *) xdh_usage unknown_second_argument ;; esac ;; --list) case $arg2 in default) xrandr ;; verbose) xrandr --verbose ;; screen) echo "xdpyinfo | grep screen -A2" xdpyinfo | grep screen -A2 echo "cat /sys/class/drm/card0-HDMI-A-2/edid | edid-decode | grep \"Detailed mode\" | cut -f2 -d, | sort -u" cat /sys/class/drm/card0-HDMI-A-2/edid | edid-decode | grep "Detailed mode" | cut -f2 -d, | sort -u echo "cat /sys/class/drm/card0-VGA-1/edid | edid-decode | grep \"Detailed mode\" | cut -f2 -d, | sort -u" cat /sys/class/drm/card0-VGA-1/edid | edid-decode | grep "Detailed mode" | cut -f2 -d, | sort -u ;; *) xdh_usage unknown_second_argument ;; esac ;; --asra) case $arg2 in default) hdmi2_aspect_ratio 16:9 ;; 4:3) hdmi2_aspect_ratio 4:3 ;; *) xdh_usage unknown_second_argument ;; esac ;; --mode) case $arg2 in default) xdh_mode add ;; expunge) xdh_mode ;; *) xdh_usage unknown_second_argument ;; esac ;; no_argument) xdh_usage missing_argument ;; *) xdh_usage unknown_argument ;; esac ;; *) xdh_usage too_many_arguments ;; esac exit $exit_status [rocketmouse@archlinux ~]$ cat /usr/local/bin/xdh-feh #!/bin/dash rp=$(echo $1 | cut -d\ -f1) on=$(echo $1 | cut -d\ -f2) f1=$(echo $1 | cut -d\ -f5) f2=$(echo $1 | cut -d\ -f6) f3=$(echo $1 | cut -d\ -f7) f4=$(echo $1 | cut -d\ -f8) f5=$(echo $1 | cut -d\ -f9) f6=$(echo $1 | cut -d\ -f10) f7=$(echo $1 | cut -d\ -f11) f8=$(echo $1 | cut -d\ -f12) f9=$(echo $1 | cut -d\ -f13) xdh_feh_wrapper () { case $f1 in "") ;; *) feh $f1 $f2 $f3 $f4 $f5 $f6 $f7 $f8 $f9 ;; esac } case $on in xdh) x1=$(echo $1 | cut -d\ -f3) x2=$(echo $1 | cut -d\ -f4) xdh "$x1" "$x2" &&\ xdh_feh_wrapper ;; esac case $(xrandr | grep HDMI2 | grep disconnected) in "") # HDMI2 connected case $(xrandr | grep VGA1 | grep disconnected) in "") # VGA1 connected case $(xrandr | grep VGA1 | grep -v disconnected | grep connected | awk '{ print $3 }' | cut -c1) in "(") # VGA1 off case $x1 in --tube) xdh --dual "$x2" &&\ xdh_feh_wrapper ;; esac "$HOME"/.customization/restart-panels-lcd.sh "$rp" 2>/dev/null ;; *) # VGA1 on case $(xrandr | grep HDMI2 | grep -v disconnected | grep connected | awk '{ print $3 }' | cut -c1) in "(") # HDMI2 off case $x1 in --hdmi|--dual) xdh --tube "$x2" &&\ xdh_feh_wrapper ;; esac "$HOME"/.customization/restart-panels-lcd.sh "$rp" 2>/dev/null ;; *) # VGA1 on and HDMI2 on case $x1 in --same) "$HOME"/.customization/restart-panels-lcd.sh "$rp" 2>/dev/null ;; *) # --dual or "" to restart panels only "$HOME"/.customization/restart-panels-lcd.sh "$rp-alt" 2>/dev/null ;; esac ;; esac ;; esac ;; *) # VGA1 disconnected case $x1 in --tube) xdh --dual "$x2" &&\ xdh_feh_wrapper ;; esac "$HOME"/.customization/restart-panels-lcd.sh "$rp" 2>/dev/null ;; esac ;; *) # HDMI2 disconnected case $x1 in --hdmi|--dual) xdh --tube "$x2" &&\ xdh_feh_wrapper ;; "") xdh --tube default &&\ xdh_feh_wrapper ;; esac "$HOME"/.customization/restart-panels-lcd.sh "$rp" 2>/dev/null ;; esac exit
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180120144301.170645e6>