如何在Awesome WM多显示器环境下避免工具提示超出屏幕
Hey there, I’ve fought this exact issue with Awesome WM 4.2 and multi-monitor layouts before—nothing’s more frustrating than tooltips or context menus spilling off-screen or jumping between monitors when they shouldn’t. Here are the most reliable fixes that worked for me and other Awesome users:
1. Enforce Off-Screen Prevention via Client Rules
The first line of defense is adding a rule in your rc.lua to force tooltip/menu windows to respect screen boundaries. This tells Awesome to automatically reposition any floating window marked as a tooltip or menu so it stays on the current screen.
Add this to your existing awful.rules.rules block:
awful.rules.rules = { -- Keep your existing rules here { rule_any = { role = { "tooltip", "popup_menu", "context_menu" } }, properties = { placement = awful.placement.no_offscreen, floating = true, ontop = true } }, }
After adding this, restart Awesome (Mod+Ctrl+r) and test those problematic apps—most should behave immediately.
2. Target Stubborn Apps with Specific Configs
Some apps (like XTerm, Pale Moon) need extra nudges because they handle their own window positioning:
- XTerm: Edit your
~/.Xresourcesfile to add these lines, then runxrdb ~/.Xresourcesto apply:
This forces XTerm’s context menus to stay anchored to the window and on-screen.XTerm.vt100.pointerMode: 0 XTerm.vt100.popupOnTop: true - Pale Moon: Open
about:config, search forui.tooltip.screen_boundary.enabled, and set it totrue. This enables built-in screen boundary checks for tooltips. - QJackCtl: Try launching it with the
--force-screen=0flag (replace 0 with your target screen index fromxrandr) to lock it to a specific monitor, which often fixes menu positioning.
3. Verify Your Xorg Monitor Layout
Double-check that Xorg isn’t treating your three monitors as a single giant screen. Run xrandr in a terminal—you should see each monitor listed with its own resolution and position (e.g., HDMI-1 connected 1920x1080+0+0, DP-1 connected 1920x1080+1920+0). If they’re merged incorrectly, adjust your xrandr startup command or xorg.conf to define proper screen positions.
4. Upgrade Awesome WM (If Possible)
Awesome WM 4.2 is a bit old, and later versions (4.3 and beyond) include significant fixes for multi-monitor window placement issues. If you can upgrade your distro’s package or build from source, this will likely eliminate the problem entirely without extra config hacks.
内容的提问来源于stack exchange,提问作者Patrice Levesque

