;==========================================================
;
;==========================================================

; Include powerline utility
include-file = ~/.config/polybar/powerline-for-polybar.config

; Include color scheme
include-file = ~/.config/polybar/colors.config

;=======================================
; Bar
;=======================================

[bar/example]
; Generic options
width          = 100%
height         = 26
dpi-x = 96
dpi-y = 96

tray-position = right
tray-background = ${colors.blue}
tray-offset-x = 0
tray-padding = 7

; Set bar's default background/foreground color
background     = #9912151c
foreground     = ${colors.white}

; Set bar's fonts list
font-0         = "Ubuntu:size=10.2:weight=85:antialias=true;3"
font-1         = "Source Code Pro:pixelsize=20:antialias=true;6"
font-2         = "Source Code Pro:size=11:weight=bold:antialias=true;3"
font-3         = "Font Awesome 6 Free Solid:size=11:antialias=true;3"
font-4         = "Font Awesome 6 Free:size=11:antialias=true;3"
font-5         = "Font Awesome 6 Brands:size=11:antialias=true;3"
font-6         = "Font Awesome v4 Compatibility:size=11:antialias=true;3"

; Set modules list
modules-left = xwindow
modules-center = i3
modules-right  = governor temperature memory clockspeed cpu pulseaudio battery updates date startarrow
fixed-center = true
monitor = eDP-1

;=======================================
; Modules
;=======================================
[module/startarrow]
inherit         = powerline-modules/right-to-left-starting-arrow
background      = ${colors.blue}
background-next = ${colors.background}

[module/pulseaudio]
type              = internal/pulseaudio
inherit           = powerline-templates/right-to-left-item
background        = ${colors.blue}
background-next   = ${colors.background}
label-muted-foreground = ${colors.gray}
format-foreground = ${colors.white}
format-volume-background = ${colors.blue}
format-muted-background = ${colors.blue}
format-volume = " <ramp-volume>  <label-volume>  "
format-muted = "   <label-volume>  "
ramp-volume-0 = 🔈
ramp-volume-1 = 🔊

[module/date]
; Powerline settings
inherit           = powerline-templates/right-to-left-item
background        = ${colors.background}
background-next   = ${colors.blue}
; Other settings
type              = internal/date
format-background = ${self.background}
format-foreground = ${colors.white}
date               = " %a %b %d, %H:%M:%S "

[module/cpu]
; Powerline settings
inherit           = powerline-templates/right-to-left-item
background        = ${colors.background}
background-next   = ${colors.blue}
; Other settings
type              = internal/cpu
format-background = ${self.background}
format-foreground = ${colors.white}
label             = " CPU %percentage%%  "

[module/memory]
; Powerline settings
inherit           = powerline-templates/right-to-left-item
background        = ${colors.background}
background-next   = ${colors.blue}
; Other settings
type              = internal/memory
format-background = ${self.background}
format-foreground = ${colors.white}
label             = " %used%  "

[module/updates]
; Powerline settings
inherit           = powerline-templates/right-to-left-item
background        = ${colors.blue}
background-next   = ${colors.background}
; Other settings
type = custom/script
format-background = ${self.background}
format-foreground = ${colors.white}
format-warn-background = ${self.background}
exec = checkupdates 2> /dev/null | wc -l
format = "    <label>  "
click-left = WINIT_X11_SCALE_FACTOR=1 alacritty -e bash -c "yay ; echo Done, press any key to exit... ; read"
interval = 90


[module/clockspeed]
; Powerline settings
inherit           = powerline-templates/right-to-left-item
background        = ${colors.blue}
background-next   = ${colors.background}
; Other settings
type = custom/script
format-background = ${self.background}
format-foreground = ${colors.white}
format-warn-background = ${self.background}
exec = cat /proc/cpuinfo | grep MHz | cut -b 12- | sort -r | head -n 1 | xargs printf '%f / 1000\\n' | bc -l | awk '{printf "%.2f\\n", $0}'
format = " <label> GHz  "

[module/temperature]
; Powerline settings
inherit           = powerline-templates/right-to-left-item
background        = ${colors.blue}
background-next   = ${colors.background}
; Other settings
type = custom/script
format-background = ${colors.blue}
format-foreground = ${colors.white}
format-warn-background = ${self.background}
exec = sensors | grep Package | cut -d ' ' -f 5 | cut -d '+' -f 2
format = " <label>  "

[module/governor]
; Powerline settings
inherit           = powerline-templates/right-to-left-item
background        = ${colors.background}
background-next   = ${root.background}
; Other settings
type = custom/script
format-background = ${self.background}
format-foreground = ${colors.white}
format-warn-background = ${self.background}
exec = cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
format = " <label>  "
click-left = /home/user/.config/scripts/toggle_performance.sh

[module/xwindow]
; Other settings
type              = internal/xwindow
inherit           = powerline-templates/left-to-right-item
background        = ${colors.blue}
background-next   = ${root.background}
format-background = ${self.background}
format-foreground = ${colors.white}
label             = "    %title%  "
label-maxlen = 80


[module/i3]
type = internal/i3
pin-workspaces = false
show-urgent = true
index-sort = true
enable-click = true
label-unfocused-padding = 3
label-focused-background = ${colors.blue}
label-visible-background = ${colors.background}
label-focused-padding = 3
label-focused-font=3
label-unfocused-font=3
label-visible-font=3
label-separator-padding = 2
label-focused = %index%
label-unfocused = %index%
label-visible = %index%
label-visible-mode = %mode%
label-mode-padding = 3
label-visible-padding = 3
label-mode-background = ${colors.blue}

[module/battery]
type = custom/script
inherit           = powerline-templates/right-to-left-item
background        = ${colors.background}
background-next   = ${colors.blue}
format-background = ${self.background}
format-foreground = ${colors.white}
exec = upower -i /org/freedesktop/UPower/devices/battery_BAT1 | ag percentage | awk '{print $2}'
format = " <label>   "
