Skip to content

Instantly share code, notes, and snippets.

@RecursiveG
Last active January 23, 2026 04:24
Show Gist options
  • Select an option

  • Save RecursiveG/1ae18279de79492282022dbb1ed04bbf to your computer and use it in GitHub Desktop.

Select an option

Save RecursiveG/1ae18279de79492282022dbb1ed04bbf to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# https://bugs.mojang.com/browse/MC-122477
# Replaces the extracted libglfw.so with this custom built one.
# How that can be done depends on your launcher.
# Minecraft version doesn't matter but GLFW version should match.
#
# How to find the version hash:
# 1. Locate the "natives-linux.jar" file for your Minecraft version.
# e.g. .minecraft/libraries/org/lwjgl/lwjgl-glfw/3.3.3/lwjgl-glfw-3.3.3-natives-linux.jar
# 2. Looking for a file named "libglfw.so.git" in it.
# 3. This file should contain the hash.
#
set -xe
# GLFW for LWJGL 3.3.3: https://github.com/glfw/glfw/archive/3eaf1255b29fdf5c2895856c7be7d7185ef2b241.zip
wget 'https://github.com/glfw/glfw/archive/3eaf1255b29fdf5c2895856c7be7d7185ef2b241.zip'
unzip 3eaf1255b29fdf5c2895856c7be7d7185ef2b241.zip
mv glfw-3eaf1255b29fdf5c2895856c7be7d7185ef2b241 glfw
patch glfw/src/x11_window.c << 'EOF'
@@ -1130,6 +1130,8 @@
keycode = event->xkey.keycode;
filtered = XFilterEvent(event, None);
+ if (filtered)
+ return;
if (_glfw.x11.randr.available)
{
EOF
mkdir build
cmake -S glfw -B build\
-D BUILD_SHARED_LIBS=YES\
-D GLFW_BUILD_EXAMPLES=NO\
-D GLFW_BUILD_TESTS=NO\
-D GLFW_BUILD_DOCS=NO
cmake --build build
# Built file in build/src/, rename the libglfw.so.X.Y file to libglfw.so.
@HitCoder9768
Copy link

Hey, I'm not sure on how to get this to work, I've run the file and i got the compiled files, but i don't know where to put them, and overwriting the ones in .minecraft doesn't appear to do anything...

If you could help i'd greatly appreciate it.

@RecursiveG
Copy link
Author

@HitCoder9768

IIRC the official launcher will extract native files into .minecraft/versions/1.19/native/libglfw.so. You need to replace that file with the custom built one build/src/libglfw.so.3.4.

The issue is that the official launcher may re-extract and overwrites the native files everytime it launches the game. I use my homebrewed launcher so it isn't an issue for me. But I don't know how to make the official launcher (or any launcher you are using) work.

@lizquilty
Copy link

This isnt working for me on 1.20.1 - even manually patching/editing that and latest version no luck

@wojtekojtek
Copy link

wojtekojtek commented Jun 26, 2024

Fixed - thank you!

The issue is that the official launcher may re-extract and overwrites the native files everytime it launches the game. I use my homebrewed launcher so it isn't an issue for me. But I don't know how to make the official launcher (or any launcher you are using) work.

I made it read-only so it shouldn't overwrite it.

edit:
I was using Fabric 1.20.6, Kubuntu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment