From 13aa86e8d1080c24afdeac51fbb8235990c8a001 Mon Sep 17 00:00:00 2001 From: adam <56338480+adastx@users.noreply.github.com> Date: Sun, 30 Oct 2022 19:39:55 +0100 Subject: polybar: major cleanup, wttr.in forecast --- .config/polybar/config.ini | 170 +++++++++++++++++---------------------- .local/bin/statusbar/sb-forecast | 48 +++++++++++ .local/bin/statusbar/sb-packages | 22 +++++ .local/bin/updates | 22 ----- 4 files changed, 142 insertions(+), 120 deletions(-) create mode 100755 .local/bin/statusbar/sb-forecast create mode 100755 .local/bin/statusbar/sb-packages delete mode 100755 .local/bin/updates diff --git a/.config/polybar/config.ini b/.config/polybar/config.ini index f77024e..837f956 100644 --- a/.config/polybar/config.ini +++ b/.config/polybar/config.ini @@ -9,176 +9,150 @@ orange = #fab387 red = #f38ba8 black = #000 white = #FFF -gray = #999 +gray = #99a0ba alert = #bd2c40 - -# i3wm focused-bg = #254183 unfocused-bg = #2c2c39 visible-bg = #182858 [bar/bar1] -monitor-fallback = eDP-1 -width = 100% -height = 28 +bottom = false +enable-ipc = true fixed-center = true -bottom = true - -background = ${colors.bg} -foreground = ${colors.fg} - -module-margin-right = 2 - -padding-left = 2 -padding-right = 2 - -font-0 = Averia Libre:style=bold:size=15;4 -font-1 = WeatherIcons:size=14;6 -font-2 = Font Awesome 5 Free Solid:size=14;4 -font-3 = Font Awesome 5 Pro Solid:size=14;4 -font-4 = Font Awesome 5 Free Regular:size=14;4 -font-5 = MaterialIcons:size=16;7 +monitor-fallback = eDP-1 +cursor-click = pointer modules-left = i3 xwindow -modules-center = -modules-right = weather updates-pacman-aurhelper xkeyboard pulseaudio battery date +modules-right = forecast packages xkeyboard pulseaudio battery network date -tray-maxsize = 25 -tray-position = none +font-0 = Averia Libre:style=bold:size=15;4 +font-1 = Font Awesome 6 Pro Solid:size=14;5 -cursor-click = pointer -cursor-scroll = ns-resize +background = ${colors.bg} +foreground = ${colors.fg} -enable-ipc = true +height = 28 +padding-left = 2 [module/xkeyboard] type = internal/xkeyboard blacklist-0 = num lock -format = -format-spacing = 1 +format = +format-padding = 2 -label-layout-padding = 2 -label-layout-foreground = ${colors.yellow} +label-indicator = %icon% +label-indicator-foreground = ${colors.red} -label-indicator-padding = 2 -label-indicator-background = ${colors.alert} -label-indicator-foreground = ${colors.white} +indicator-icon-0 = caps lock;; [module/i3] type = internal/i3 format = index-sort = true wrapping-scroll = false - -; Only show workspaces on the same output as the bar pin-workspaces = true +label-separator = " " +label-unfocused = %index% +label-focused = %index% +label-visible = %index% +label-urgent = %index% + +label-unfocused-padding = 3 +label-focused-padding = 3 +label-visible-padding = 3 +label-urgent-padding = 3 label-mode-padding = 3 -label-mode-foreground = ${colors.black} + label-mode-background = ${colors.purple} +label-mode-foreground = ${colors.black} -; focused = Active workspace on focused monitor -label-focused = %index% label-focused-background = ${colors.focused-bg} label-focused-foreground = ${colors.yellow} -label-focused-padding = 3 -; unfocused = Inactive workspace on any monitor -label-unfocused = %index% label-unfocused-background = ${colors.unfocused-bg} -label-unfocused-padding = 3 - -; visible = Active workspace on unfocused monitor -label-visible = %index% label-visible-background = ${colors.visible-bg} -label-visible-padding = ${self.label-focused-padding} - -; urgent = Workspace with urgency hint set -label-urgent = %index% label-urgent-background = ${colors.alert} -label-urgent-padding = 3 - -label-separator = " " [module/battery] type = internal/battery -full-at = 99 battery = BAT0 adapter = ADP1 -poll-interval = 5 +format-discharging = format-charging = -format-discharging = -format-full = - -format-charging-foreground = ${colors.red} -format-discharging-foreground = ${colors.red} -format-full-foreground = ${colors.red} +format-full = -label-charging = " %percentage%" -label-discharging = %percentage% -label-full = %percentage% +ramp-capacity-0 =  +ramp-capacity-1 =  +ramp-capacity-2 =  +ramp-capacity-3 =  +ramp-capacity-4 =  -label-charging-padding = 2 -label-discharging-padding-right = 2 -label-full-padding-right = 2 +label-charging =  +label-full =  -ramp-capacity-padding-left = 2 -ramp-capacity-0 = " " -ramp-capacity-1 = " " -ramp-capacity-2 = " " -ramp-capacity-3 = " " -ramp-capacity-4 = " " +format-discharging-padding = 2 +format-charging-padding = 2 +format-full-padding = 2 [module/date] type = internal/date interval = 5 -date-alt = "" -date = "%a, %d %b " - -time-alt = %H:%M -time = %H:%M - label = %date%%time% label-foreground = ${colors.blue} label-padding = 2 +date = "%a, %d %b " +date-alt = "" + +time = %H:%M +time-alt = %H:%M + [module/pulseaudio] type = internal/pulseaudio -format-volume = +format-volume = -label-volume = " %percentage%" -label-volume-foreground = ${colors.green} -label-volume-padding = 2 - -label-muted = " muted" +label-muted =  label-muted-foreground = ${colors.gray} label-muted-padding = 2 +ramp-volume-padding = 2 +ramp-volume-0 =  +ramp-volume-1 =  +ramp-volume-2 =  + [module/xwindow] type = internal/xwindow format-padding = 3 label-maxlen = 50 -[module/updates-pacman-aurhelper] +[module/packages] type = custom/script -exec = ~/.local/bin/updates -interval = 600 +exec = ~/.local/bin/statusbar/sb-packages format-foreground = ${colors.orange} format-padding = 2 +interval = 600 -[module/weather] +[module/forecast] type = custom/script -exec = ~/.local/bin/forecast -interval = 600 +exec = ~/.local/bin/statusbar/sb-forecast format-foreground = ${colors.purple} format-padding = 2 +interval = 600 + +click-left = ~/.local/bin/statusbar/sb-forecast --browser + +[module/network] +type = internal/network +interface-type = wireless +interval = 3.0 -[settings] -screenchange-reload = true +label-connected =  +label-disconnected =  -[global/wm] -margin-top = 5 -margin-bottom = 5 +label-connected-padding = 2 +label-disconnected-padding = 2 +label-disconnected-foreground = ${colors.gray} diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast new file mode 100755 index 0000000..ec3e590 --- /dev/null +++ b/.local/bin/statusbar/sb-forecast @@ -0,0 +1,48 @@ +#!/bin/bash + +LOCATION=$(<$XDG_CONFIG_HOME/forecast/location) + +main () { + case "$1" in + -b|--browser) + xdg-open https://wttr.in/$LOCATION + exit 0 ;; + esac + + res=$(curl -sf wttr.in/$LOCATION?format="%x+%t") || exit 1 + arr=($res) + + icon=$(condition_icon ${arr[0]}) + temp=$(temperature ${arr[1]}) + echo $icon $temp +} + +condition_icon () { + case "$1" in + 'mm') echo  ;; + '=') echo  ;; + '///') echo  ;; + '//') echo  ;; + '**') echo  ;; + '*/*') echo  ;; + '/') echo  ;; + '.') echo  ;; + 'x') echo  ;; + 'x/') echo  ;; + '*') echo  ;; + '*/') echo  ;; + 'm') echo  ;; + 'o') echo  ;; + '/!/') echo  ;; + '!/') echo  ;; + '*!*') echo  ;; + 'mmm') echo  ;; + *) echo ? ;; + esac +} + +temperature () { + echo $1 | sed 's/+//' | sed 's/C//' +} + +main "$@" diff --git a/.local/bin/statusbar/sb-packages b/.local/bin/statusbar/sb-packages new file mode 100755 index 0000000..bbdefb1 --- /dev/null +++ b/.local/bin/statusbar/sb-packages @@ -0,0 +1,22 @@ +#!/bin/sh + +if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then + updates_arch=0 +fi + +# if ! updates_aur=$(yay -Qum 2> /dev/null | wc -l); then +if ! updates_aur=$(paru -Qum 2> /dev/null | wc -l); then +# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then +# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then +# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then +# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then + updates_aur=0 +fi + +aur_ignored=$($HOME/.local/bin/aurignored | wc -l) + +updates=$((updates_arch + updates_aur - $aur_ignored)) + +if [ "$updates" -gt 0 ]; then + echo " $updates" +fi diff --git a/.local/bin/updates b/.local/bin/updates deleted file mode 100755 index 7af054a..0000000 --- a/.local/bin/updates +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then - updates_arch=0 -fi - -# if ! updates_aur=$(yay -Qum 2> /dev/null | wc -l); then -if ! updates_aur=$(paru -Qum 2> /dev/null | wc -l); then -# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then -# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then -# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then -# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then - updates_aur=0 -fi - -aur_ignored=$($HOME/.local/bin/aurignored | wc -l) - -updates=$((updates_arch + updates_aur - $aur_ignored)) - -if [ "$updates" -gt 0 ]; then - echo " $updates" -fi -- cgit v1.2.3-70-g09d2