awesomewm:显示聚焦屏幕的小部件
awesomewm: widget showing focused screen
我经常忘记当前关注的是哪个屏幕(尤其是在没有打开的客户端时)。
因此我想写一个小部件,它总是显示哪个屏幕被聚焦。
我当前的代码如下所示:
-- Focused screen widget
local focused_screen_widget = wibox.widget{
markup = "SCR: " .. tostring(awful.screen.focused().index),
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
}
function update_focused_screen_widget()
focused_screen_widget.text = "SCR: " .. tostring(awful.screen.focused().index)
end
client.connect_signal("focus", update_focused_screen_widget)
client.connect_signal("unfocus", update_focused_screen_widget)
---- hook into awful.screen.focus()
original_screen_focus = awful.screen.focus
function awful.screen.focus(_screen)
original_screen_focus(_screen)
update_focused_screen_widget()
end
这主要是工作,但是当我没有打开客户端并在屏幕之间移动鼠标时,没有触发更新。
我知道焦点发生了变化,因为新应用程序总是在正确的屏幕上启动,但我找不到根据这些变化更新我的小部件的方法。
谁能帮我解决这个问题?
编辑:我使用的是 awesome v4.2
目前您无法获取鼠标光标移动到其他显示器时的事件。原因主要是技术性的(除非您要求 "please send me an event for any mouse movement",否则 X11 不会为您提供 "the mouse moved to another monitor" 的事件)。
因此,您唯一的解决方案是一个定期更新您的小部件的计时器,比方说每秒一次或每十秒一次或任何适合您的数字。
我经常忘记当前关注的是哪个屏幕(尤其是在没有打开的客户端时)。 因此我想写一个小部件,它总是显示哪个屏幕被聚焦。
我当前的代码如下所示:
-- Focused screen widget
local focused_screen_widget = wibox.widget{
markup = "SCR: " .. tostring(awful.screen.focused().index),
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
}
function update_focused_screen_widget()
focused_screen_widget.text = "SCR: " .. tostring(awful.screen.focused().index)
end
client.connect_signal("focus", update_focused_screen_widget)
client.connect_signal("unfocus", update_focused_screen_widget)
---- hook into awful.screen.focus()
original_screen_focus = awful.screen.focus
function awful.screen.focus(_screen)
original_screen_focus(_screen)
update_focused_screen_widget()
end
这主要是工作,但是当我没有打开客户端并在屏幕之间移动鼠标时,没有触发更新。 我知道焦点发生了变化,因为新应用程序总是在正确的屏幕上启动,但我找不到根据这些变化更新我的小部件的方法。 谁能帮我解决这个问题?
编辑:我使用的是 awesome v4.2
目前您无法获取鼠标光标移动到其他显示器时的事件。原因主要是技术性的(除非您要求 "please send me an event for any mouse movement",否则 X11 不会为您提供 "the mouse moved to another monitor" 的事件)。
因此,您唯一的解决方案是一个定期更新您的小部件的计时器,比方说每秒一次或每十秒一次或任何适合您的数字。