all repos — dotfiles @ c2895b6fb3cfb1b791bf03a71deb1794687052ca

my *nix dotfiles

nix/bin/bar.nix (view raw)

 1{ pkgs, theme, host, ... }:
 2
 3let
 4  name = "bar";
 5  pamixer = "${pkgs.pamixer}/bin/pamixer";
 6  lemonbar = "${pkgs.lemonbar-xft}/bin/lemonbar";
 7  btctl = "${pkgs.bluezFull}/bin/bluetoothctl";
 8  barHeight = if host == "wyndle" then "50" else "30";
 9in
10pkgs.writeShellScriptBin name
11  ''
12    dt() {
13        date +"%a, %d %b" | tr A-Z a-z
14    }
15
16    vol() {
17        ${pamixer} --get-volume
18    }
19
20    audio_dev() {
21      con="$(${btctl} info | grep Connected | awk '{ print $2 }')"
22
23      if [[ "$con" == "yes" ]]; then
24        printf 'bt'
25      else
26        printf 'spkr'
27      fi
28    }
29
30    pad="%{015}"
31
32    while :; do
33        time="$(date +"%H:%M")"
34        echo "$pad $(dt) $pad $time %{r}bat $(bat) %{O14}$(audio_dev) $(vol)% $pad"
35        sleep 0.5
36    done | ${lemonbar} -n bar -f 'Input:style=Regular:size=12:antialias=true' -g x${barHeight} \
37        -F '${theme.base00}' -B '${theme.base07}'
38  ''