polybar: Custom script no longer works
I have this custom module to get the current song from Spotify.
[module/spotify]
type = custom/script
exec = ~/.config/polybar/spotify
interval = 2
This is the script:
#!/bin/bash
if [ "$(playerctl status)" = "Playing" ]; then
title=`exec playerctl metadata xesam:title`
artist=`exec playerctl metadata xesam:artist`
echo "$title - $artist"
else
echo ""
fi
Polybar version is:
polybar 2.5.0-4-g2cde3f3-git
Now, after rebooting today, the module no longer works at all. The script still works, but the module no longer shows an output in my polybar.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 48 (16 by maintainers)
Just for posterity’s sake, the comment above ^ has nothing to do with the underlying cause of this issue (even if it has the same symptoms).
So, I’ve encountered this “no output” issue myself, but I’m using
zsh, notfish. Running polybar viashsolves the issue, too:SHELL=$(which sh) polybarI’ve updated my polybar launch script to use that, and it’s resolved the issue permanently. There’s likely something carrying over from the
zsh/fishshells that’s impacting howpolybaritself is spawning processes (or the environment in which those processes run). Even launching polybar outside of a terminal window (via i3, or a launcher likerofiordmenu) causes problems (although in those scenarios, I would getterminal: tabs: no such device or addressas the script output in polybar). I start X manually after logging in, which is again, via a virtual console running zsh, so part of me still thinks it’s the non-bashshell causing issues.@jaagr for completeness’ sake, here’s the output of those commands you requested:
Let me know if there’s anything else I can help with. If this is just a caveat that’s required going forward, it’s probably worth updating the
custom/scriptsection of the wiki so that non-standard shell users don’t get tripped up. 🙂It’s
/usr/bin/fish, however that shouldn’t make any difference because"/usr/bin/env sh -c [command]"is how polybar executes scripts, and I have declared the shell to run under with the hashbang.