diff options
author | aszlig <aszlig@redmoonstudios.org> | 2015-03-18 02:46:15 +0100 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2015-03-18 02:46:15 +0100 |
commit | e91c0b0c2269a8ab0158863dc1c074daf46001f7 (patch) | |
tree | cfb21b6e78bc61de7b653a71db5af06a61951a72 /modules/i3/conky.nix | |
parent | 147ee83ee25b0c5d4a0600b12e31d6c994a5a9ca (diff) |
modules: Move own stuff into modules/user/aszlig.
Some modules might be generic enough to be included in modules/ directly, but for now, let's just get them out of the way. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules/i3/conky.nix')
-rw-r--r-- | modules/i3/conky.nix | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/modules/i3/conky.nix b/modules/i3/conky.nix deleted file mode 100644 index 77a63ea5..00000000 --- a/modules/i3/conky.nix +++ /dev/null @@ -1,115 +0,0 @@ -{ pkgs ? import <nixpkgs> {}, timeout ? 300 }: - -with pkgs.lib; - -let - baseConfig = pkgs.writeText "conkyrc" '' - cpu_avg_samples 2 - net_avg_samples 2 - no_buffers yes - out_to_console yes - out_to_ncurses no - out_to_stderr no - out_to_x no - extra_newline no - update_interval 1.0 - uppercase no - use_spacer none - pad_percents 3 - use_spacer left - TEXT - ''; - - optexpr = name: expr: "\${${name}_disabled:-\\\${${name} ${expr}\\}}"; - cexpr = name: args: "${optexpr name (concatStringsSep " " args)}"; - - mkNetInfo = iface: let - upspeed = cexpr "upspeed" [ iface ]; - downspeed = cexpr "downspeed" [ iface ]; - in "${upspeed} ${downspeed}"; - - mkDiskFree = path: let - used = cexpr "fs_used" [ path ]; - size = cexpr "fs_size" [ path ]; - in "${used}/${size}"; - - gpuTemp = "${cexpr "hwmon" [ "0" "temp" "1" ]}C"; - - weather = (cexpr "weather" [ - "http://weather.noaa.gov/pub/data/observations/metar/stations/" - "EDMA" - "temperature" - ]) + "C"; - - mkConky = args: let - time = cexpr "time" [ "%a %b %d %T %Z %Y" ]; - text = concatStringsSep " | " (args ++ singleton time); - conky = pkgs.conky.override { - weatherMetar = true; - }; - in pkgs.writeScript "conky-run.sh" '' - #!${pkgs.stdenv.shell} - PATH="${pkgs.coreutils}/bin" - - cpuload() { - for i in $(seq 1 $(nproc)) - do - [ $i -eq 1 ] || echo -n ' ' - echo -n "\''${cpu cpu$i}%" - done - } - - cputemp_collect() { - for i in /sys/bus/platform/devices/coretemp.?/hwmon/hwmon?/temp?_input - do - [ -e "$i" ] || continue - echo "$i" | ${pkgs.gnused}/bin/sed -re \ - 's/^.*hwmon([0-9]+)[^0-9]*([0-9]+).*$/''${hwmon \1 temp \2}/' - done - } - - cputemp() { - echo $(cputemp_collect) - } - - tries=0 - while ! raw_netinfo="$(${ - "${pkgs.iproute}/sbin/ip route get 8.8.8.8 2> /dev/null" - })"; do - if [ $tries -ge ${toString timeout} ]; then - upspeed_disabled=N/A - downspeed_disabled=N/A - break - fi - echo "Waiting for primary network interface to become available..." - tries=$(($tries + 1)) - sleep 1 - done - - primary_netdev="$(echo "$raw_netinfo" | \ - ${pkgs.gnused}/bin/sed -nre 's/^.*dev *([^ ]+).*$/\1/p')" - - ${conky}/bin/conky -c "${baseConfig}" -t "${text}" - ''; - -in { - left = mkConky [ - "CPU: $(cpuload) - ${cexpr "cpu" [ "cpu0" ]}%" - "MEM: \\$mem/\\$memmax - \\$memperc%" - "SWAP: \\$swap/\\$swapmax \\$swapperc%" - ]; - - right = mkConky [ - "NET: ${mkNetInfo "$primary_netdev"}" - "DF: ${mkDiskFree "/"}" - "LAVG: \\$loadavg" - "TEMP - CPU: $(cputemp) - GPU: ${gpuTemp} - OUTSIDE: ${weather}" - ]; - - single = mkConky [ - "CPU: $(cpuload) - ${cexpr "cpu" [ "cpu0" ]}%" - "MEM: \\$mem/\\$memmax - \\$memperc%" - "NET: ${mkNetInfo "$primary_netdev"}" - "TEMP - CPU: $(cputemp) - OUTSIDE: ${weather}" - ]; -} |