I'm used to quickly closing windows on i3wm and SwayWM, where I would just press WIN+SHIFT+Q. I've already checked and there are no alternatives for elementary OS except ALT+F4, which is annoying since I have to press FN as well.

What is the terminal command ALT+F4 uses to close the currently highlighted window? I want to use that command in the Custom section of the Keyboard settings.


I've already checked and there are no alternatives for elementary OS except ALT+F4

Well that is the "alternative" if I see it from your point of view. But like KDE, GNOME and many others yours is the real alternative and a rarity of a non spoken rule to define ALT+F4 as a way to close active windows

In elementary OS's Pantheon we call it shortcut, you may keep calling it alternative

If I start to think where it came the idea of this shortcut (or alternative), I'll probably will have to go back to the 80's where a lot of Common User Access standards were written/defined and then Microsoft thought to use F4 better than Q in case a non English speaker will use the shortcut (associated with Quit) or a DVORAK layout user who will not have the Q up there

Also you could check System reserved shortcuts for GNOME in https://developer.gnome.org/hig/stable/keyboard-input.html.en

And for KDE you'll find them in https://docs.kde.org/trunk5/en/applications/fundamentals/kbd.html

All of them using the "alternative"

I understand you want something like XF86Close, a simple command. But doesn't work when I tested it.


In terms of kill the current active window, isn't simple to achieve but you could do it by binding

"xkill -id $(xprop -root | grep NET_ACTIVE_WINDOW\( | cut -d# -f2)"

, to a key

ref: https://bbs.archlinux.org/viewtopic.php?pid=897968#p897968


$ xdotool key Alt+F4

To install it: sudo apt install xdotool


$ wmctrl -c :ACTIVE:

To install it: sudo apt install wmctrl


You could play with xev

Check the outputs and remap it (/usr/share/X11/xkb/keycodes/evdev)

My ALT+F4 from xev:

KeyPress event, serial 38, synthetic NO, window 0x4a00001,
    root 0x6c6, subw 0x0, time 1732231, (-131,275), root:(500,652),
    state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusOut event, serial 38, synthetic NO, window 0x4a00001,
    mode NotifyGrab, detail NotifyAncestor

ClientMessage event, serial 38, synthetic YES, window 0x4a00001,
    message_type 0x132 (WM_PROTOCOLS), format 32, message 0x130 (WM_DELETE_WINDOW)

More info about map them and the use of xkb



  • Will this ask the program to quit, like pressing the X, or does it kill the program without saving the changes? – user16868 Dec 29 '18 at 20:07
  • Just kill. From man xkill - This command does not provide any warranty that the application whose connection to the X server is closed will abort nicely, or even abort at all. All this command does is to close the connection to the X server. Many existing applications do indeed abort when their connection to the X server is closed, but some can choose to continue.. I added a few more ways. – Sebastian Dec 29 '18 at 20:46
  • Killing a program means most likely losing some data. What does pressing the X (close) button do? I'm guessing it tries to properly close the program. This is the action I want to achieve. – user16868 Dec 30 '18 at 9:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.