Saturday 1 August 2020

HowTo: Swap out i3bar for Polybar

Polybar is a popular and feature-rich bar component that is frequently used with i3. For those looking for more visual flare and features than what is provided by default with i3bar, Polybar provides a compelling alternative. Polybar can be compiled from source or installed via the Speed Ricer PPA. This howto will use the latter as it requires fewer steps.

  1. Install the package:
$ sudo add-apt-repository -y ppa:kgilmer/speed-ricer
...
$ sudo apt install polybar
...
  1. Stage a configuration (see this Arch wiki for more details):
$ mkdir -p ~/.config/polybar && cd ~/.config/polybar
$ cp /usr/share/doc/polybar/config.gz .
$ gunzip config.gz  # You will want to edit this file at some point to configure Polybar
  1. Create a launcher script by saving the following file to ~/.config/polybar/launch.sh:
#!/bin/bash

# Terminate already running bar instances
killall -q polybar

# Wait until the processes have been shut down
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done

# Launch Polybar, using default config location ~/.config/polybar/config
polybar example &

echo "Polybar launched..."
  1. Make the launch script executable:
$ chmod u+x ~/.config/polybar/launch.sh
  1. Stage your Regolith i3 config file:
$ mkdir ~/.config/regolith/i3
$ cp /etc/regolith/i3/config ~/.config/regolith/i3/
  1. Disable i3bar in ~/.config/regolith/i3/config by commenting out or deleting this section:
bar {
  font $i3-wm.bar.font
  separator_symbol " "
  status_command i3xrocks -c $i3xrocks_config
  tray_output none
  strip_workspace_numbers yes

  colors {
      background $i3-wm.bar.background.color
      statusline $i3-wm.bar.statusline.color
      separator  $i3-wm.bar.separator.color

#                        BORDER  BACKGROUND TEXT
      focused_workspace  $i3-wm.bar.workspace.focused.border.color      $i3-wm.bar.workspace.focused.background.color   $i3-wm.bar.workspace.focused.text.color
      active_workspace   $i3-wm.bar.workspace.active.border.color       $i3-wm.bar.workspace.active.background.color    $i3-wm.bar.workspace.active.text.color
      inactive_workspace $i3-wm.bar.workspace.inactive.border.color     $i3-wm.bar.workspace.inactive.background.color  $i3-wm.bar.workspace.inactive.text.color
      urgent_workspace   $i3-wm.bar.workspace.urgent.border.color       $i3-wm.bar.workspace.urgent.background.color    $i3-wm.bar.workspace.urgent.text.color
  }
}
  1. Launch polybar in your ~/.config/regolith/i3/config file, by adding this line at the end:
exec --no-startup-id $HOME/.config/polybar/launch.sh
Log out and back in to have i3 pick up your newly staged i3 config file and see Polybar loaded:
Share:

0 comments:

Post a Comment