From 3ec063b8b8f7d6ff58889f5dbc04d116eef198ed Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Sat, 5 Feb 2022 13:50:56 -0500 Subject: [PATCH] polybar --- config/polybar/battery-combined-shell.sh | 61 +++++++++ config/polybar/config | 162 +++++++++++++++++++++++ config/polybar/i3wmthemer_bar_launch.sh | 7 + 3 files changed, 230 insertions(+) create mode 100755 config/polybar/battery-combined-shell.sh create mode 100644 config/polybar/config create mode 100755 config/polybar/i3wmthemer_bar_launch.sh diff --git a/config/polybar/battery-combined-shell.sh b/config/polybar/battery-combined-shell.sh new file mode 100755 index 0000000..9ded8cc --- /dev/null +++ b/config/polybar/battery-combined-shell.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +path_ac="/sys/class/power_supply/AC" +path_battery_0="/sys/class/power_supply/BAT0" +path_battery_1="/sys/class/power_supply/BAT1" + +ac=0 +battery_level_0=0 +battery_level_1=0 +battery_max_0=0 +battery_max_1=0 + +if [ -f "$path_ac/online" ]; then + ac=$(cat "$path_ac/online") +fi + +if [ -f "$path_battery_0/energy_now" ]; then + battery_level_0=$(cat "$path_battery_0/energy_now") +fi + +if [ -f "$path_battery_0/energy_full" ]; then + battery_max_0=$(cat "$path_battery_0/energy_full") +fi + +if [ -f "$path_battery_1/energy_now" ]; then + battery_level_1=$(cat "$path_battery_1/energy_now") +fi + +if [ -f "$path_battery_1/energy_full" ]; then + battery_max_1=$(cat "$path_battery_1/energy_full") +fi + +battery_level=$(("$battery_level_0 + $battery_level_1")) +battery_max=$(("$battery_max_0 + $battery_max_1")) + +battery_percent=$(("$battery_level * 100")) +battery_percent=$(("$battery_percent / $battery_max")) + +if [ "$ac" -eq 1 ]; then + icon="#1" + + if [ "$battery_percent" -gt 97 ]; then + echo "$icon" + else + echo "$icon $battery_percent %" + fi +else + if [ "$battery_percent" -gt 85 ]; then + icon="#21" + elif [ "$battery_percent" -gt 60 ]; then + icon="#22" + elif [ "$battery_percent" -gt 35 ]; then + icon="#23" + elif [ "$battery_percent" -gt 10 ]; then + icon="#24" + else + icon="#25" + fi + + echo "$icon $battery_percent %" +fi diff --git a/config/polybar/config b/config/polybar/config new file mode 100644 index 0000000..9eb2cc0 --- /dev/null +++ b/config/polybar/config @@ -0,0 +1,162 @@ +[bar/i3wmthemer_bar] +width = 100% +height = 27 +radius = 0 +fixed-center = true + +background = #162025 +foreground = #bfbfbf + +line-size = 3 +line-color = + +border-size = 0 +border-color = + +padding-left = 0 +padding-right = 2 + +module-margin-left = 1 +module-margin-right = 2 + +font-0 = "Source Code Pro Semibold:size=10;1" +font-1 = "Font Awesome 5 Free:style=Solid:size=10;1" +font-2 = "Font Awesome 5 Brands:size=10;1" + +modules-left = i3 +modules-center = date +modules-right = custom-battery wlan powermenu + +tray-position = right +tray-padding = 10 + +cursor-click = pointer +cursor-scroll = ns-resize + +[module/i3] +type = internal/i3 +format = +index-sort = true +wrapping-scroll = false + +label-mode-padding = 2 +label-mode-foreground = #162025 +label-mode-background = #75404b + +label-focused = %index% +label-focused-background = #75404b +label-focused-foreground = #6b7443 +label-focused-padding = 2 + +label-unfocused = %index% +label-unfocused-background = #75404b +label-unfocused-foreground = #162025 +label-unfocused-padding = 2 + +label-visible = %index% +label-visible-background = #75404b +label-visible-foreground = #162025 +label-visible-padding = 2 + +label-urgent = %index% +label-urgent-background = #BA2922 +label-urgent-padding = 2 + +[module/wlan] +type = internal/network +interface = nwlp2s0 +interval = 3.0 + +format-connected = +format-connected-foreground = #162025 +format-connected-background = #39402e +format-connected-padding = 2 +label-connected = %essid% + +format-disconnected = + +ramp-signal-0 =  +ramp-signal-1 =  +ramp-signal-2 =  +ramp-signal-3 =  +ramp-signal-4 =  +ramp-signal-foreground = #162025 + +[module/eth] +type = internal/network +interface = enp0s3 +interval = 3.0 + +format-connected-padding = 2 +format-connected-foreground = #162025 +format-connected-background = #39402e +format-connected-prefix = " " +format-connected-prefix-foreground = #162025 +label-connected = %local_ip% + +format-disconnected = + +[module/date] +type = internal/date +interval = 5 + +date = +date-alt = " %Y-%m-%d" + +time = %H:%M +time-alt = %H:%M:%S + +format-prefix =  +format-foreground = #162025 +format-background = #4c584a +format-padding = 2 + +label = %date% %time% + +[module/powermenu] +type = custom/menu + +expand-right = true + +format-spacing = 1 + +label-open =  +label-open-foreground = #39402e +label-close =  cancel +label-close-foreground = #39402e +label-separator = | +label-separator-foreground = #39402e + +menu-0-0 = reboot +menu-0-0-exec = menu-open-1 +menu-0-1 = power off +menu-0-1-exec = menu-open-2 +menu-0-2 = log off +menu-0-2-exec = menu-open-3 + +menu-1-0 = cancel +menu-1-0-exec = menu-open-0 +menu-1-1 = reboot +menu-1-1-exec = reboot + +menu-2-0 = power off +menu-2-0-exec = poweroff +menu-2-1 = cancel +menu-2-1-exec = menu-open-0 + +menu-3-0 = log off +menu-3-0-exec = pkill -KILL -u $USER +menu-3-1 = cancel +menu-3-1-exec = menu-open-0 + +[settings] +screenchange-reload = true + +[global/wm] +margin-top = 0 +margin-bottom = 0 + +[module/custom-battery] +type = custom/script +exec = polybar-ab -polybar -thr 10 +tail = true \ No newline at end of file diff --git a/config/polybar/i3wmthemer_bar_launch.sh b/config/polybar/i3wmthemer_bar_launch.sh new file mode 100755 index 0000000..9a4928f --- /dev/null +++ b/config/polybar/i3wmthemer_bar_launch.sh @@ -0,0 +1,7 @@ +#!/bin/env sh + +pkill polybar + +sleep 1; + +polybar i3wmthemer_bar &