dotfiles/dot_config/polybar/executable_run.sh

24 lines
675 B
Bash

#!/bin/bash
echo "Killing polybar...";
killall -q polybar;
echo "Waiting for polybar to die...";
deadline=$(($(date +%s) + 10));
while pgrep -u $UID -x polybar >/dev/null; do
sleep 0.5;
[ $deadline -gt "$(date +%s)" ] || (
echo "Timed out, force-killing...";
killall -q -KILL polybar;
);
done
primary_monitor="$(xrandr --listactivemonitors \
| tail -n+2 | head -n 1 | awk '{print$4}')";
interfaces="$(ip a show up \
| sed -ne 's/^\([[:alnum:]]\+\): \+\([[:alnum:]]\+\).*$/\2/p' \
| grep -v ^lo)";
MONITOR=${primary_monitor} IFACES=${interfaces} polybar main & disown;
MONITOR=${primary_monitor} IFACES=${interfaces} polybar tray & disown;