nixos-config/profiles/workspace/i3blocks/scripts/default.nix

51 lines
2.0 KiB
Nix
Raw Normal View History

2020-02-17 17:00:59 +04:00
p: c:
with p;
2020-07-27 01:16:19 +04:00
let
iconfont = "Material Icons";
buildHaskellScript = name: script:
stdenv.mkDerivation {
inherit name;
src = script;
unpackPhase = "true";
buildInputs = [ghc];
buildPhase = "ghc -o $out $src";
installPhase = "true";
ICONFONT = iconfont;
};
writeScript = name: script:
writeTextFile {
inherit name;
text = callPackage script {
inherit iconfont;
config = c;
};
executable = true;
checkPhase =
"${bash}/bin/bash -n $src || ${python3}/bin/python3 -m compileall $src";
};
in
builtins.mapAttrs buildHaskellScript {
2020-02-17 17:00:59 +04:00
free = ./free.hs;
temperature = ./temperature.hs;
network = ./network.hs;
2020-07-27 01:16:19 +04:00
} // builtins.mapAttrs writeScript {
2020-02-17 17:00:59 +04:00
battery = ./battery.nix;
brightness = ./brightness.nix;
email = ./email.nix;
2022-05-30 14:12:15 +04:00
# emacs = ./emacs.nix;
2020-07-27 01:16:19 +04:00
bluetooth = ./bluetooth.nix;
2020-02-17 17:00:59 +04:00
connections = ./connections.nix;
weather = ./weather.nix;
sound = ./sound.nix;
music = ./music.nix;
youtrack-wage = ./youtrack-wage.nix;
2022-09-01 23:10:23 +04:00
cpu = {...}: ''${procps}/bin/top -b -n1 -p 1 | ${gnugrep}/bin/fgrep "Cpu(s)" | ${coreutils}/bin/tail -1 | ${gawk}/bin/awk -F'id,' -v prefix="$prefix" '{ split($1, vs, ","); v=vs[length(vs)]; sub("%", "", v); printf "%s%.1f%%\n", prefix, 100 - v }' '';
freq = {...}: ''echo $(${pkgs.bc}/bin/bc -l <<< "scale=2; `${coreutils}/bin/cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq|${coreutils}/bin/sort|${coreutils}/bin/tail -1`/1000000") GHz'';
df = {...}: ''echo '<span font="${iconfont}"></span>' `${coreutils}/bin/df / | ${coreutils}/bin/tail -1 | ${gnugrep}/bin/grep -o '..%'`'';
2020-07-27 01:16:19 +04:00
date = {...}: "${pkgs.coreutils}/bin/date +'<span font=\"${iconfont}\"></span> %a %y-%m-%d'";
time = {...}: "${pkgs.coreutils}/bin/date +'<span font=\"${iconfont}\"></span> %T'";
2022-09-01 23:10:23 +04:00
nixos = {...}: "echo -n '<span font=\"Material Icons 13\"></span>'; ${coreutils}/bin/cat /run/current-system/nixos-version | ${coreutils-full}/bin/cut -d. -f3";
2020-02-17 17:00:59 +04:00
#temperature = ./temperature.nix;
#free = ./free.nix;
}