#!/bin/sh export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p') export HEIGHT=$((20 * DPI / 96)) export BACKLIGHT=$(cd /sys/class/backlight ; ls | head -1) polybar --version # Example of setup: # xrandr --setmonitor '*'DisplayPort-3-left 1920/444x1440/334+0+0 DisplayPort-3 # xrandr --setmonitor DisplayPort-3-right 1520/352x1440/334+1920+0 none MONITORS=$(polybar --list-monitors | sed -nE 's/([^ ]+): .*/\1/p' | tr '\n' ' ') PRIMARY=$(polybar --list-monitors | grep -F '(primary)' | sed -nE 's/([^ ]+): .*/\1/p') NMONITORS=$(echo $MONITORS | wc -w) PRIMARY=${PRIMARY:-${MONITORS%% *}} awk 'BEGIN { i=0 } ($4 == "/" && $3 !~ /^0:/) {print "mount-"i" = "$5; i++}' /proc/self/mountinfo \ > $XDG_RUNTIME_DIR/i3/polybar-filesystems.conf case $NMONITORS in 1) MONITOR=$PRIMARY polybar --reload alone & systemd-notify --status="Single polybar instance running on $PRIMARY" ;; *) MONITOR=$PRIMARY polybar --reload primary & for MONITOR in ${MONITORS}; do [ $MONITOR != $PRIMARY ] || continue MONITOR=$MONITOR polybar --reload secondary & done systemd-notify --status="$NMONITORS polybar instances running" ;; esac systemd-notify --ready trap "systemd-notify WATCHDOG=trigger" CHLD wait