
如何在很棒的 WM 中設定一個快捷方式來終止目前視窗?
我知道Ctrl+ ⇧ Shift+C關閉一個窗口,但我想要的是 KILL (kill <PID>
例如)。
例如,我需要它來終止處理凍結的視窗。
答案1
您想要的是終止建立視窗的進程。您無法直接執行此操作,但在某些情況下可能可以執行此操作。
請看一下Stack Overflow 上的這個答案為什麼這通常不可能。
如果你想嘗試一下,你必須在 lua 中取得活動視窗 id,嘗試從中檢索 PID 並kill -9
在其上呼叫命令。使用像這樣的工具可以輕鬆完成此操作xprop
,或者您可以使用像這樣的命令(未經測試,可能甚至不起作用):
awful.key({ modkey, "Control" }, "c",
function (c) awful.util.spawn("kill -9 " .. get_xproperty("_NET_WM_PID(CARDINAL)"))
答案2
client
類別有pid
屬性(至少在 Awesome 4.2 中)https://awesomewm.org/doc/api/classes/client.html)所以你可以簡單地這樣做:
awful.key({ modkey, "Control" }, "c",
function (c)
if c.pid then
awful.spawn("kill -9 " .. c.pid)
end
end
)