I'm aware that using gtk2 it was possible to capture a screen into a pixbuf using gtk2hs. The solution is given here: Screen capture in Haskell?. The problem is that pixbufGetFromDrawable is absent in gtk3 (at least in gtk2hs). Can somebody recommend the solution to this problem? I need this for linux, not windows. The solution from the link is duplicated here for convenience.
import Graphics.UI.Gtk
import Graphics.UI.Gtk.Gdk.Screen
import System.Environment
main = do
[fileName] <- getArgs
initGUI
Just screen <- screenGetDefault
window <- screenGetRootWindow screen
size <- drawableGetSize window
origin <- drawWindowGetOrigin window
Just pxbuf <- pixbufGetFromDrawable window ((uncurry . uncurry Rectangle) origin size)
pixbufSave pxbuf filename "png" []