Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want dwm to close all windows gracefully when I press quit hotkey. I like Unity behaviour: it displays list of windows denying logout (for example, editors with unsaved changes) and do not logout before all issues are resolved and applications are closed. By default, dwm just end X session and all running applications are killed.

I was thinking about writing a script that will retrieve list of all windows, gracefully close them and wait for their processes to finish. But I even don't know how to close windows. The only way I know is using wmctrl, and this utility doesn't work with dwm.

share|improve this question
    
since i have experience working with DWM's code, but this isn't stackoverflow so i must stay in context: you'll have to have a wrapper around dwm, that's the best you can do without having to rewrite code. I use a script that sends sigterm to everything except dwm running underneath it, and if (only if) everything was also killed, which is not the case if a program pops up a "save your document" box, then kills dwm as well (if not/no kill).You can modify such a script to do what you want however wrapping it without going into codes the real challenge. (but like i said this isnt stackoverflow) – osirisgothra May 5 '14 at 11:05
    
btw you can use a combination of ps, kill, grep and sed, to get the info you need about your processes when in a script, of course you can find the correct dwm instance via the DISPLAY variable – osirisgothra May 5 '14 at 11:11

You may need to start dwm from within a X11 session manager


Here is one way to do it with Gnome Display Manager (GDM)

Add the following to /usr/share/xsessions/dwm.desktop

 [Desktop Entry]
 Encoding=UTF-8
 Name=dwm
 Comment=This session starts dwm
 Exec=/usr/local/bin/dwm-start
 Type=Application

Create a new file at /usr/local/bin/dwm-start with 755 permissions.

 #!/bin/sh
 # You can add other programs to set the background, add autoloading
 # and add autoload for USB and such here 
 # Make sure you start dwm last as it never returns control to this script
 exec /usr/local/bin/dwm > /dev/null

If GDM is properly configured on your computer, you should see a new dwm entry in the session menu on the log-in screen.

More dwm tweaks, including setup for hibernate/shutdown are here.

share|improve this answer
    
I'm starting dwm from lightdm (default login manager in Ubuntu). When dwm is finished, all applications are killed. I don't see that gdm or lightdm provide any functionality for asking about am I really want these applications to be killed. – Riateche Jun 10 '12 at 5:40
    
@Riateche if you are starting this in lightdm already .. have you tried gnome-session-quit --logout-dialog? I'm not sure if it will be valid without gnome/unity desktop but it's worth trying. – Jeremy W Jun 11 '12 at 18:57
    
gnome-session-quit works only if gnome-session was started. dwm works not well with gnome-session. – Riateche Jun 11 '12 at 20:33
1  
@Riateche mod+Shift+Q should just kill dwm ... not X. Is this not the case for you? – Jeremy W Jun 11 '12 at 21:10
    
There are two options. First: session command is directly set to dwm. In this case mod+shift+q kills dwm, X and all gui applications. Second: session command is set to script that restarts dwm in infinite loop. In this case mod+shift+q restarts dwm without killing applications, and killall dwm kills dwm, X and all gui applications. I'm currently using the second type of setup. – Riateche Jun 12 '12 at 7:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .