Advertisement
Ri0n

Untitled

Mar 4th, 2024 (edited)
921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.22 KB | None | 0 0
  1. ini file located in etc/
  2.  
  3.  
  4. case "${ACTION}" in
  5.     "listModes")
  6.         echo "$(</userdata/system/videomodes.conf)"
  7.         xrandr --listModes | sed -e 's/\*$//' | sed -e 's/^\([^ ]*\) \(.*\)$/ \1:\2/' | sed -e "/\b\(SR\)\b/d"
  8.         ;;
  9.     "setMode")
  10.         MODE=$1
  11.         read WIDTH HEIGHT PARTHZ INI <<< $(echo $MODE | awk -F'[x.:]' '{print $1, $2, $3, $4, $5}')
  12.         INI=$(echo "$INI" | sed 's/00//')
  13.         if [[ ${INI} ]]; then
  14.             switchres ${WIDTH} ${HEIGHT} ${PARTHZ} -f ${WIDTH}x${HEIGHT}@${PARTHZ} -i ${INI}.ini -s -k
  15.         else
  16.             switchres ${WIDTH} ${HEIGHT} ${PARTHZ} -f ${WIDTH}x${HEIGHT}@${PARTHZ} -s -k
  17.         fi
  18.         ;;
  19.     "defineMode")
  20.         MODE=$1
  21.         read WIDTH HEIGHT PARTHZ INI <<< $(echo $MODE | awk -F'[x.:]' '{print $1, $2, $3, $4, $5}')
  22.         RES_MODE="${WIDTH}x${HEIGHT}"
  23.         if [[ ${INI} ]]; then
  24.             MODE_switchres=$(switchres ${WIDTH} ${HEIGHT} ${PARTHZ} -f ${WIDTH}x${HEIGHT}@${PARTHZ} -i ${INI}) #> /dev/null 2>/dev/null
  25.         else
  26.             MODE_switchres=$(switchres ${WIDTH} ${HEIGHT} ${PARTHZ} -f ${WIDTH}x${HEIGHT}@${PARTHZ}) #> /dev/null 2>/dev/null
  27.         fi
  28.         MODELINE_CUSTOM=$(echo "$MODE_switchres" | sed -n 's/.*Modeline "[^"]*" \([0-9.]\+\) \([0-9 ]\+\) \(.*\)/\1 \2 \3/p')
  29.         OUTPUT=$(xrandr --listConnectedOutputs | grep -E '\*$' | sed -e 's/\*$//' | head -1)
  30.         xrandr -display :0.0 --newmode ${RES_MODE} ${MODELINE_CUSTOM}
  31.         xrandr -display :0.0 --addmode ${OUTPUT} ${RES_MODE}
  32.         ;;
  33.        
  34.  
  35. ini file located in /userdata/system/Batocera-CRT-Script/switchres_overrides/
  36.        
  37.        
  38. case "${ACTION}" in
  39.     "listModes")
  40.         echo "$(</userdata/system/videomodes.conf)"
  41.         xrandr --listModes | sed -e 's/\*$//' | sed -e 's/^\([^ ]*\) \(.*\)$/ \1:\2/' | sed -e "/\b\(SR\)\b/d"
  42.         ;;
  43.     "setMode")
  44.         MODE=$1
  45.         read WIDTH HEIGHT PARTHZ INI <<< $(echo $MODE | awk -F'[x.:]' '{print $1, $2, $3, $4, $5}')
  46.         INI=$(echo "$INI" | sed 's/00//' | tr -d '[:space:]')
  47.         if [[ ${INI} ]]; then
  48.             switchres ${WIDTH} ${HEIGHT} ${PARTHZ} -f ${WIDTH}x${HEIGHT}@${PARTHZ} -i /userdata/system/Batocera-CRT-Script/switchres_overrides/${INI}.ini -s -k
  49.         else
  50.             switchres ${WIDTH} ${HEIGHT} ${PARTHZ} -f ${WIDTH}x${HEIGHT}@${PARTHZ} -s -k
  51.         fi
  52.         ;;
  53.     "defineMode")
  54.         MODE=$1
  55.         read WIDTH HEIGHT PARTHZ INI <<< $(echo $MODE | awk -F'[x.:]' '{print $1, $2, $3, $4, $5}')
  56.         RES_MODE="${WIDTH}x${HEIGHT}"
  57.         if [[ ${INI} ]]; then
  58.             MODE_switchres=$(switchres ${WIDTH} ${HEIGHT} ${PARTHZ} -f ${WIDTH}x${HEIGHT}@${PARTHZ} -i /userdata/system/Batocera-CRT-Script/switchres_overrides/${INI}) #> /dev/null 2>/dev/null
  59.         else
  60.             MODE_switchres=$(switchres ${WIDTH} ${HEIGHT} ${PARTHZ} -f ${WIDTH}x${HEIGHT}@${PARTHZ}) #> /dev/null 2>/dev/null
  61.         fi
  62.         MODELINE_CUSTOM=$(echo "$MODE_switchres" | sed -n 's/.*Modeline "[^"]*" \([0-9.]\+\) \([0-9 ]\+\) \(.*\)/\1 \2 \3/p')
  63.         OUTPUT=$(xrandr --listConnectedOutputs | grep -E '\*$' | sed -e 's/\*$//' | head -1)
  64.         xrandr -display :0.0 --newmode ${RES_MODE} ${MODELINE_CUSTOM}
  65.         xrandr -display :0.0 --addmode ${OUTPUT} ${RES_MODE}
  66.         ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement