mirror of https://gitlab.com/meliurwen/dotfiles
parent
30734e2010
commit
270655afe0
@ -1,33 +1,46 @@ |
|||||||
#!/bin/sh |
#!/bin/sh |
||||||
|
|
||||||
|
set -e |
||||||
|
|
||||||
|
# If at least one polybar process is running send a SIGTERM to all: |
||||||
|
# - Give a grace period of N cycles to all processes to terminate gracefully |
||||||
|
# - When the grace period is expired, send a SIGKILL to all |
||||||
|
cycle=0 |
||||||
|
while pgrep -u "$(id -u)" -x polybar >/dev/null |
||||||
|
do |
||||||
|
if [ $cycle -eq 0 ]; then |
||||||
# Terminate already running bar instances |
# Terminate already running bar instances |
||||||
killall -q polybar |
pkill -U "$(id -u)" -15 polybar |
||||||
|
elif [ $cycle -eq 4 ]; then |
||||||
# Wait until the processes have been shut down |
# At the 5th cylcle SIGKILL |
||||||
while pgrep -u "$(id -u)" -x polybar >/dev/null; do sleep 1; done |
pkill -U "$(id -u)" -9 polybar |
||||||
|
fi |
||||||
# Launch polybar |
sleep 1 |
||||||
#polybar main -c $HOME/.config/polybar/config & |
cycle=$((cycle + 1)) |
||||||
|
done |
||||||
# Set Monitors |
unset cycle |
||||||
#xrandr --output HDMI1 --auto --left-of LVDS1 |
|
||||||
|
|
||||||
POLY_IFACES="$(ip link show | awk '/^[0-9]+:/ {sub(/:/,"",$2); print $2}')" |
|
||||||
|
|
||||||
for NET_IFACE in $POLY_IFACES ; do |
NET_IFACES="$(ip link show | awk '/^[0-9]+:/ {sub(/:/,"",$2); print $2}')" |
||||||
|
for NET_IFACE in $NET_IFACES ; do |
||||||
case $NET_IFACE in |
case $NET_IFACE in |
||||||
wlp* ) POLY_WLP=$NET_IFACE ;; |
wlp* ) POLY_WLP=$NET_IFACE ;; |
||||||
enp* ) POLY_ENP=$NET_IFACE ;; |
enp* ) POLY_ENP=$NET_IFACE ;; |
||||||
esac |
esac |
||||||
done |
done |
||||||
|
unset NET_IFACES |
||||||
|
|
||||||
HWMON_BASEDIR="$(find "/sys/devices/platform/coretemp.0/hwmon/" -maxdepth 1 -type d -name 'hwmon*' | tail -n +2 | head -1)" |
HWMON_MODULE="/sys/devices/platform/coretemp.0/hwmon/" |
||||||
|
if [ -d "$HWMON_MODULE" ]; then |
||||||
|
HWMON_BASEDIR="$(find "$HWMON_MODULE" -maxdepth 1 -type d -name 'hwmon*' | tail -n +2 | head -1)" |
||||||
POLY_HWMON="$HWMON_BASEDIR"/temp1_input |
POLY_HWMON="$HWMON_BASEDIR"/temp1_input |
||||||
|
unset HWMON_BASEDIR |
||||||
|
fi |
||||||
|
unset HWMON_MODULE |
||||||
|
|
||||||
if type "xrandr"; then |
if type "xrandr"; then |
||||||
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do |
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do |
||||||
POLY_WLP=$POLY_WLP POLY_ENP=$POLY_ENP POLY_HWMON=$POLY_HWMON MONITOR=$m polybar main -c "$HOME/.config/polybar/config" & |
POLY_WLP=$POLY_WLP POLY_ENP=$POLY_ENP POLY_HWMON=$POLY_HWMON MONITOR=$m polybar main -c "$HOME/.config/polybar/config" & |
||||||
done |
done |
||||||
else |
|
||||||
POLY_WLP=$POLY_WLP POLY_ENP=$POLY_ENP POLY_HWMON=$POLY_HWMON MONITOR=$m polybar main -c "$HOME/.config/polybar/config" & |
|
||||||
fi |
fi |
||||||
|
|
||||||
|
unset POLY_WLP POLY_ENP POLY_HWMON |
||||||
|
Loading…
Reference in new issue