2013年01月24日 Ctrl + Alt + plus/minus to change resolution for X Window System [長年日記]
_ Ctrl + Alt + plus/minus to change resolution for X Window System
I can change resolution for X Window System to use Ctrl+Alt+XK_KP_{Add|Subtract} on desktop computer. But laptop computer don't have XK_KP_something. So I try to use Ctrl+Alt+XK_{plus|minus} with fvwm to change resolution.
xrandr_plus.sh
#! /bin/sh # modenum_total=`xrandr |\ egrep '^ *[0-9]*x[0-9]*' |\ wc -l` # current_modenum=`xrandr |\ egrep '^ *[0-9]*x[0-9]*' |\ tac |\ cat -n |\ tr '\t' ' ' |\ tr -s ' ' |\ egrep '\*' |\ cut -d ' ' -f 2` current_modenum=`expr ${current_modenum} - 1` # next_modenum=`expr ${current_modenum} + 1` next_modenum=`expr ${next_modenum} % ${modenum_total}` # modenum=0 for i in `xrandr |\ egrep '^ *[0-9]*x[0-9]*' |\ tr -s ' ' |\ cut -d ' ' -f 2 |\ tac` do if [ ${modenum} -eq ${next_modenum} ] then modestr=$i fi modenum=`expr ${modenum} + 1` done # xrandr --output "LVDS" --mode ${modestr}
xrandr_minus.sh
#! /bin/sh # modenum_total=`xrandr |\ egrep '^ *[0-9]*x[0-9]*' |\ wc -l` # current_modenum=`xrandr |\ egrep '^ *[0-9]*x[0-9]*' |\ tac |\ cat -n |\ tr '\t' ' ' |\ tr -s ' ' |\ egrep '\*' |\ cut -d ' ' -f 2` current_modenum=`expr ${current_modenum} - 1` # current_modenum=`expr ${current_modenum} + ${modenum_total}` next_modenum=`expr ${current_modenum} - 1` next_modenum=`expr ${next_modenum} % ${modenum_total}` # modenum=0 for i in `xrandr |\ egrep '^ *[0-9]*x[0-9]*' |\ tr -s ' ' |\ cut -d ' ' -f 2 |\ tac` do if [ ${modenum} -eq ${next_modenum} ] then modestr=$i fi modenum=`expr ${modenum} + 1` done # xrandr --output "LVDS" --mode ${modestr}
.fvwmrc
Key minus A CM Exec "xrandr_minus" exec xrandr_minus.sh Key semicolon A CM Exec "xrandr_plus" exec xrandr_plus.sh