0

I am curious how applications like gksu lock screen focus when prompting for a password. I see gksu even has an option "-g", that can disable this behavior.

I am interested in doing something similar for a Python app (I used Quickly to generate the GUI app -- GTK+3) but I can't find any info on how this could be done. I have found things like fullscreen(), etc but I really like how gksu does it.

I am using Lubuntu 14.04 (LXDE)

Any pointers or suggestions would be appreciated.

Monty
  • 3
  • 1

1 Answers1

0

If you look at the source code you will see the functions grab_keyboard_and_mouse() and ungrab_keyboard_and_mouse(), which do the locking and unlocking.

The core locking and unlocking functions are done by calling the GTK library functions gdk_pointer_grab() and gdk_keyboard_grab() and their ..._ungrab() equivalents.

You would need to make these functions callable from Python, but I don't know if that is a simple task or not. Alternatively, maybe you can find a program which puts up a message box with some input fields and buttons, like an extended xmessage, but locking the screen while it's active.

AFH
  • 17,300
  • 3
  • 32
  • 48
  • Thanks for the info AFH. Looking at the source code helps a lot and gives me a good starting point on what to do on the Python side. It also looks to me that they are basically getting the screen x and y dimensions and painting a rectangle box that is semi transparent for the screen "lock". At least that is what it appears to me and is an interesting idea on how to essentially "lock" the screen – Monty Nov 15 '14 at 05:46