Xorg screenshot programs freezing

Since some run of nixos-rebuild in the past few days, any program that takes screenshots in X freezes when it tries to copy the image to the clipboard or save to a file. I cannot simply roll back my system because I have been making a lot of changes recently, and have run a garbage collect just yesterday. I did notice that a nixos-rebuild run yesterday was rebuilding the nvidia driver, so I am suspicious that is the culprit.

Any suggestions on ways to rule anything in or out?

are you running a different kernel. Thats always a good start.

You can always do a nixos-rebuild switch using an older version of nixpkgs to see where the culprit is.

How do I use an older version of nixpkgs?

1 Like

I just tried sudo nixos-rebuild --max-jobs 32 switch -I https://releases.nixos.org/nixos/21.11/nixos-21.11.334977.d1e59cfc499/nixexprs.tar.xz to roll back to last week’s version of the 21.11 channel, rebooted, and it is still happening, even though this issue was not present on my system a week ago. Just to be sure, I rolled back as far as I could until I got an error about the already-installed boot-loader being newer (I’m certain I’ve rolled back to a release from before I’ve even installed my system), and the issue persists.

Do you have any logs whatsoever? If just running scrot in a terminal doesn’t show anything, you might find more in either /var/log/X.*.log or journalctl -et xsession.

If that won’t help, you might have more luck throwing gdb at it.

Nothing helpful in my ~/.sx.log (the other logs you mentioned don’t exist on my system). And scrot doesn’t have this problem, oddly enough.

I also just thought to try running screengrab from a nix-shell, and it does not have this problem, so this may be fixed in unstable.

Sounds more like a specific set of screenshot applications are affected, or they happen to be run in an environment that’s missing something.

Which ones do freeze, and can you invoke them from the same shell you ran scrot in?

1 Like

screengrab (from lxqt.screengrab) and flameshot freeze while scrot does not. I have not been trying flameshot since this started happening, because the way it works, if it freezes, the entire X session is frozen, so I have just been trying screengrab and scrot.

scrot run from a normal xterm shell (as in not under nix-shell) exits in about one second, producing a screenshot in an image file as expected. screengrab run under the same shell behaves normally until I either save the screenshot to a file or hit the “Copy” button (to copy to the clipboard), at which point it freezes indefinitely, even though it writes the image file almost right away (and the image appears fine in an image viewer).

Although while I was repeating this process, I just noticed this output from screengrab while it is frozen:

Notify: Unable to create interface.

This may due to me not having a notification daemon running (due to a bug in dunst).

Edited to add: I have verified that this is the case: these screenshot programs are hanging trying to talk to the notification dbus service, which is not present.

1 Like

That’s a bit sad, but good that you figured it out!

I wonder if upstream would be interested in this as a bug report, given that you probably don’t want your application to freeze just because notifications can’t be sent.


Well it seems to be fixed in the unstable nixpkgs channel, and I wouldn’t even know where to report it, as it seems to affect anything that tries to talk to the dbus notification service, including firefox. I’ll try to remember to test this again after upgrading to the next NixOS release, and if it’s still an issue then, look into reporting it upstream.

Hosted by Flying Circus.