A couple polybar modules

Wrote a couple scripts using FIFO pipes, stole the start of an idea from here in the xmonad module.

These will likely be included in the next release but for anyone wanting to give them a try, feel free.
I’ve obviously done basic testing with them and there shouldn’t be any issues (though you never know :P).

UPDATE: I made a change to the update script and added the use of inotifywait it’s much more efficient this way while also being able to update as soon as the system database is changed, it will still work fine without but I had to use $(stat) subshells to get a similar effect, so I recommend installing inotify-tools if you don’t already have it.

UPDATE 2: I added an empty echo to clear the pipe when no updates are present, otherwise polybar just keeps drawing whatever was there last. This is currently untested though.

UPDATE 3: Fixed refresh after running a package operation.


script (copy to ~/bin/check-network)


# somewhat deamon network state icon
# written by Nathaniel Maia, 2019


[ -p /tmp/.network_status ] || mkfifo /tmp/.network_status

# loop and dump info to the pipe
while true; do
	until { ping -c 1 'archlinux.org' || ping -c 1 'archlabslinux.com'; } >/dev/null 2>&1; do
		for (( i=0; i < ${#dc}; i++ )); do
			echo "${dc:$i:1}" >/tmp/.network_status # spinning character
			sleep 0.25

	if ip link | grep -q '[0-9]:\se.*:.*state UP'; then
		echo "$eth" >/tmp/.network_status
		echo "$wl" >/tmp/.network_status

	sleep 300 # only recheck every 5m to save some cpu time

module (add to ~/.config/polybar/modules.conf)

type = custom/script
exec = tail -F /tmp/.network_status
exec-if = [ -p /tmp/.network_status ]
tail = true
click-left = networkmanager_dmenu &
click-right = networkmanager_dmenu &
label-padding = 1


script (copy to ~/bin/check-update)


# somewhat deamon update count + icon
# written by Nathaniel Maia, 2019


if ! hash checkupdates inotifywait >/dev/null 2>&1; then
	echo 'error: check-update: requires "pacman-contrib" and "inotify-tools" installed' >&2
	exit 1

[ -p /tmp/.update_status ] || mkfifo /tmp/.update_status

# wait until were connected
until ping -c 1 'archlinux.org' >/dev/null 2>&1 || ping -c 1 'archlabslinux.com' >/dev/null 2>&1; do
	sleep 10

# loop and dump info to the pipe
while true; do
	if (( ( COUNT = $(checkupdates 2>/dev/null | wc -l) ) > 0 )); then
		echo "$COUNT $ICON" >/tmp/.update_status
		# recheck when the log is written to or after 1.5 hours
		inotifywait -q -q -t 5000 -e close_write /var/log/pacman.log
		sleep 3
		echo "" >/tmp/.update_status
		sleep 5000 # only do a recheck every 1.5 hours to save some cpu time

module (add to ~/.config/polybar/modules.conf)

type = custom/script
exec = tail -F /tmp/.update_status
exec-if = [ -p /tmp/.update_status ]
label-padding = 1
tail = true


Once you’ve got the scripts and modules setup the scripts need to actually be started (as a background process with &).

So two options:

  1. Install archlabs-scripts from the unstable repo, it looks for ~/bin/check-network and ~/bin/check-update and runs them if they are executable so you shouldn’t have to do anything but run al-polybar-session.
  2. Execute the scripts in your startup procedure. Because they just dump to a pipe they can be started whenever. Since startup varies I’ll just use basic shell syntax that can be used in
    ~/.xinitrc ~/.xprofile ~/.config/openbox/autostart ~/.config/bspwm/bspwmrc but this can be translated to others easily.
    $HOME/bin/check-update &
    $HOME/bin/check-network &

Lemme know if you have any issues,



hi @natemaia thank for the job.

When I do the pkg update it still shows updates.
I restarted and pkg and returned to zero, now let’s see when new updates arrive if you reset or always rhyme with active updates

Wow, top job again @natemaia

Perhaps I have to empty the pipe when there are no updates, let me know if it happens again.

Make sure you have the most recent version of the script after I edited it, also make sure you don’t have multiple pkg modules in polybar modules.conf

should all be ok, 9 updates have just arrived, I update and let you know.
the script is the one above in this post.
I copied it this morning.

ok done the update, see photo

should i remove pkg from config polybar?

Nice install @ector , sorry about behing offtopic.

I added another edit, see above. Double check that yours is the same.

If you have multiple [module/pkg] in your modules.conf then remove the old or rename one to be different, [module/pkg2] for example. Make sure to load the right one though :stuck_out_tongue:

I’m sorry @natemaia, but on three distro does not work.
Good night

Ok I see what is going wrong.

Grab the fixed version from above, make sure your have inotify-tools installed.

yes natemaia.
excuse me, now it works you see that I had to restart.

I’ve added these seem to be all working well.

1 Like