How to disable PrintScreen by GTK in Linux?
Asked Answered
P

1

1

Is there any way to block PrintScreen key using C++ code in linux? I am writing a C++ program which do not want user get screen shoot. I tried g_signal_connect to block PrintScreen key but it seems even not fire.

Plusch answered 24/10, 2013 at 22:2 Comment(1)
Looks like the XY problem. How will you prevent the user from snapping up a picture from the monitor? How will you stop him from passing the video signal through a video capture device? Why do you think you need to stop the user from using PrintScreen? Did you try pulling the key out (maybe use a screwdriver, or a hammer)?Mcentire
L
0

Why would you want to prevent the print screen key from working?!

Anyway, on Linux at least, this is impossible: when the print screen key is pressed, the window manager launches a little programme which captures the focussed X window (or the entire desktop or whatever) and writes it out as a PNG -- this happens outside your app, and unless you're in control of the entire desktop session, there's really no way to stop it.

If you really wanted to, you could try installing a hook that notices when print screen has been pressed and instantly blanks your window (and race the snapshot utility), though that is so easily worked around it seems pointless.

For example, the user could just configure the capture shortcut to something else, or run gnome-screenshot manually from the terminal. And even if you did get it working, how do you avoid someone pulling out their mobile phone and taking a picture of the monitor?

Libbi answered 25/10, 2013 at 4:55 Comment(1)
Yes, you are right. I was using hook but not perfectly.Plusch

© 2022 - 2024 — McMap. All rights reserved.