Just a short one on this problem with combination of Spectrwm tiling window manager and Polybar. Managed to sort it out after hours without finding a solution on the web. So here is my hack.
First, the problem... Once you replace the bar that comes with Spectrwm, with Polybar, you have to reserve a portion on top of the screen for Polybar. That's OK, but toggling Polybar leaves that reserved space empty so again you don't get a full screen. On the other hand, if you don't reserve that space, Polybar is displayed above your windows which is also not nice.
My solution is simple:
- Leave original bar ON with minimal settings, and remove reserved space for Polybar if you had it configured before (
region
in config). Only Spectrwm bar config items you need are:
bar_enabled = 1
bar_border_width = 0
bar_font = <any font, just adjust size so bar is as large as Polybar>
bar_format = ' # <--- something minimal so bar is almost not visible
make sure your original keybinding to toggle Spectrwm bar is still active (Super+b)
install
xdotool
. Miniature program that can send fake keys to Xorgwrite shell script, I named it
fullscreen-toggle.sh
and put it somewhere (mine are in ~/scripts/
). Also make it executable:
#!/bin/sh
xdotool key super+b
polybar-msg cmd toggle
Script is really simple. First, xdotool toggles Spectrwm bar by sending fake keypresses. Then we use polybar-msg to send remote command to Polybar to toggle.
- Add new keybinding to Spectrwm conf (
~/.spectrwm.comf
). I used MOD+Shift+f:
program[toggle_bars] = ~/scripts/fullscreen-toggle.sh
bind[toggle_bars] = MOD+Shift+f
... and we're done! Restart Spectrwm (Super+q
) and try it out. Make sure your keybinding was free before assigning it. Also, try running shell script from terminal for test.
Top comments (0)