# Typical laptop setup, with wifi, brightness, battery etc, for
# i3/Sway.

# For X11/i3, you'll want to replace calls to swaymsg with i3-msg, and
# the sway-xkb module with the xkb module.

# fonts we'll be re-using here and there
awesome: &awesome Font Awesome 6 Free:style=solid:pixelsize=14
awesome_brands: &awesome_brands Font Awesome 6 Brands:pixelsize=16

std_underline: &std_underline {underline: { size: 2, color: ff0000ff}}

# This is THE bar configuration
bar:
  height: 26
  location: top
  spacing: 5
  margin: 7

  # Default font
  font: Adobe Helvetica:pixelsize=12

  foreground: ffffffff
  background: 9636C088

  border:
    width: 1
    color: 999999cc

    margin: 5
    top-margin: 0

  left:
    - script:
        path: ~/.config/yambar/scripts/hyprland_ws.sh
        args: []
        content:
          {string: {text: "WorkSpace: {ws}"}}
    #- foreign-toplevel:
        #content:
          #map:
            #conditions:
              #~activated: {empty: {}}
              #activated:
                #- string: {text: "{app-id}", foreground: ffa0a0ff}
                #- string: {text: ": {title}"}
  center:
    - mpd:
        host: /run/mpd/socket
        anchors:
          list: &artist_album_title
            spacing: 0
            items:
              - map:
                  conditions:
                    state == playing: {string: {text: "{artist}"}}
                    state == paused: {string: {text: "{artist}", foreground: ffffff66}}
              - string: {text: " | ", foreground: ffffff66}
              - map:
                  conditions:
                    state == playing: {string: {text: "{album}"}}
                    state == paused: {string: {text: "{album}", foreground: ffffff66}}
              - string: {text: " | ", foreground: ffffff66}
              - map:
                  conditions:
                    state == playing: {string: {text: "{title}", foreground: ffa0a0ff}}
                    state == paused: {string: {text: "{title}", foreground: ffffff66}}

        content:
          map:
            margin: 10
            conditions:
              state == stopped: {string: {text: stopped}}
              state == paused: {list: *artist_album_title}
              state == playing: {list: *artist_album_title}

  right:
    - removables:
        anchors:
          drive: &drive { text: "💿", font: *awesome}
          optical: &optical {text: "💿", font: *awesome}
        spacing: 5
        content:
          map:
            conditions:
              ~mounted:
                map:
                  on-click: udisksctl mount -b {device}
                  conditions:
                    ~optical: [{string: *drive}, {string: {text: "{label}"}}]
                    optical: [{string: *optical}, {string: {text: "{label}"}}]
              mounted:
                map:
                  on-click: udisksctl unmount -b {device}
                  conditions:
                    ~optical:
                      - string: {<<: *drive, deco: *std_underline}
                      - string: {text: "{label}"}
                    optical:
                      - string: {<<: *optical, deco: *std_underline}
                      - string: {text: "{label}"}
    # - sway-xkb:
        # identifiers: [1:1:AT_Translated_Set_2_keyboard]
        # content:
          # - string: {text: "", font: *awesome}
          # - string: {text: "{layout}"}
    - network:
        content:
          map:
            default:
              string: {text: "🛜 {ssid} ({quality}%) {signal}dBm"}
            conditions:
              name == "eno1" && name == "Io": # || name == "lo":
                string: {text: ""}
              ipv4 == "":
                string: {text: "{name}: {state} {ssid}"}
    - alsa:
        card: hw:PCH
        mixer: Master
        content:
          map:
            conditions:
              ~online: {string: {text: "", font: *awesome, foreground: ff0000ff}}
              online:
                map:
                  on-click: /bin/sh -c "amixer -q sset Speaker unmute && amixer -q sset Headphone unmute && amixer -q sset Master toggle"
                  conditions:
                    muted: {string: {text: "🔇", font: *awesome, foreground: ffffff66}}
                    ~muted:
                      ramp:
                        tag: percent
                        items:
                          - string: {text: "🔈", font: *awesome}
                          - string: {text: "🔉", font: *awesome}
                          - string: {text: "🔊", font: *awesome}
    - battery:
        name: BAT0
        poll-interval: 30000
        anchors:
          discharging: &discharging
            list:
              items:
                - ramp:
                    tag: capacity
                    items:
                      - string: {text: "", foreground: ff0000ff, font: *awesome}
                      - string: {text: "", foreground: ffa600ff, font: *awesome}
                      - string: {text: "", font: *awesome}
                      - string: {text: "", font: *awesome}
                      - string: {text: "", font: *awesome}
                      - string: {text: "", font: *awesome}
                      - string: {text: "", font: *awesome}
                      - string: {text: "", font: *awesome}
                      - string: {text: "", font: *awesome}
                      - string: {text: "", foreground: 00ff00ff, font: *awesome}
                - string: {text: "🔋{capacity}% {state} {estimate}"}
        content:
          map:
            conditions:
              state == unknown:
                <<: *discharging
              state == discharging:
                <<: *discharging
              state == charging:
                - string: {text: "", foreground: 00ff00ff, font: *awesome}
                - string: {text: "{capacity}% {estimate}"}
              state == full:
                - string: {text: "", foreground: 00ff00ff, font: *awesome}
                - string: {text: "{capacity}% full"}
              state == "not charging":
                - ramp:
                    tag: capacity
                    items:
                      - string: {text: "", foreground: ff0000ff, font: *awesome}
                      - string: {text: "", foreground: ffa600ff, font: *awesome}
                      - string: {text: "", foreground: 00ff00ff, font: *awesome}
                      - string: {text: "", foreground: 00ff00ff, font: *awesome}
                      - string: {text: "", foreground: 00ff00ff, font: *awesome}
                      - string: {text: "", foreground: 00ff00ff, font: *awesome}
                      - string: {text: "", foreground: 00ff00ff, font: *awesome}
                      - string: {text: "", foreground: 00ff00ff, font: *awesome}
                      - string: {text: "", foreground: 00ff00ff, font: *awesome}
                      - string: {text: "", foreground: 00ff00ff, font: *awesome}
                - string: {text: "{capacity}%"}
    - clock:
        time-format: "%H:%M:%S"
        date-format: "%d/%m/%Y"
        content:
          - string: {text: "📅", font: *awesome}
          - string: {text: "{date}", right-margin: 5}
          - string: {text: "🕓", font: *awesome}
          - string: {text: "{time}"}
    - label:
        content:
          string:
            on-click: systemctl poweroff
            text: "♇"
            font: *awesome

