;; ┌──────────────────────────────────────────────────────────────────────────────-----┐
;; │░█▀█░█▀█░█░░░█░█░█▀▄░█▀█░█▀▄░░░░░░░░░█░█░█▀▀░█▀▀░█▀▄░░░█▄█░█▀█░█▀▄░█░█░█░░░█▀▀░█▀▀ │
;; │░█▀▀░█░█░█░░░░█░░█▀▄░█▀█░█▀▄░░░░▀░░░░█░█░▀▀█░█▀▀░█▀▄░░░█░█░█░█░█░█░█░█░█░░░█▀▀░▀▀█ │
;; │░▀░░░▀▀▀░▀▀▀░░▀░░▀▀░░▀░▀░▀░▀░░░░▀░░░░▀▀▀░▀▀▀░▀▀▀░▀░▀░░░▀░▀░▀▀▀░▀▀░░▀▀▀░▀▀▀░▀▀▀░▀▀▀ │
;; │░Created░By░Aditya░Shakya░@adi1090x░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
;; └──────────────────────────────────────────────────────────────────────────────-----┘
;
;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
;[module/thunderbird]
;type = custom/script

;exec = find ~/.thunderbird/*/ImapMail -name 'INBOX*.msf' -exec sh -c "echo '{}' && grep '(^A2=' '{}' | tail -n1 | sed -r 's/.*\\(\\^A2=(\\w+)\\).*/\\1/' | xargs --replace=__ printf '%d\\n' '0x__'" \\; | grep -o '^[0-9]' | paste -sd+ | bc

;interval = 5

;format = <label>
;format-prefix =  
;label-padding = 1
;format-prefix-foreground = ${color.yellow}

[module/mu4e_edu]
type = custom/script

# Educational emails
exec = find ~/.mail -path '*\\.edu.*/*/new/*' -type f | wc -l

interval = 5

format =  <label>
label-padding = 1
format-prefix = 
format-prefix-foreground = ${color.yellow}

[module/mu4e]
type = custom/script

# anything /but/ educational emails
exec =  find ~/.mail -path '*/*/new/*' -not -path '*\\.edu.*/*/new/*' -type f | wc -l

interval = 5

format =  <label>
label-padding = 1
format-prefix = 
format-prefix-foreground = ${color.blue}

[module/ssh]
type = custom/script

exec =  (ssh-add -l > /dev/null && ssh-add -l | wc -l) || echo 0

interval = 5

format =  <label>
label-padding = 1
format-prefix = 
format-prefix-foreground = ${color.green}

# this checks if keepassxc is open, by using secret-tool
# secret-tool store --label='is_keepassxc_open' check status
# and type anything in the password prompt.
# See: https://github.com/keepassxreboot/keepassxc/discussions/7906
[module/keepassxc]
type = custom/script
exec-if = pgrep keepassxc
exec =  secret-tool lookup check status &> /dev/null && echo " "

interval = 20

format =  <label>
label-padding = 1
format-prefix = ""
format-prefix-foreground = ${color.green}

[module/org-clock]
type = custom/script

## At time of writing:
#  (defun my/polybar/org-clock ()
#    "Gets polybar formatted message"
#    (let ((message nil)
#            (icon nil)
#            (icon-color nil))
#        (if (org-clock-is-active)
#            (setq message (substring-no-properties (org-clock-get-clock-string))
#                    icon ""
#                    icon-color "#BA68C8")
#            (setq message ""
#                    icon ""
#                    icon-color "#FDD835"))
#        (concat "%{F" icon-color "}" icon  "%{F-}" message)))

exec-if = emacsclient --eval '(emacs-version)'
exec = emacsclient --eval '(my/polybar/org-clock)' | sed 's/"//g'


interval = 5

format =  <label>
label-padding = 1
format-prefix = ""
format-prefix-foreground = ${color.purple}

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

[module/updates]
type = custom/script


; Available tokens:
;   %counter%
; Command to be executed (using "/usr/bin/env sh -c [command]")
exec = ~/.config/polybar/forest/scripts/updates.sh

; Conditional command that, if defined, needs to exit successfully
; before the main exec command is invoked.
; Default: ""
;;exec-if = ""

; Will the script output continous content?
; Default: false
tail = true

; Seconds to sleep between updates
; Default: 2 (0 if `tail = true`)
interval = 2000

; Available tags:
;   <output> - deprecated
;   <label> (default)
format = <label>
format-prefix = 
format-prefix-foreground = ${color.yellow}

; Available tokens:
;   %output%
; Default: %output%
label = " %output%"

; Available tokens:
;   %counter%
;   %pid%
;
; "click-(left|middle|right)" will be executed using "/usr/bin/env sh -c [command]"
click-left = exo-open --launch TerminalEmulator &
click-right = rofi-sensible-terminal -e paru &
;;double-click-left = echo double left %counter%
;;double-click-middle = echo double middle %counter%
;;double-click-right = echo double right %counter%

