Commit 19c22ff0 authored by Benedikt Vollmerhaus's avatar Benedikt Vollmerhaus

Add finished Polybar config and launch script

parent 3163be97
......@@ -348,7 +348,7 @@ exec --no-startup-id $term -name math -e R -q
exec_always --no-startup-id compton -b -i 0.95
# Delayed Polybar launch so Pywal has time to start before
exec_always --no-startup-id "sleep 1; exec $HOME/.config/polybar/launch"
exec_always --no-startup-id "sleep 1; exec $HOME/.config/polybar/launch_polybar"
# Custom Scripts
exec --no-startup-id $HOME/.config/i3/ -s 10
This diff is collapsed.
#!/usr/bin/env sh
# A launcher for Polybar which automatically starts the primary bar on the main
# screen and the secondary bar on all other screens. Additionally, it retrieves
# the system's first ethernet and wireless interfaces for the network module.
# Author: Benedikt Vollmerhaus
# License: MIT
launch_bar() {
MONITOR=$1 IFACE_ETH=${eth} IFACE_WLAN=${wlan} polybar "$2" &
# Terminate already running bar instances
killall -q polybar
# Wait until the processes have been shut down
while pgrep -u "$(id -u)" -x polybar >/dev/null; do
sleep 1;
eth=$(ip link | grep -m 1 -E '\b(en)' | awk '{print substr($2, 1, length($2)-1)}')
wlan=$(ip link | grep -m 1 -E '\b(wl)' | awk '{print substr($2, 1, length($2)-1)}')
printf "Found network interfaces: ${BLUE}%s${NC} (eth), ${BLUE}%s${NC} (wlan)\\n" "${eth}" "${wlan}"
# Use newline as field separator for looping over lines
# Ensure that xrandr is available and abort the script otherwise. Discard
# command's output by redirecting stdout to /dev/null and stderr to stdout.
if ! command -v xrandr >/dev/null 2>&1; then
printf "[ ${RED}Error${NC} ] Polybar launcher requires ${BLUE}xrandr${NC} for detecting monitors.\\n" >&2
for screen in $(xrandr --query | grep -w connected); do
# Substring removal, delete everything after first space
output=${screen%% *}
printf "Found output: ${BLUE}%s${NC}\\n" "${output}"
case ${screen} in
printf "Launching primary bar(s) on ${BLUE}%s${NC}\\n" "${output}"
launch_bar "${output}" top-primary
launch_bar "${output}" bottom-primary
printf "Launching secondary bar(s) on ${BLUE}%s${NC}\\n" "${output}"
launch_bar "${output}" top-secondary
launch_bar "${output}" bottom-secondary
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment