# Maintainer: Frederik Schwan <freswa at archlinux dot org>
# Contributor: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>

pkgname=i3status-rust
pkgver=0.20.4
pkgrel=1
pkgdesc='Resourcefriendly and feature-rich replacement for i3status, written in pure Rust'
arch=('x86_64')
url='https://github.com/greshake/i3status-rust'
license=('GPL3')
depends=('libpulse')
makedepends=('rust')
optdepends=('alsa-utils: for the volume block'
            'bluez: for the bluetooth block'
            'curl: for the weather block'
            'fakeroot: for the pacman block to show pending updates'
            'ibus: for the ibus block'
            'iw: display wifi signal strength in net block'
            'kdeconnect: for the kdeconnect block'
            'lm_sensors: for the temperature block'
            'networkmanager: for the networkmanager block'
            'powerline-fonts: for all themes using the Powerline arrow char'
            'pulseaudio: for the volume block'
            'speedtest-cli: for the speedtest block'
            'ttf-font-awesome: for the awesome icons'
            'upower: for the battery block')
source=("https://github.com/greshake/i3status-rust/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
b2sums=('94459d4efebdf654387487a2bd8aeaa24094f6d9dc3295ab5ab3245ff3a8c7b6a3c55b6dd0b1466a56dfc58ea9bb66c6c2b5b2b243f1297ad102de67cbdbd1f5')

build() {
  cd ${pkgname}-${pkgver}
  cargo build --release --locked --features 'pulseaudio maildir'
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm755 -t "${pkgdir}"/usr/bin target/release/i3status-rs
  install -Dm644 -t "${pkgdir}"/usr/share/man/man1 man/i3status-rs.1

  for icon in files/icons/*.toml; do
    install -Dm644 -t "${pkgdir}"/usr/share/${pkgname}/icons "${icon}"
  done

  for theme in files/themes/*.toml; do
    install -Dm644 -t "${pkgdir}"/usr/share/${pkgname}/themes "${theme}"
  done

  for example in examples/*.toml; do
    install -Dm644 -t "${pkgdir}"/usr/share/doc/${pkgname}/examples/ ${example}
  done
}
