It might sound ridiculous, but I want to prevent closing a window in Ubuntu. I want to provide to my users a highly secure environment, without any desktop environment with just one window open. Now I want to make sure user can't close that window. Is there any way to hack around with compiz so that there is no way a user can close the window. Not by pressing close button, not by pressing alt+f4 etc.?
I am open to use any window manager amongst those available in 12.04. Either of compiz, metacity, and others. I am also willing to hack around with source code if required.
EDIT: Just disabling ALT+F4 from OS doesn't solve the problem. That is because some applications issue close commands on pressing ALT+F4 even before the event is bubbled to OS. I need a way by which the ability to close the window is taken away from application itself.
Compiz provides this functionality using the Window Rules plugin. You specify which windows to match (by name, type, ID, etc.) and then you can apply rules to those windows. One of the rules is to prevent the window from closing. I used this for a long time and can confirm it works well and prevents keyboard shortcuts, close button, and right click and close on the task bar. Pretty much a low-level way of preventing a window from closing.
You can also use
xprop
to do this (Compiz not required). An example:Combined with locating the window ID to use:
Note that what
xprop
is modifying here are allowed actions for the window, not the window's state. So if you want to prevent a window from being minimized, remove the_NET_WM_ACTION_MINIMIZE
action, and so on. If you actually want to change the state of a window, usingwmctrl
is an easier tool to use for that.Although the default list of allowed actions is likely the same for all window managers, you might want to run
xprop | grep _NET_WM_ALLOWED_ACTIONS
on the window before just to be sure that you're re-setting all of the other actions that were there before. There doesn't seem to be a way of usingxprop
to remove a single allowed action, only to remove an entire property.In terms of how foolproof/secure this is, it's probably as good as you can get for a single window. By removing
_NET_WM_ACTION_CLOSE
or another allowed action, it means that the window is not allowed to receive that action. No matter what method a user might try to close the window, the window will never receive that action. Obviously there are more components to making a secure desktop, but this should be the best way to prevent a window from closing.However, if the application offers a way of closing itself (e.g.
File > Quit
), then it will close when that is triggered. Removing_NET_WM_ACTION_CLOSE
prevents the action from being received from outside the window, but doesn't prevent the window from triggering the action itself.As I know and as you said there are two ways to prevent closing a window. disable close button and alt+f4
To disable close, minimize, maximize button in Gnome : Alt+F2 Enter: gconf-editor Go to app > metacity > general Double click on button layout you will see menu:minimize,maximize,close
you can also use Gnome tweak tool to enable disable menu and button icons which is available here https://live.gnome.org/GnomeTweakTool
I think you can remove the ones you don't want from there.
To disable atl+f4 : In the menu go to System - Preferences - Personal -Keyboard Shortcuts disable the shortcuts which you want