vincentbernat.i3wm-configur.../bin/polybar

36 lines
1.2 KiB
Text
Raw Normal View History

2021-07-04 18:25:28 +02:00
#!/bin/sh
export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p')
2021-08-07 21:09:10 +02:00
export HEIGHT=$((18 * DPI / 96))
2021-07-04 18:25:28 +02:00
# 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=$(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