all repos — dotfiles @ d59fbd2ea4d9ba33287b8b53ae0f69eb543f4ffb

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  cpufreq = "${pkgs.cpufrequtils}/bin/cpufreq-info";
 8  btctl = "${pkgs.bluezFull}/bin/bluetoothctl";
 9  barHeight = if host == "wyndle" then "50" else "30";
10in
11pkgs.writeShellScriptBin name
12  ''
13    dt() {
14        date +"%a, %d %b" | tr A-Z a-z
15    }
16
17    vol() {
18        ${pamixer} --get-volume
19    }
20
21    freq() {
22      printf '%sGHz' $(${cpufreq} -fm | cut -d' ' -f1)
23    }
24
25    temp() {
26      printf '%sC' $(( $(cat /sys/class/thermal/thermal_zone0/temp) / 1000 ))
27    }
28
29    audio_dev() {
30      con="$(${btctl} info | grep Connected | awk '{ print $2 }')"
31
32      if [[ "$con" == "yes" ]]; then
33        printf 'bt'
34      else
35        printf 'spkr'
36      fi
37    }
38
39    pad="%{015}"
40
41    while :; do
42        time="$(date +"%H:%M")"
43        echo "$pad $(dt) $pad $time %{r}temp $(temp) $pad cpu $(freq) $pad bat $(bat) $pad $(audio_dev) $(vol)% $pad"
44        sleep 0.5
45    done | ${lemonbar} -n bar -f 'Input:style=Regular:size=12:antialias=true' -g x${barHeight} \
46        -F '${theme.base00}' -B '${theme.base07}'
47  ''