Skip to content

Instantly share code, notes, and snippets.

@inscapist
Last active April 22, 2024 21:20
Show Gist options
  • Save inscapist/83fd43b49c17e46059eb4fe0c1ae8bea to your computer and use it in GitHub Desktop.
Save inscapist/83fd43b49c17e46059eb4fe0c1ae8bea to your computer and use it in GitHub Desktop.
Nvidia and Xorg on Void Linux
xset r rate 250 60
setxkbmap -option caps:escape
xbacklight -set 10
# paired with `Xft.dpi: 144`
export GDK_DPI_SCALE=1.4
if [ -z "${XDG_RUNTIME_DIR}" ]; then
export XDG_RUNTIME_DIR=/tmp/${USER}-runtime-dir
if [ ! -d "${XDG_RUNTIME_DIR}" ]; then
mkdir "${XDG_RUNTIME_DIR}"
chmod 0700 "${XDG_RUNTIME_DIR}"
fi
fi
#exec herbstluftwm --locked
#exec xmonad
# the bus will be known at $DBUS_SESSION_BUS_ADDRESS
exec dbus-run-session -- i3

Installation

Use chroot method to install void. or add nomodeset in the installer screen (press "e" in grub menu)

Drivers

For most up-to-date info, refer here.

Or simply do the following and let the other dependencies be computed:

sudo xbps-install nvidia

Kernel parameters

Set nvidia-drm.modeset=1 to kernel parameters in /etc/default/grub. Then run update-grub


It seems that there's an alternative which is adding nvidia.conf to /etc/modprobe.d with

options nvidia_drm modeset=1

Still, it is better documentation to do it at kernel parameters level.

Initramfs

Void uses dracut instead of mkinitcpio. Create a file at /etc/dracut.conf.d/nvidia.conf with the content:

add_drivers+=" nvidia nvidia_modeset nvidia_uvm nvidia_drm "

Note: surrounding space is important

Then run dracut --force or dracut -f

Xorg

Don't install xorg, but install xorg-minimal to prevent installing unrelated and potentially conflicting video drivers:

sudo xbps-install xorg-minimal xorg-server-devel xrdb xbacklight

-server-devel is to provide package config for nvidia-xconfig to work

xrdb is needed for dpi settings

I also need this for changing keyboard repeat rate and swapping CAPSLOCK with ESCAPE key

sudo xbps-install xset setxkbmap

By now, /etc/X11 should not contain any xorg related configs. Next, make sure nvidia drivers are already installed, then run:

sudo nvidia-xconfig
@inscapist
Copy link
Author

inscapist commented Apr 7, 2024

Brightness

Make sure there's a folder /sys/class/backlight/nvidia_0. If its not (eg. acpi_video_0), it means nvidia driver isn't working properly.

Then, do the following test (change to 50%):

echo 50 | sudo tee /sys/class/backlight/nvidia_0/brightness

Install xbacklight package and bind keys to the xbacklight commands, for eg on I3:

bindsym XF86MonBrightnessUp exec xbacklight +10
bindsym XF86MonBrightnessDown exec xbacklight -10

@inscapist
Copy link
Author

inscapist commented Apr 7, 2024

Hopefully i can get a laptop with AMD gpu soon :/

@inscapist
Copy link
Author

inscapist commented Apr 7, 2024

DPI settings

To change DPI, add this in ~/.Xresources.

Xft.dpi: 144

and then xrdb -merge ~/.Xresources. This is because xorg is a server, and resources are stored in server. See https://wiki.archlinux.org/title/X_resources.


Try the following values. Should be multiples of 96

96, 120 (25% higher), 144 (50% higher), 168 (75% higher), 192 (100% higher)


For best result, pair Xft.dpi: 144 with export GDK_DPI_SCALE=1.4

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