vincentbernat.i3wm-configur.../bin/polybar
Vincent Bernat 41dba59ce2 polybar: switch back to xrandr to find monitors
For some reason, I get this with polybar:

```
DisplayPort-3-1: 1920x1440+0+0 (XRandR monitor)
DisplayPort-3-2: 1520x1440+1920+0 (XRandR monitor)
DisplayPort-3: 3440x1440+0+0 (primary)
```
2021-08-23 10:16:03 +02:00

31 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p')
export HEIGHT=$((18 * DPI / 96))
MONITORS=$(xrandr --current --listactivemonitors | sed -nE 's/ *([0-9]+): [+*]*([^ ]*).*/\2/p' | tr '\n' ' ')
PRIMARY=$(xrandr --current --listactivemonitors | sed -nE 's/ *([0-9]+): [+]?[*]([^ ]*).*/\2/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