2021-07-04 18:25:28 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p')
|
2021-11-02 09:55:55 +01:00
|
|
|
export HEIGHT=$((20 * DPI / 96))
|
2022-09-14 01:15:18 +02:00
|
|
|
export BACKLIGHT=$(cd /sys/class/backlight ; ls | head -1)
|
2024-11-02 21:41:04 +01:00
|
|
|
export I3SOCK=$(i3 --get-socketpath)
|
2021-07-04 18:25:28 +02:00
|
|
|
|
2022-07-22 14:00:52 +02:00
|
|
|
polybar --version
|
|
|
|
|
2021-08-26 09:21:56 +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
|
|
|
|
|
2021-10-20 15:29:23 +02:00
|
|
|
MONITORS=$(polybar --list-monitors | sed -nE 's/([^ ]+): .*/\1/p' | tr '\n' ' ')
|
|
|
|
PRIMARY=$(polybar --list-monitors | grep -F '(primary)' | sed -nE 's/([^ ]+): .*/\1/p')
|
2021-08-22 08:59:43 +02:00
|
|
|
NMONITORS=$(echo $MONITORS | wc -w)
|
2021-07-15 19:12:36 +02:00
|
|
|
PRIMARY=${PRIMARY:-${MONITORS%% *}}
|
2021-07-15 20:52:32 +02:00
|
|
|
|
2021-08-02 22:59:26 +02:00
|
|
|
awk 'BEGIN { i=0 } ($4 == "/" && $3 !~ /^0:/) {print "mount-"i" = "$5; i++}' /proc/self/mountinfo \
|
|
|
|
> $XDG_RUNTIME_DIR/i3/polybar-filesystems.conf
|
|
|
|
|
2021-08-22 08:59:43 +02:00
|
|
|
case $NMONITORS in
|
2021-07-08 08:10:37 +02:00
|
|
|
1)
|
2021-07-17 11:09:04 +02:00
|
|
|
MONITOR=$PRIMARY polybar --reload alone &
|
2021-08-22 08:59:43 +02:00
|
|
|
systemd-notify --status="Single polybar instance running on $PRIMARY"
|
2021-07-08 08:10:37 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
MONITOR=$PRIMARY polybar --reload primary &
|
2021-07-15 14:32:00 +02:00
|
|
|
for MONITOR in ${MONITORS}; do
|
|
|
|
[ $MONITOR != $PRIMARY ] || continue
|
|
|
|
MONITOR=$MONITOR polybar --reload secondary &
|
2021-07-08 08:10:37 +02:00
|
|
|
done
|
2021-08-22 08:59:43 +02:00
|
|
|
systemd-notify --status="$NMONITORS polybar instances running"
|
2021-07-08 08:10:37 +02:00
|
|
|
;;
|
|
|
|
esac
|
2021-08-22 08:59:43 +02:00
|
|
|
|
|
|
|
systemd-notify --ready
|
|
|
|
trap "systemd-notify WATCHDOG=trigger" CHLD
|
|
|
|
wait
|