; Available tokens:
;   %counter%
;   %pid%
;
; "scroll-(up|down)" will be executed using "/usr/bin/env sh -c [command]"
;;scroll-up = echo scroll up %counter%
;;scroll-down = echo scroll down %counter%


;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

[module/launcher]
type = custom/text

content = 
content-foreground = ${color.purple}

; "click-(left|middle|right)" will be executed using "/usr/bin/env sh -c $COMMAND"
click-left = ~/.config/polybar/forest/scripts/launcher.sh &
;;click-middle = ~/.config/polybar/forest/scripts/launcher-full
click-right = ~/.config/polybar/forest/scripts/style-switch.sh &

; "scroll-(up|down)" will be executed using "/usr/bin/env sh -c $COMMAND"
;;scroll-up = ~/.config/polybar/forest/scripts/launcher.sh &
;;scroll-down = ~/.config/polybar/forest/scripts/color-switch.sh &

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

[module/sysmenu]
type = custom/text

content = 
content-foreground = ${color.cyan}

click-left = ~/.config/polybar/forest/scripts/powermenu.sh &

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

[module/color-switch]
type = custom/text

content = 
content-foreground = ${color.red}

click-left = ~/.config/polybar/forest/scripts/style-switch.sh &

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

[module/sep]
type = custom/text
content = |

content-foreground = ${color.sep}

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

[module/apps]
type = custom/text

[module/term]
inherit = module/apps
content = 
content-foreground = ${color.blue-gray}
click-left = termite &
click-middle = urxvt &
click-right = xfce4-terminal &

[module/files]
inherit = module/apps
content = 
content-foreground = ${color.blue}
click-left = thunar &
click-right = pcmanfm &

[module/browser]
inherit = module/apps
content = 
content-foreground = ${color.orange}
click-left = firefox &
click-right = chromium &

[module/settings]
inherit = module/apps
content = 
content-foreground = ${color.teal}
click-left = xfce4-settings-manager &
click-right = lxappearance &

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

[module/powermenu]
type = custom/menu

; If true, <label-toggle> will be to the left of the menu items (default).
; If false, it will be on the right of all the items.
expand-right = true

; "menu-LEVEL-N" has the same properties as "label-NAME" with
; the additional "exec" property
;
; Available exec commands:
;   menu-open-LEVEL
;   menu-close
; Other commands will be executed using "/usr/bin/env sh -c $COMMAND"
menu-0-0 = " Reboot |"
menu-0-0-exec = menu-open-1
menu-0-1 = " Shutdown "
menu-0-1-exec = menu-open-2

menu-1-0 = " Back |"
menu-1-0-exec = menu-open-0
menu-1-1 = " Reboot "
menu-1-1-exec = systemctl reboot

menu-2-0 = " Shutdown |"
menu-2-0-exec = systemctl poweroff
menu-2-1 = " Back "
menu-2-1-exec = menu-open-0

; Available tags:
;   <label-toggle> (default) - gets replaced with <label-(open|close)>
;   <menu> (default)
; Note that if you use <label-toggle> you must also include
; the definition for <label-open>

format = <label-toggle><menu>

label-open = 
label-open-foreground = ${color.cyan}
label-open-padding = 1
label-close = 
label-close-foreground = ${color.red}
label-close-padding = 1

; Optional item separator
; Default: none
;label-separator = " | "
;label-separator-foreground = ${color.foreground}
;label-separator-background = ${color.background-alt}

;;label-open-foreground = ${color.foreground}
;;label-close-foreground = ${color.background}

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

[module/menu]
type = custom/menu

; If true, <label-toggle> will be to the left of the menu items (default).
; If false, it will be on the right of all the items.
expand-right = true

; "menu-LEVEL-N" has the same properties as "label-NAME" with
; the additional "exec" property
;
; Available exec commands:
;   menu-open-LEVEL
;   menu-close
; Other commands will be executed using "/usr/bin/env sh -c $COMMAND"
menu-0-0 ="  Menu | "
menu-0-0-exec = ~/.config/polybar/forest/scripts/launcher.sh &

menu-0-1 =" Files | "
menu-0-1-exec = thunar &

menu-0-2 =" Terminal | "
menu-0-2-exec = ($TERMINAL || termite)&
 
menu-0-3 =" Browser "
menu-0-3-exec = (librewolf || brave || firefox) &

; Available tags:
;   <label-toggle> (default) - gets replaced with <label-(open|close)>
;   <menu> (default)
; Note that if you use <label-toggle> you must also include
; the definition for <label-open>

format = <label-toggle><menu>

label-open = 
label-open-foreground = ${color.yellow}
label-open-padding = 1
label-close = 
label-close-foreground = ${color.red}
label-close-padding = 1

; Optional item separator
; Default: none
;label-separator = " | "

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
