From ca968c4e5040f1ff4b5b5e12d9312360d807dcc1 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 3 Jun 2024 19:56:39 +0800 Subject: added submodules, change . -> dot (see man stow --dotfiles) --- dot-config/bspwm/themes/hack/polybar/launch.sh | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 dot-config/bspwm/themes/hack/polybar/launch.sh (limited to 'dot-config/bspwm/themes/hack/polybar/launch.sh') diff --git a/dot-config/bspwm/themes/hack/polybar/launch.sh b/dot-config/bspwm/themes/hack/polybar/launch.sh new file mode 100755 index 00000000..d5552039 --- /dev/null +++ b/dot-config/bspwm/themes/hack/polybar/launch.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +## Copyright (C) 2020-2022 Aditya Shakya + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +CARD="$(light -L | grep 'backlight' | head -n1 | cut -d'/' -f3)" +INTERFACE="$(ip link | awk '/state UP/ {print $2}' | tr -d :)" +RFILE="$DIR/.module" + +# Fix backlight and network modules +fix_modules() { + if [[ -z "$CARD" ]]; then + sed -i -e 's/backlight/bna/g' "$DIR"/config.ini + elif [[ "$CARD" != *"intel_"* ]]; then + sed -i -e 's/backlight/brightness/g' "$DIR"/config.ini + fi + + if [[ "$INTERFACE" == e* ]]; then + sed -i -e 's/network/ethernet/g' "$DIR"/config.ini + fi +} + +# Launch the bar +launch_bar() { + # Terminate already running bar instances + killall -q polybar + + # Wait until the processes have been shut down + while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done + + # Launch the bar + for mon in $(polybar --list-monitors | cut -d":" -f1); do + MONITOR=$mon polybar -q top -c "$DIR"/config.ini & + MONITOR=$mon polybar -q bottom -c "$DIR"/config.ini & + done +} + +# Execute functions +if [[ ! -f "$RFILE" ]]; then + fix_modules + touch "$RFILE" +fi +launch_bar -- cgit v1.2.3