Skip to content

Commit 292f202

Browse files
committed
nixos: fix sway screen glitches with vulkan (not working)
1 parent 5c3e9ef commit 292f202

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

nix/common.nix

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,11 @@ in
802802
extraSessionCommands = ''
803803
# see also https://wiki.hyprland.org/Configuring/Environment-variables/
804804
805+
# Fix screen tearing in external display of machine with nvidia GPU
806+
# https://old.reddit.com/r/swaywm/comments/102cdqa/how_can_i_fix_my_external_screen_flickering_with/
807+
# Seems to be not working
808+
# export WLR_RENDERER=vulkan
809+
805810
export TERMINAL="alacritty"
806811
export BROWSER="firefox"
807812
@@ -831,16 +836,20 @@ in
831836
# export GBM_BACKEND=nvidia-drm
832837
# export __GLX_VENDOR_LIBRARY_NAME=nvidia
833838
839+
# https://old.reddit.com/r/swaywm/comments/17sob2b/sway_wont_launch_with_vulkan_renderer_on_nvidia/k8rkxo4/
840+
nvidia_priority=40
841+
# If $WLR_RENDERER == vulkan, then the nvidia card should be prioritized to the first
842+
# otherwise, nvidia card should be deprioritized to the last.
843+
if [[ "$WLR_RENDERER" == "vulkan" ]]; then
844+
nvidia_priority=40
845+
fi
834846
# https://wiki.hyprland.org/hyprland-wiki/pages/Configuring/Multi-GPU/
835-
# Changing the order of using GPUs to intel -> amd -> other -> nvidia.
836847
wlr_drm_devices="$(drm_info -j |\
837848
jq -r 'with_entries(.value |= .driver.desc) | to_entries | .[] | "\(.key) \(.value)"' |\
838-
sed -E 's#(^\S+)\s+(.*intel.*)#\1 10#gI;
849+
sed -E "s#(^\S+)\s+(.*intel.*)#\1 10#gI;
839850
s#(^\S+)\s+(.*amd.*)#\1 20#gI;
840-
s#(^\S+)\s+(.*nvidia.*)#\1 40#gI;
841-
# Below line assign all other devices to the priority 30,
842-
# which means the order is intel -> amd -> other -> nvidia.
843-
s#(^\S+)\s+([^0-9]+$)#\1 30#gI' |\
851+
s#(^\S+)\s+(.*nvidia.*)#\1 $nvidia_priority#gI;
852+
s#(^\S+)\s+([^0-9]+$)#\1 30#gI" |\
844853
sort -n -k2 |\
845854
awk '{print $1}' |\
846855
paste -sd ':')"

0 commit comments

Comments
 (0)