prompt to close a window (by mod+shift+q)
closing a window now becomes too easy. Is it possible to have a prompt to close a window?
closing a window now becomes too easy. Is it possible to have a prompt to close a window?
You can use i3 modes for this purpose. Pressing $mod+Shift+q moves you to a special mode, where it asks you if you really want to close the window. Then, in my example, pressing Enter or y will close the window. Pressing Escape or n will get you out of this mode.
set $close "Close the window? (y/n)"
mode $close {
bindsym y kill, mode default
bindsym Return kill, mode default
bindsym n mode default
bindsym Escape mode default
}
bindsym $mod+Shift+q mode $close
This is not perfect, but perhaps you'll like it.
@diablo456: You could write a script that uses the output of `i3-msg -t get_tree` to figure out the type of the currently focused window. Then it could either execute `i3-msg kill` (to kill the current window) or `i3-msg "mode Close the window? (y/n)"` (to switch to the auxiliary mode).
Sure, but not from i3 itself. You can change your keybinding to execute this:
bindsym $mod+Shift+q exec --no-startup-id xdotool getactivewindow | xargs -I '{}' i3-nagbar -t warning -m "Do you really want to close this?" -b "Yes" "killall i3-nagbar; i3-msg [id='{}'] kill" -b "No" "killall i3-nagbar; i3-msg nop"
Not exactly pretty, but works. I don't think i3-nagbar is a great tool for this, though, but you can replace it with whatever tool you want to create the dialog with. For example, you can use zenity
:
bindsym $mod+Shift+q exec --no-startup-id xdotool getactivewindow | xargs -I '{}' zenity --question && i3-msg [id='{}'] kill
I use xdotool
to get the focused window first because if I simply do the dialog and kall i3-msg kill
, you end up killing the wrong window.
Asked: 2015-07-15 06:01:35 +0000
Seen: 151 times
Last updated: Jul 15