Last active
April 14, 2024 00:26
-
-
Save felipsmartins/04b47a445082d25904a99ebdff010084 to your computer and use it in GitHub Desktop.
xrandr posicionamento telas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
set -euo pipefail | |
# ---------------------------------------------------------------------------------------- | |
# https://man.archlinux.org/man/xrandr.1 | |
# https://wiki.ubuntu.com/X/Config/Resolution | |
CLIPS_DIR=~/clips | |
# ASUS TUF (MAIN) DISPLAY POS | |
ASUS_TUF_POS=2560x2160 | |
# SAMSUNG - DISPLAY POS | |
# Se quisermos alinhar o eixo Y do ASUS com eixo Y do monitor de cima: | |
# Como os dois tem resoluções (largura em pixels nesse caso) diferentes, temos de saber a diferença entre eles, então: | |
# SAMSUNG_WIDTH=3840; ASUS_WIDTH=1920; DIFF=(SAMSUNG_WIDTH - ASUS_WIDTH) -> 1920 | |
# SHIFT=(1920/2) -> 960 | |
# SHIFT=2560-SHIFT -> 1600 # essa será a posição inicial no eixo Y do SAMSUNG se quiséssemos alinhar os eixos Y de cada monitor | |
SAMSUNG_POS=2068x0 | |
LG_WIDE_POS=0x2160 | |
function enable_all_monitors() { | |
xrandr --auto \ | |
--output DisplayPort-0 --primary --mode 1920x1080 --rate 144 --pos $ASUS_TUF_POS \ | |
--output HDMI-A-0 --mode 3840x2160 --rate 60 --pos $SAMSUNG_POS \ | |
--output DisplayPort-1 --mode 2560x1080 --rate 75 --pos $LG_WIDE_POS | |
} | |
function enable_game_monitor_only() { | |
# enable just one monitor (cause VRR issues on Xorg) | |
xrandr --output HDMI-A-0 --off --output DisplayPort-1 --off --output DisplayPort-0 --primary --mode 1920x1080 --rate 144 | |
} | |
function enable_screen_recorder() { | |
# examples: https://git.dec05eba.com/gpu-screen-recorder/tree/scripts | |
MONITOR="DisplayPort-0" # or: $__GL_SYNC_DISPLAY_DEVICE | |
DEFAULT_AUDIO_OUTPUT=$(pactl get-default-sink) | |
DEFAULT_AUDIO_INPUT=$(pactl get-default-source) | |
gpu-screen-recorder -o $CLIPS_DIR -c mp4 -f 60 -r 15 -w "$MONITOR" -a "$DEFAULT_AUDIO_OUTPUT.monitor|$DEFAULT_AUDIO_INPUT" | |
} | |
############################################################################### | |
# Bootstrap | |
############################################################################### | |
# usage: | |
# all monitors on: this_script_name.sh | |
# just main monitor on: this_script_name.sh gamemode | |
# just main monitor on + replay mode: this_script_name.sh gamemode replay | |
# values: 0, 1 | |
MODE=${1:-""} | |
# values: replay | |
REPLAY_ENABLED=${2:-""} | |
if [ "$MODE" = "gamemode" ]; then | |
enable_game_monitor_only | |
if [ "$REPLAY_ENABLED" = "replay" ]; then | |
enable_screen_recorder | |
fi | |
else | |
enable_all_monitors | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment