Statistik: Postat av eson57 — 28 feb 2024, 10:46
Kod:
#! /bin/bash#PROTOCOL=$(echo "$XDG_SESSION_TYPE")if [[ $PROTOCOL != "x11" ]]; thenecho "-As the protocol is $PROTOCOL, we cannot continue (only x11 is supported)"echoexitfi##====================================================================================function usage {less << EODusage: $CMDNAME [function] [WIDTHxHEIGTH]If "WIDTHxHEIGHT" is specified, this automatically implies a "set" function.FUNCTIONS:-----------c | --currentShow current resolution, this is also what is shown if "$CMDNAME" is runwithout any specified function.-d | --defineDefine a new resolution for this monitor. The specified resolution mustbe defined by the VESA standard. If the specified resolution is alreadydefined, a message is written and no further definition is made.--dryrunPerforms all the actions specified except that no changes are made.-h | --helpShow this.-i | --inter | --interactiveAll defined resolutions for this monitor is shown and it is possibleto select one of them, by entering its number. It is also possible toenter "0" and then specify which resolution that is wanted.Running this and selecting the number for 1920x1080 (eg. "1" ) has thesame result as running "$CMDNAME -l" to see that it is "1" and then run"$CMDNAME 1" (or "$CMDNAME 1920x1080" first.Running interactive and specifying "0" and then enter "1920x1080" hasthe same result as running "xd --define 1920x1080".-l | --listList all modes are currently defined for this monitor. It only shows allresolutions that are defined for the monitor, it does not show all possibleresolutions.--rm | --removeRemove a defined resolution. Generally there is no need for this functionas defined resolutions is removed by a reboot. It is not possible to removeany resolution defined by the system.This function sometimes misses, due to a bug in xrandr, but however a rebootworks.-r | --resetReset monitor to the previous resolution. Most often this is the originalresolution.The "previus" resolution is only saved the first time a change of resolutionis made. Therefore a reset after a number of changes only resets to the firstresolution.The "reset-file" is deleted after each reset, but can however remain after acertain reboot.-v | --vesaList possible resolutions that are defined by VESA. This does not implythat the resolutions are supported by the actual monitor.The purpose of this function is not to be a complete list of all possibleresolutions, but to give tips on the most common ones if none are availablevia "-l" for the monitor in question.-m MON | --mon=MON | --monitor=MONSpecifies which monitor to operate on. If not specified it is assumedthat only one monitor exists.Both "-c" and "-l" performs an exit when the info is shown. If both are specifiedonly the first function will thus be performed. This is also the same when a resolution("set") is specified. A resolution setting is always superseeded if "-c" or "-l" is specified.FILES:The command uses a file called ".xr" in the users home-directory, so do not usethis name for anything else.EXAMPLES:$CMDNAME 5Setup this monitor to run with the resolution defined by line #5 asshown by "$CMDNAME -l".$CMDNAME 1920x1080Setup this monitor to run with the resolution "1920x1080". It only works if1920x1080 is already defined. Check with "--list" and use "--define" if itis not.$CMDNAME -c | --currentShow current resolution - this is also default if no other action is specfied.$CMDNAME -d 1920x1080 | --define=1920x1080Define the resolution "1920x1080" for this monitor and change to it. If 1920x1080is already defined, a new definition will not be made.$CMDNAME -l | --listList all modes are currently defined for this monitor.$CMDNAME -m MON | --mon=MON | --monitor=MONSpecify that the monitor to be used are for example "HDMI-1" or "VGA". Of coursea function to be performed must also be specified, otherwise only the currentresolution will be shown.If there only exist one monitor, it is not needed to specify this.$CMDNAME -v | --vesaShow the standard resolutions defined by VESA, as I have found so far. This script will not try define anything else. Edit this script and add extra resolutions ifyou want and know what you are doing.EOD}#function checkIfResolIsDefined {RSL=$1ResolIsDefined=falseif [[ $PROTOCOL == "x11" ]]; thenLINES=$(xrandr | sed -e 's/^[[:space:]]*//' | grep "^[0-9]" | awk '{ print $1 }')elif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...RESOL="<wayland>"return 1else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...RESOL="<other>"return 1fiorigIFS=$IFSIFS=$'\n'for LINE in $LINES; doif [[ $RSL == $LINE ]]; thenResolIsDefined=trueRESOL=$RSLbreakfidoneIFS=$origIFSif [[ $ResolIsDefined == false ]]; thenreturn 1fireturn 0}function currentModes {SPECIFIED_MODE=$1if [[ $PROTOCOL == "x11" ]]; thenMODES=$(xrandr | sed -e 's/^[[:space:]]*//' | grep "^[0-9]" | awk '{ print $1 }')elif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...MODES="<wayland>"return 1else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...MODES="<other>"return 1fifor MODE in $MODES; doif [[ $SPECIFIED_MODE == $MODE ]]; thenreturn 0fidonereturn 1}function doReset {getMonitorif [[ -r ~/.xr ]]; thenRESOL=$(cat ~/.xr)echo "-Resetting resolution to $RESOL"echo "=> xrandr $OPT --output $MONITOR --mode $RESOL"xrandr $OPT --output $MONITOR --mode $RESOLrm ~/.xrelseecho "-No previous resolution found..."fiecho}function findMonitor {NUM=$1if [[ $PROTOCOL == "x11" ]]; thenxrandr --listmonitors | tail -n +2 | sed 's/^[[:space:]]*//' | grep "^$NUM:" | awk '{ print $4 }'elif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...echo "<wayland>"else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...echo "<unknown>"fi}function getMonitor {#if [[ -z $MONITOR ]]; thenif [[ $PROTOCOL == "x11" ]]; thenNMON=$(xrandr --listmonitors | grep "Monitors:" | awk '{ print $2 }')elif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...NMON="0"else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...NMON="0"fiif [[ $NMON -gt 1 ]]; thenecho "-More than one monitor exists, you have specify which one to use with name or number"echo "-Existing monitors:"echoshowMonitorsechoread -p "_Monitor: " INif [[ $PROTOCOL == "x11" ]]; thenMONITORS=$(xrandr --listmonitors | sed -e 's/^[[:space:]]*//' | grep "^[0-9]" | awk '{ print $4 }')elif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...MONITORS="<wayland>"else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...MONITORS="<other>"fiisnum $INif [[ $? == 0 ]]; thenMONITOR=$(findMonitor $IN)elseMONITOR=$(toupper $IN)fiif [[ ! -z $MONITOR ]]; thenmonitorExist $MONITORif [[ $? != 0 ]]; thenecho "-Specified monitor $MONITOR not found..."echoexitfiecho "-Monitor specified as $MONITOR"echoelseecho "-Specified monitor not found..."echoexitfielseif [[ $PROTOCOL == "x11" ]]; thenMONITOR=$(xrandr | grep -e " connected [^(]" | cut -d\ -f1 | xargs)echo "-Monitor implicitly set to $MONITOR (only 1 exists)..."elif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...MONITOR="<wayland>"else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...MONITOR="<other>"fifielsemonitorExist $MONITORif [[ $? == 0 ]]; thenecho "-Monitor specified as $MONITOR"elseecho "-Monitor $MONITOR does not exist..."echoexitfifi}function isnum {if [[ $1 =~ ^[0-9]+$ ]]; thenreturn 0fireturn 1}function listDefined {#xrandr | grep "^ "[0-9] | grep -v noneecho '-Preferred resolutions is denoted by "+" (plus)'echo '-Current resolution is denoted by a "*" (asterisk)'echo '-A resolution that ends with an "i" means "interlaced" and a "p" means "progressive"'echo "-(Interlaced is mostly used for CRT monitors)"echoif [[ $PROTOCOL == "x11" ]]; thenxrandr | sed -e 's/^[[:space:]]*//' | grep "^[0-9]" | cat -nelif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...echo "<wayland>"else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...echo "<unknown>"fiecho}function monitorExist {MN=$1FOUNDMON=falseif [[ $PROTOCOL == "x11" ]]; thenMONITORS=$(xrandr --listmonitors | tail -n +2 | awk '{ print $4 }')for MONIT in $MONITORS; doif [[ $MONIT == $1 ]]; thenFOUNDMON=truereturn 0fidoneelif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...echo "<wayland>"else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...echo "<unknown>"fireturn 1}function number2resol {IN=$1NumToResol=falseif [[ $PROTOCOL == "x11" ]]; then#LINES=$(xrandr | grep "^ "[0-9] | cat -n | sed -E 's/^[[:space:]]+//')LINES=$(xrandr | sed -e 's/^[[:space:]]*//' | grep "^[0-9]" | cat -n)elif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...RESOL="<wayland>"return 1else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...RESOL="<other>"return 1fiorigIFS=$IFSIFS=$'\n'for LINE in $LINES; doNUM=$(echo $LINE | awk '{ print $1 }')if [[ $NUM == $IN ]]; thenNumToResol=truebreakfidoneIFS=$origIFSif [[ $NumToResol == true ]]; thenRESOL=$(echo $LINE | awk '{ print $2 }')elseRESOL=""return 1fireturn 0}function removeResol {RESOL=$1NMON=$(xrandr --listmonitors | grep "Monitors:" | awk '{ print $2 }')if [[ $NMON -gt 1 ]]; thenecho "-More than one monitor exists, you have specify which one to use with name or number"echo "-Existing monitors:"echoshowMonitorsechoread -p "_Monitor: " INisnum $INif [[ $? == 0 ]]; thenMONITOR=$(findMonitor $IN)elseMONITOR=$(toupper $IN)fiif [[ ! -z $MONITOR ]]; thenmonitorExist $MONITORif [[ $? != 0 ]]; thenecho "-Specified monitor $MONITOR not found..."echoexitfiecho "-Monitor specified as $MONITOR"echoelseecho "-Specified monitor not found..."echoexitfielseMONITOR=$(xrandr | grep -e " connected [^(]" | cut -d\ -f1 | xargs)ficheckIfResolIsDefined $RESOLif [[ $? == 0 ]]; thenecho "=> xrandr $OPT --delmode $MONITOR $RESOL 2> /dev/null"xrandr $OPT --delmode $MONITOR $RESOL 2> /dev/null echo "=> xrandr $OPT --rmmode $RESOL 2> /dev/null" xrandr $OPT --rmmode $RESOL 2> /dev/nullif [[ $? != 0 ]]; thenecho "-Remove failed, if it is a user defined resolution it will be removed at next reboot..."fiechoexitelseecho "-Resolution $RESOL is not defined..."echoexitfi}function setupDefine {ASK=$1MODE=$2if [[ $ASK == "yes" ]]; thenread -p '_Enter "WIDTHxHEIGHT": ' MODEif [[ -z $MODE || $MODE == "q" || $MODE == "Q" ]]; thenechoexitfifiWxH=$(echo $MODE | awk -F \_ '{ print $1 }')checkIfResolIsDefined $MODEif [[ $? == 0 ]]; thenDEFINE=falseRESOL=$WxHecho "-Resolution $MODE is already defined for this monitor..."return 0fivesaStd $WxHif [[ $? != 0 ]]; thenecho "-Unsupported resolution (no such VESA standard) - $WxH..."echoexitficheckIfResolIsDefined $MODEDEFINE=trueFREQ=$(echo $MODE | awk -F _ '{ print $2 }')WIDTH=$(echo $WxH | awk -F x '{ print $1 }')HEIGHT=$(echo $WxH | awk -F x '{ print $2 }')#MODE=$(cvt $WIDTH $HEIGHT | grep -i modeline | awk '{ $1=""; print $0 }' | sed -E 's/^[[:space:]]+//')NAME=$(echo $MODE | awk '{ print $1 }' | sed 's/\"//g' | awk -F _ '{ print $1 }')LINE=$(echo $MODE | awk '{ $1=""; print $0 }' | sed -E 's/^[[:space:]]+//')MODELINE="$NAME $LINE"MODSET=trueRESOL=$WxHcurrentModes $WxH}function showCurrent {if [[ $PROTOCOL == "x11" ]]; thenCURRENT=$(xrandr | sed -e 's/^[[:space:]]*//' | grep "^[0-9]" | grep \* | awk '{ print $1 }')elif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...CURRENT="<wayland>"else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...CURRENT="<other>"fiecho "-Current resolution is: $CURRENT"echo}function showFunctions {if [[ $CURRENT == true ]]; thenecho " current - yes"elseecho " current - no"fiif [[ $HELP == true ]]; thenecho " help - yes"elseecho " help - no"fiif [[ $INTER == true ]]; thenecho " inter - yes"elseecho " inter - no"fiif [[ $LIST == true ]]; thenecho " list - yes"elseecho " list - no"fiif [[ $RESET == true ]]; thenecho " reset - yes"elseecho " reset - no"fiif [[ $RM == true ]]; thenecho " rm - yes"elseecho " rm - no"fiif [[ $VESA == true ]]; thenecho " vesa - yes"elseecho " vesa - no"fiif [[ $SPEC == true ]]; thenecho " spec - yes (specified resolution)"elseecho " spec - no (specified resolution)"fi}function showMonitors {if [[ $PROTOCOL == "x11" ]]; thenxrandr --listmonitors | grep -v Monitors:elif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...echo "<wayland>"else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...echo "<other>"fi}function toupper {echo $1 | awk '{ print toupper($0) }'}function vesaList {#cat << EOV This is not a complete list of all possible resolutions. It is only tips about common resolutions that possibly can be defined if there are to few pre defined as shown by "-l". To define resolutions other than these, the script must be edited. The idea behind this, is to prevent for unreasonable resolutions.EOV# 4:3echo " 4:3"echo " 3840x2880"echo " 3200x2400"echo " 2560x1920"echo " 2048x1536"echo " 1920x1440"echo " 1600x1200"echo " 1400x1050"echo " 1280x960"echo " 1024x768"echo " 800x600"echo " 640x480"echo# 5:4echo " 5:4"echo " 1280x1024"echo# 15:9echo " 15:9"echo " 1280x768"echo# 16:9echo " 16:9"echo " 5120x2880"echo " 4264x2400"echo " 3408x1920"echo " 2728x1536"echo " 2560x1440"echo " 2128x1200"echo " 1920x1080"echo " 1864x1050"echo " 1704x960"echo " 1360x768"echo " 1280x720"echo " 1064x600"echo " 848x480"echo# 16:10echo " 16:10"echo " 4608x2880"echo " 3840x2400"echo " 3072x1920"echo " 2456x1536"echo " 2304x1440"echo " 1920x1200"echo " 1728x1080"echo " 1680x1050"echo " 1536x960"echo " 1224x768"echo " 1152x720"echo " 960x600"echo " 768x480"echo}function vesaStd {wxh=$1## 4:3if [[ $wxh == 3840x2880 ]]; thenreturn 0elif [[ $wxh == 3200x2400 ]]; thenreturn 0elif [[ $wxh == 2560x1920 ]]; thenreturn 0elif [[ $wxh == 2048x1536 ]]; thenreturn 0elif [[ $wxh == 1920x1440 ]]; thenreturn 0elif [[ $wxh == 1600x1200 ]]; thenreturn 0elif [[ $wxh == 1400x1050 ]]; thenreturn 0elif [[ $wxh == 1280x960 ]]; thenreturn 0elif [[ $wxh == 1024x768 ]]; thenreturn 0elif [[ $wxh == 800x600 ]]; thenreturn 0elif [[ $wxh == 640x480 ]]; thenreturn 0# 5:4elif [[ $wxh == 1280x1024 ]]; thenreturn 0# 15:9elif [[ $wxh == 1280x768 ]]; thenreturn 0# 16:9elif [[ $wxh == 5120x2880 ]]; thenreturn 0elif [[ $wxh == 4264x2400 ]]; thenreturn 0elif [[ $wxh == 3408x1920 ]]; thenreturn 0elif [[ $wxh == 2728x1536 ]]; thenreturn 0elif [[ $wxh == 2560x1440 ]]; thenreturn 0elif [[ $wxh == 2128x1200 ]]; thenreturn 0elif [[ $wxh == 1920x1080 ]]; thenreturn 0elif [[ $wxh == 1864x1050 ]]; thenreturn 0elif [[ $wxh == 1704x960 ]]; thenreturn 0elif [[ $wxh == 1360x768 ]]; thenreturn 0elif [[ $wxh == 1280x720 ]]; thenreturn 0elif [[ $wxh == 1064x600 ]]; thenreturn 0elif [[ $wxh == 848x480 ]]; thenreturn 0# 16:10elif [[ $wxh == 4608x2880 ]]; thenreturn 0elif [[ $wxh == 3840x2400 ]]; thenreturn 0elif [[ $wxh == 3072x1920 ]]; thenreturn 0elif [[ $wxh == 2456x1536 ]]; thenreturn 0elif [[ $wxh == 2304x1440 ]]; thenreturn 0elif [[ $wxh == 1920x1200 ]]; thenreturn 0elif [[ $wxh == 1728x1080 ]]; thenreturn 0elif [[ $wxh == 1680x1050 ]]; thenreturn 0elif [[ $wxh == 1536x960 ]]; thenreturn 0elif [[ $wxh == 1224x768 ]]; thenreturn 0elif [[ $wxh == 1152x720 ]]; thenreturn 0elif [[ $wxh == 960x600 ]]; thenreturn 0elif [[ $wxh == 768x480 ]]; thenreturn 0elsereturn 1fi}##=================================================================================================#echoTEMP=`getopt -ocdhilm:rv --long current,define,dryrun,help,inter,interactive,list,mon:,monitor:,rm,remove,vesa,reset -n $(basename $0) -- "$@"`if [[ $? -ne 0 ]]; thenusageexitfieval set -- "$TEMP"#MODELINE="<not created as we are not defining a new mode>"RESNAME="<not created as we are not defining a new mode>"#OPT=""CURR=falseCURRENT=falseDEFINE=falseDRYRUN=falseHELP=falseINTER=falseLIST=falseNONE=trueRESET=falseRM=falseSPEC=falseVESA=falseMODSET=falselet COUNT=0CMDNAME=$(basename $0)while true; docase $1 in-c|--current)NONE=falselet COUNT+=1CURRENT=trueshift;;-d|--define)DEFINE=trueshift;;--dryrun)DRYRUN=trueOPT="--dryrun "shift;;-h|--help)NONE=falselet COUNT+=1HELP=trueshift;;-i|--inter|--interactive)NONE=falselet COUNT+=1INTER=trueshift;;-l|--list)NONE=falselet COUNT+=1LIST=trueshift;;-m|--mon|--monitor)shiftMONITOR=$(toupper $1)shift;;--rm|--remove)NONE=falseRM=trueshift;;-v|--vesa)NONE=falselet COUNT+=1VESA=trueshift;;-r|--reset)NONE=falselet COUNT+=1RESET=trueshift;;--)shiftbreak;;*)echo "-Got a star... [$1]"exit;;esacdoneP1=$1P2=$2P3=$3P4=$4if [[ ! -z $P1 ]]; thenNONE=falseSPEC=true#RESOL=$P1let COUNT+=1fiif [[ $COUNT -gt 1 ]]; thenecho "-Only possible to specify one function..."echo "-Specified functions:"showFunctionsechoexitfi##=================================================================================================#ResolIsDefined=unknownNumToResol=unknown#if [[ $CURRENT == true || $NONE == true ]]; thenshowCurrentexitelif [[ $HELP == true ]]; thenusageexitelif [[ $LIST == true ]]; thenlistDefinedexitelif [[ $RESET == true ]]; thendoResetexitelif [[ $RM == true ]]; thenremoveResol $P1exitelif [[ $VESA == true ]]; thenvesaListexitelse# -If $INTER or specified resolution - find which monitorgetMonitorfi##=================================================================================================#if [[ $INTER == true ]]; then## -Interactive was specified, so we have to show defined resolutions and ask about which to use.#if [[ $PROTOCOL == "x11" ]]; thenlistDefinedecho '_Enter a number that exists to change to that resolution, "0" to define a new resolution or "q" to quit.'echo "-It is not possible to enter resolution directly here!!"read -p '_Number: ' INif [[ -z $IN || $IN == "q" || $IN == "Q" ]]; thenechoexitelif [[ $IN != 0 ]]; thennumber2resol $INif [[ $? != 0 ]]; thenecho "-No such resolution number - $IN..."echo exitfielif [[ $IN == 0 ]]; thenDEFINE=truesetupDefine "yes"fielif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...echo "-Session protocol is Wayland - not possible to fix yet-1..."echoexitelse# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...echo "-Session protocol is unknown - not possible to fix..."echoexitfielif [[ $SPEC == true ]]; then## -A resolution was specified in the command line, so we will check it out and possibly use it.#X=$(echo $P1 | grep "x")if [[ ! -z $X ]]; thencheckIfResolIsDefined $P1if [[ $DEFINE == true ]]; thenif [[ $ResolIsDefined == false ]]; thensetupDefine "no" $P1elseecho "-Resolution $P1 is already defined for this monitor..."fielseif [[ $ResolIsDefined == false ]]; thenecho "-Undefined resolution for this monitor - $P1..."echoexitfiRESOL=$P1fielif [[ ! -z $P1 ]]; thennumber2resol $P1if [[ $? != 0 ]]; thenecho "-No such resolution number - $P1 (check with \"$(basename $0) -l\"..."echo exitelif [[ $DEFINE == true ]]; thenecho "-Resolution $RESOL is already defined for this monitor..."fielse# We should never reach here, but add a message in case of...echo "-Unknown resolution error..."fifiCURRENT=$(xrandr | sed -e 's/^[[:space:]]*//' | grep "^[0-9]" | grep \* | awk '{ print $1 }')if [[ $CURRENT == $RESOL ]]; thenecho "-Specified resolution is the same as current - no reason to change..."echoexitfi#if [[ $MODSET == true ]]; thenRESNAME=$(echo $MODELINE | awk '{ print $1 }' | sed 's/"//g')fiTRACE=falseif [[ $TRACE == true ]]; thenechoecho "IN: $IN"echo "SPEC: $SPEC"echo "FOUNDNUM: $FOUNDNUM"echo "ResolIsDefined: $ResolIsDefined"echo "NumToResol: $NumToResol"echo "DEFINE: $DEFINE"echo "MONITOR: $MONITOR"echo "MODELINE: $MODELINE"echo "RESNAME: $RESNAME"echo "RESOL: $RESOL"echofi#CURRENT=$(xrandr | sed -e 's/^[[:space:]]*//' | grep "^[0-9]" | grep \* | awk '{ print $1 }')if [[ ($SPEC == true && $ResolIsDefined == true) || ($NumToResol == true) ]]; thenif [[ $PROTOCOL == "x11" ]]; thenecho "-Setting resolution to $RESOL"echo "=> xrandr $OPT --output $MONITOR --mode $RESOL"xrandr $OPT --output $MONITOR --mode $RESOLif [[ ! -e ~/.xr ]]; thenecho $CURRENT > ~/.xrfielif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...echo "-Session protocol is Wayland - not possible to fix yet-2..."else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...echo "-Session protocol is unknown - not possible to fix..."fielif [[ $DEFINE == true ]]; thenif [[ $PROTOCOL == "x11" ]]; thenif [[ $? != 0 ]]; thenecho "-Mode $WxH already exist, will not redefine it..."elseecho "-Defining mode $RESOL"echo "=> xrandr $OPT --newmode $MODELINE"xrandr $OPT --newmode $MODELINE#echo "=> xrandr $OPT --addmode $MONITOR $RESNAME"xrandr $OPT --addmode $MONITOR $RESNAMEfiecho "-Setting resolution to $RESOL"echo "=> xrandr $OPT --output $MONITOR --mode $RESOL"xrandr $OPT --output $MONITOR --mode $RESOLif [[ ! -e ~/.xr ]]; thenecho $CURRENT > ~/.xrfielif [[ $PROTOCOL == "wayland" ]]; then# We will never reach here as "$PROTOCOL==wayland" has already performed an exit...# It is just here for future development...echo "-Session protocol is Wayland - not possible to fix yet..."else# We will never reach here as "$PROTOCOL==other" has already performed an exit...# It is just here for future development...echo "-Session protocol is unknown - not possible to fix..."fielseecho "-Resolution $IN not found..."fiecho
Statistik: Postat av Osprey — 03 feb 2024, 02:21
Statistik: Postat av Surfaren — 12 jan 2024, 22:35
Statistik: Postat av anth — 12 jan 2024, 22:07
Statistik: Postat av Osprey — 11 jan 2024, 15:22
Kod:
# make all windows floatfor_window [class=".*"] floating enable
Statistik: Postat av anth — 07 jan 2024, 11:32
Kod:
xr 1920x1080
Statistik: Postat av Osprey — 06 jan 2024, 02:29