Score:1

Auto launch Polybar at boot with default WM (GNOME, Mutter, 21.04)

vn flag

I'm new to both polybar and Linux.

I have follow the tutorial on Github:

  1. Created a file called ~/.config/polybar/launch.sh

  2. Make it executable (I have confirm this through the GUI)

Here's the content of launch.sh:

#!/usr/bin/env bash

killall -q polybar

echo "---" | tee -a /tmp/polybar.log
polybar tonton 2>&1 | tee -a /tmp/polybar.log & disown
echo "Bars launched..."

Running this command from terminal works:

polybar tonton 2>&1 | tee -a /tmp/polybar.log & disown

that means I got my bar name correctly.

Running the launch script manually also works.

Am I missing something? I feel like I should tell the OS to run the launch script on startup somehow... I don't think it will recognise automatically.

I tried using crontab to run launch.sh automatically by adding this line to crontab file:

@reboot export DISPLAY=:0 && /home/atran/.config/polybar/launch.sh

but after checking the log file, this is what I got:

---
polybar|error: X connection error... (what: Socket, pipe or stream error)

What am I missing?

Edit: fix the crontab command by adding export display and now having a different error

Score:3
zw flag

You have to run PolyBar after Xorg launch, and after login to desktop session.

The best way to do so - use XDG Autostart with below long command:

mkdir -p ~/.config/autostart/
cat <<EOF > ~/.config/autostart/polybar.desktop
[Desktop Entry]
Type=Application
Exec=/home/atran/.config/polybar/launch.sh
Hidden=false
X-MATE-Autostart-enabled=true
Name=Polybar
EOF

and then reboot.

Anh Tran avatar
vn flag
you saved me days of debugging, thanks!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.