diff options
| author | Christoph Schlosser <christoph@linux.com> | 2025-09-07 18:47:52 +0200 |
|---|---|---|
| committer | Christoph Schlosser <christoph@linux.com> | 2025-09-07 18:48:21 +0200 |
| commit | 875b3add8f4e265eeabd125472fb6d5186d3f8d5 (patch) | |
| tree | 8dba6a51a060fecec8d58e0777925698624a704e /polybar | |
| parent | 8e40fea5c0e42dc1204d35292e350d660ee3ed95 (diff) | |
| download | dots-875b3add8f4e265eeabd125472fb6d5186d3f8d5.tar.gz | |
polybar: Add config
Diffstat (limited to 'polybar')
| -rwxr-xr-x | polybar/OpenBSD-battery.sh | 27 | ||||
| -rwxr-xr-x | polybar/OpenBSD-storage.sh | 15 | ||||
| -rwxr-xr-x | polybar/OpenBSD-vol.sh | 17 | ||||
| -rwxr-xr-x | polybar/OpenBSD-wifi.sh | 14 | ||||
| -rw-r--r-- | polybar/config | 149 | ||||
| -rwxr-xr-x | polybar/info-hlwm-workspaces.sh | 65 | ||||
| -rwxr-xr-x | polybar/plat.sh | 6 |
7 files changed, 293 insertions, 0 deletions
diff --git a/polybar/OpenBSD-battery.sh b/polybar/OpenBSD-battery.sh new file mode 100755 index 0000000..a63f766 --- /dev/null +++ b/polybar/OpenBSD-battery.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +time_fmt() { + MINUTES=$1 + if [[ $MINUTES -ge 60 ]]; then + ((h=${MINUTES}/60)) + ((m=${MINUTES}%60)) + if [[ $h -ge 99 ]]; then + echo -n "long" + else + printf "%02d:%02d" $h $m + fi + elif [[ "$MINUTES" != 'unknown' ]]; then + echo -n "${MINUTES}m" + fi +} + +while true; do + PERCENT=$(apm -l) + MIN_REMAINING=$(time_fmt $(apm -m)) + CHARGING='' + if [[ "$(apm -b)" -eq 3 ]]; then + CHARGING='+' + fi + echo "$PERCENT% (${CHARGING}${MIN_REMAINING})" + sleep 60 +done diff --git a/polybar/OpenBSD-storage.sh b/polybar/OpenBSD-storage.sh new file mode 100755 index 0000000..6acd8b4 --- /dev/null +++ b/polybar/OpenBSD-storage.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +function print_line() { + echo -n "%{F#555}$1: %{F-}$2 " +} + +while true; do + while IFS= read -r LINE; do + PART="$(awk '{print $1}' <<< $LINE)" + PERC="$(awk '{print $5}' <<< $LINE)" + print_line ${PART: -1} $PERC + done <<< "$(df | grep '/dev/' | sort)" + echo + sleep 5 +done diff --git a/polybar/OpenBSD-vol.sh b/polybar/OpenBSD-vol.sh new file mode 100755 index 0000000..ff083f2 --- /dev/null +++ b/polybar/OpenBSD-vol.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +function sndio_val() { + sndioctl "$1" | awk -F'=' '{print $2}' +} + +while true; do + LEVEL=$(sndio_val output.level | bc) + MUTE=$(sndio_val output.mute) + if [[ $MUTE -eq 1 ]]; then + echo 'muted' + else + LEVEL=${LEVEL/./} + echo "$(( LEVEL/10 ))%" + fi + sleep 1 +done diff --git a/polybar/OpenBSD-wifi.sh b/polybar/OpenBSD-wifi.sh new file mode 100755 index 0000000..e778c92 --- /dev/null +++ b/polybar/OpenBSD-wifi.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +IF=iwx0 + +while true; do + WIFI_STATUS=$(ifconfig $IF | grep status | awk -F': ' '{print $2}') + if [[ "$WIFI_STATUS" != "active" ]]; then + echo 'Not connected' + else + WIFI_NAME=$(ifconfig iwx0 | sed -En 's/.*join (.*) chan.*/\1/p') + echo "${WIFI_NAME//\"/}" + fi + sleep 60 +done diff --git a/polybar/config b/polybar/config new file mode 100644 index 0000000..87e51ff --- /dev/null +++ b/polybar/config @@ -0,0 +1,149 @@ +;========================================================== +; +; +; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗ +; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗ +; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝ +; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗ +; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║ +; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ +; +; +; To learn more about how to configure Polybar +; go to https://github.com/polybar/polybar +; +; The README contains a lot of information +; +;========================================================== + +[colors] +;background = ${xrdb:color0:#222} +background = #222 +background-alt = #444 +;foreground = ${xrdb:color7:#222} +foreground = #dfdfdf +foreground-alt = #555 +primary = #ffb52a +secondary = #e60053 +alert = #bd2c40 + +[bar/herbstluft] +monitor = ${env:MONITOR:} +width = 100% +height = 32 +dpi = 192 + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 3 +line-color = #f00 + +border-color = #00000000 + +padding-left = 2 +padding-right = 4 + +module-margin-left = 0 +module-margin-right = 1 + +font-0 = Cousine NF:pixelsize=8;1 +font-1 = NotoSansM Nerd Font Mono:pixelsize=8;0 +font-2 = Siji:pixelsize=10;1 + +modules-left = info-hlwm-workspaces xwindow +modules-center = +modules-right = cpu memory storage battery wifi volume date + +[module/volume] +interval = 1 +type = custom/script +exec = "~/.config/polybar/plat.sh vol" +tail = true +format-prefix = "VOL: " +format-prefix-foreground = ${colors.foreground-alt} +format-underline = #C4C1DC + +[module/storage] +interval = 1 +type = custom/script +exec = "~/.config/polybar/plat.sh storage" +tail = true +format-prefix-foreground = ${colors.foreground-alt} +format-underline = #DE965D + +[module/battery] +interval = 60 +type = custom/script +exec = "~/.config/polybar/plat.sh battery" +tail = true +format-prefix = "BAT: " +format-prefix-foreground = ${colors.foreground-alt} +format-underline = #C4C1DC + +[module/wifi] +interval = 60 +type = custom/script +exec = "~/.config/polybar/plat.sh wifi" +tail = true +format-prefix = "WIFI: " +format-prefix-foreground = ${colors.foreground-alt} +format-underline = #DE965D + +[module/info-hlwm-workspaces] +type = custom/script +exec = ~/.config/polybar/info-hlwm-workspaces.sh +tail = true +scroll-up = herbstclient use_index -1 --skip-visible & +scroll-down = herbstclient use_index +1 --skip-visible & + +[module/xwindow] +type = internal/xwindow +label = %title:0:72:...% + +[module/cpu] +type = internal/cpu +interval = 2 +format-prefix = "CPU: " +format-prefix-foreground = ${colors.foreground-alt} +format-underline = #DE965D +label = %percentage:2%% + +[module/memory] +type = internal/memory +interval = 2 +format-prefix = "MEM: " +format-prefix-foreground = ${colors.foreground-alt} +format-underline = #C4C1DC +label = %percentage_used%% + +[module/date] +type = internal/date +interval = 1 + +date = "%d. %b" +date-alt = " %Y-%m-%d" + +time-alt = %H:%M +time = %H:%M:%S + +format-prefix-foreground = ${colors.foreground-alt} +format-underline = #DE965D + +label = %date% %time% + +;hidden = true + +[settings] +screenchange-reload = true +;compositing-background = xor +;compositing-background = screen +;compositing-foreground = source +;compositing-border = over +;pseudo-transparency = false + +[global/wm] +margin-top = 5 +margin-bottom = 5 + +; vim:ft=dosini diff --git a/polybar/info-hlwm-workspaces.sh b/polybar/info-hlwm-workspaces.sh new file mode 100755 index 0000000..4a42500 --- /dev/null +++ b/polybar/info-hlwm-workspaces.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Multi monitor support. Needs MONITOR environment variable to be set for each instance of polybar +# If MONITOR environment variable is not set this will default to monitor 0 +# Check https://github.com/polybar/polybar/issues/763 +MON_IDX="0" +mapfile -t MONITOR_LIST < <(polybar --list-monitors | cut -d":" -f1) +for (( i=0; i<$((${#MONITOR_LIST[@]})); i++ )); do + [[ ${MONITOR_LIST[${i}]} == "$MONITOR" ]] && MON_IDX="$i" +done; + +herbstclient --idle "tag_*" 2>/dev/null | { + while true; do + # Read tags into $tags as array + IFS=$'\t' read -ra tags <<< "$(herbstclient tag_status "${MON_IDX}")" + { + for i in "${tags[@]}" ; do + name=${i#?} + # Read the prefix from each tag and render them according to that prefix + case ${i:0:1} in + '.') + # the tag is empty + printf "%%{F#707880}" + ;; + ':') + # the tag is not empty + printf "%%{F#C5C8C6}" + ;; + '+') + # the tag is viewed on the specified MONITOR, but this monitor is not focused. + printf "%%{F#cccccc}" + ;; + '#') + # the tag is viewed on the specified MONITOR and it is focused. + printf "%%{R}" + ;; + '-') + # the tag is viewed on a different MONITOR, but this monitor is not focused. + # TODO Add your formatting tags + ;; + '%') + # the tag is viewed on a different MONITOR and it is focused. + # TODO Add your formatting tags + ;; + '!') + # the tag contains an urgent window + printf "%%{B#CC6666}" + ;; + esac + + # focus the monitor of the current bar before switching tags + echo "%{A1:herbstclient focus_monitor ${MON_IDX}; herbstclient use ${i:1}:} ${i:1} %{A -u -o F- B-}" + done + + # reset foreground and background color to default + echo "%{F-}%{B-}" + } | tr -d "\n" + + echo + + # wait for next event from herbstclient --idle + read -r || break +done +} 2>/dev/null + diff --git a/polybar/plat.sh b/polybar/plat.sh new file mode 100755 index 0000000..b8797f6 --- /dev/null +++ b/polybar/plat.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +PLAT=$(uname) +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") + +"${SCRIPT_DIR}/${PLAT}-${1}.sh" |