在 dwm 中优雅地注销

Ria*_*che 5 logout ubuntu dwm

当我按下退出热键时,我希望 dwm 优雅地关闭所有窗口。我喜欢 Unity 的行为:它显示拒绝注销的窗口列表(例如,具有未保存更改的编辑器)并且在解决所有问题并关闭应用程序之前不要注销。默认情况下,dwm 只是结束 X 会话并且所有正在运行的应用程序都会被杀死。

我正在考虑编写一个脚本来检索所有窗口的列表,优雅地关闭它们并等待它们的进程完成。但我什至不知道如何关闭窗户。我知道的唯一方法是使用 wmctrl,而此实用程序不适用于 dwm。

Jer*_*y W 0

您可能需要从 X11 会话管理器中启动 dwm


这是使用 Gnome 显示管理器 (GDM) 执行此操作的一种方法

将以下内容添加到/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
Run Code Online (Sandbox Code Playgroud)

在/usr/local/bin/dwm-start处创建一个具有 755 权限的新文件。

 #!/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
Run Code Online (Sandbox Code Playgroud)

如果您的计算机上正确配置了 GDM,您应该会在登录屏幕的会话菜单中看到一个新的 dwm 条目。

更多 dwm 调整,包括休眠/关闭设置,请参见此处。