I love i3 window manager, and I love that you can create minimalists system, both in function and look. Recently I thought to myself, what if I hide polybar and there is only window on screen? But I don't want a permament hide, I need a shortcut to show it, if I need it.
Here comes in r/i3wm subreddit, and here is the solution. Note, that I use Manjaro and package names probably are different on other distros.
There is no built-in solution for this, but there is a tool, called xdo which let's you do some things with windows, and since polybar is a window, it works!
1. Install xdo and xprop
We need these packages.
$ sudo pacman -S xdo xorg-xprop
2. Create the bash script
Copy these lines in your favorite text editor and save it somewhere as a bash script (sh).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/bin/sh # Check if xdo is installed xdo_path=$(which xdo) if [ $? -ne 0 ]; then echo "Cannot find \`xdo\` command." 1>&2 exit 1 fi # Obtain bar's window id id=$(xdo id -N "Polybar") # Toggle bar visibility if xprop -id $id | grep -q "Normal"; then xdo hide -N "Polybar" else xdo show -N "Polybar" fi
Make it executable:
$ chmod +x name_of_script.sh
3. Edit your i3 config file, and assign a shortcut
For me it become $mod+p, but you can use it whatever you want and free.
bindsym $mod+p exec ~/.config/scripts/poly_hide.sh
Refresh your i3wm, and try it out! So far it works well, and instantly, even with using compton.