summaryrefslogtreecommitdiff
path: root/dot-config/bspwm/themes/hack/polybar/launch.sh
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-06-03 19:56:39 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-06-03 19:56:39 +0800
commitca968c4e5040f1ff4b5b5e12d9312360d807dcc1 (patch)
tree9900920e8f566794560c1519678e344351d2803b /dot-config/bspwm/themes/hack/polybar/launch.sh
parent5f3deaff0bf006a1a353e57b82ad48c0e8f143bc (diff)
added submodules, change . -> dot (see man stow --dotfiles)
Diffstat (limited to 'dot-config/bspwm/themes/hack/polybar/launch.sh')
-rwxr-xr-xdot-config/bspwm/themes/hack/polybar/launch.sh43
1 files changed, 43 insertions, 0 deletions
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 <adi1090x@gmail.com>
+
+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