WIP: Production release #6
66
content/posts/cs2_4-3_resolution.md
Normal file
66
content/posts/cs2_4-3_resolution.md
Normal file
@ -0,0 +1,66 @@
|
||||
+++
|
||||
title = "Fixing 4:3 Resolution in CS2 on Linux with NVIDIA GPU"
|
||||
date = 2024-10-17
|
||||
description = "How I fixed the 4:3 resolution in CS2 with an NVIDIA graphics card and Linux"
|
||||
+++
|
||||
|
||||
I don't consider myself a gamer, but I've been playing the Counter-Strike series since CS 1.6. Every now and then, I enjoy staying up all night playing this broken game.
|
||||
|
||||
Ever since I started playing Counter-Strike, I’ve preferred using a 4:3 stretched resolution on my 16:9 monitor. When I switched to Linux as my daily driver, the only game I really cared about was CS:GO.
|
||||
|
||||
CS:GO ran perfectly without any tweaks on my [Void Linux](https://voidlinux.org) system with a 1050ti laptop graphics card. I could play with the stretched resolution, and I even got more FPS than I did on Windows.
|
||||
|
||||
My problems started with the release of CS2. The 4:3 resolution didn’t work at all, some resolutions were missing, and there didn’t seem to be a solution (except for some Wayland fixes). There’s a [GitHub issue](https://github.com/ValveSoftware/csgo-osx-linux/issues/3264) about it.
|
||||
|
||||
My first idea was to set a custom resolution through `xrandr`. I followed [guides like this one](https://unix.stackexchange.com/questions/227876/how-to-set-custom-resolution-using-xrandr-when-the-resolution-is-not-available-i), but that didn’t work for me.
|
||||
|
||||
For a while, I just stuck with the standard 16:9 `1920x1080` resolution. But today, I opened the `nvidia-settings` GUI. After tinkering with some advanced settings in the resolution section, I think I finally fixed my issue.
|
||||
|
||||
In the `X Server Display Configuration` section under advanced options, I adjusted the ViewPortIn and Panning settings. I’m currently using a `2560x1440` resolution, so for 4:3 stretched, I set the resolution to `1440x1080`.
|
||||
|
||||
Here are the settings that worked for me:
|
||||
- **ViewPortIn**: `1440x1080`
|
||||
- **ViewPortOut**: `2560x1440+0+0`
|
||||
- **Panning**: `1440x1080`
|
||||
|
||||
That fixed the issue, but I didn’t want to manually open `nvidia-settings` every time I wanted to play CS2. After reading the [Arch Wiki article](https://wiki.archlinux.org/title/NVIDIA#Using_nvidia-settings) on `nvidia-settings`, I found that I could use this command to get the current resolution information:
|
||||
|
||||
```sh
|
||||
$ nvidia-settings -q CurrentMetaMode
|
||||
```
|
||||
|
||||
So ~I wrote~ ChatGPT wrote a small bash script to switch between my regular resolution and the CS2 resolution.
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# Define the commands for the two modes
|
||||
MODE1="nvidia-settings --assign 'CurrentMetaMode=DPY-4: 2560x1440_144 @2560x1440 +1920+0 {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}, DPY-3: nvidia-auto-select @1920x1080 +0+180 {ViewPortIn=1920x1080, ViewPortOut=1920x1080+0+0}'"
|
||||
MODE2="nvidia-settings --assign 'CurrentMetaMode=DPY-4: 2560x1440_144 @1440x1080 +0+0 {ViewPortIn=1440x1080, ViewPortOut=2560x1440+0+0}'"
|
||||
|
||||
# File to store the current mode
|
||||
STATE_FILE="/tmp/current_resolution_mode"
|
||||
|
||||
# Check if the state file exists
|
||||
if [[ ! -f "$STATE_FILE" ]]; then
|
||||
# If the state file doesn't exist, create it and set it to mode 1
|
||||
echo "1" > "$STATE_FILE"
|
||||
CURRENT_MODE=1
|
||||
else
|
||||
# Read the current mode from the state file
|
||||
CURRENT_MODE=$(cat "$STATE_FILE")
|
||||
fi
|
||||
|
||||
# Switch between the two modes
|
||||
if [[ "$CURRENT_MODE" -eq 1 ]]; then
|
||||
# Switch to mode 2
|
||||
eval "$MODE2"
|
||||
echo "2" > "$STATE_FILE"
|
||||
echo "Switched to resolution mode 2"
|
||||
else
|
||||
# Switch to mode 1
|
||||
eval "$MODE1"
|
||||
echo "1" > "$STATE_FILE"
|
||||
echo "Switched to resolution mode 1"
|
||||
fi
|
||||
```
|
@ -1,4 +1,8 @@
|
||||
.language-yaml {
|
||||
//.language-yaml {
|
||||
pre {
|
||||
display:flex;
|
||||
align-items: center;
|
||||
min-height: 3rem;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
overflow-x: auto;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
{% block content %}
|
||||
<section class="project-wrapper flex-col">
|
||||
<h2>{{ page.title }}</h2>
|
||||
<!--
|
||||
<section class="left-bar flex-col">
|
||||
<h2>Projects</h2>
|
||||
|
Loading…
Reference in New Issue
Block a user