2020-01-06 14:36:38 +01:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
let
|
|
|
|
|
|
|
|
unstable = import <nixpkgs-unstable> { };
|
|
|
|
|
2020-01-07 03:44:59 +01:00
|
|
|
taskNextWeek = pkgs.writers.writeDash "taskweek" ''
|
|
|
|
${pkgs.taskwarrior}/bin/task \
|
|
|
|
export \
|
|
|
|
status:pending and \( due.before:6days \) \
|
|
|
|
| ${pkgs.jq}/bin/jq '[.[] | { Day: .due, ID: .id, Description: .description | sub("\n.*";"")} ] | sort_by(.Day)' \
|
|
|
|
| ${pkgs.miller}/bin/mlr --ijson --opprint put '$Day = strftime(strptime($Day,"%Y%m%dT%H%M%SZ")'$(date +%z)'00,"%a")'
|
|
|
|
'';
|
|
|
|
|
2020-01-06 14:36:38 +01:00
|
|
|
activeTasks = pkgs.writers.writeBash "active-tasks" ''
|
|
|
|
${pkgs.taskwarrior}/bin/task export +checklist status:pending +READY | \
|
|
|
|
${pkgs.jq}/bin/jq \
|
|
|
|
--raw-output '
|
|
|
|
sort_by(.description) | reverse |
|
|
|
|
.[] |
|
|
|
|
"[ \( .id ) ] \( .description )"
|
|
|
|
'
|
|
|
|
echo
|
|
|
|
${pkgs.taskwarrior}/bin/task export \
|
|
|
|
+ACTIVE status:pending \
|
|
|
|
| ${pkgs.jq}/bin/jq --raw-output '.[] | "⇒ \(.id) \(.description)"'
|
|
|
|
'';
|
|
|
|
|
|
|
|
userHighlight = map ({ user, ... }: user)
|
|
|
|
(builtins.attrValues config.programs.custom.browser.configList);
|
|
|
|
|
|
|
|
activeUsers = pkgs.writers.writeBash "active-users" ''
|
|
|
|
${pkgs.procps}/bin/ps -eo user \
|
|
|
|
| ${pkgs.gnused}/bin/sed '1 d' \
|
|
|
|
| ${pkgs.coreutils}/bin/sort \
|
|
|
|
| ${pkgs.coreutils}/bin/uniq \
|
|
|
|
| ${pkgs.gnugrep}/bin/egrep --color=always '(${
|
|
|
|
pkgs.lib.concatStringsSep "|" userHighlight
|
|
|
|
})|$'
|
|
|
|
'';
|
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
# default settings
|
|
|
|
wtfModule =
|
|
|
|
args@{ height ? 1, width ? 1, top, left, enabled ? true, type, ... }:
|
|
|
|
{
|
|
|
|
enabled = enabled;
|
|
|
|
focusable = false;
|
|
|
|
position.top = top;
|
|
|
|
position.left = left;
|
|
|
|
position.height = height;
|
|
|
|
position.width = width;
|
|
|
|
} // (lib.filterAttrs
|
|
|
|
(key: _: lib.all (x: x != key) [ "height" "width" "top" "left" ]) args);
|
|
|
|
|
|
|
|
modules = {
|
|
|
|
|
|
|
|
# command runner module
|
|
|
|
cmdRunner = args@{ cmd, ... }:
|
|
|
|
wtfModule ({
|
|
|
|
type = "cmdrunner";
|
|
|
|
focusable = false;
|
|
|
|
refreshInterval = 300;
|
|
|
|
} // args);
|
|
|
|
|
|
|
|
digitalclock = args@{ top, left, ... }:
|
|
|
|
wtfModule ({
|
|
|
|
type = "digitalclock";
|
|
|
|
title = "";
|
|
|
|
color = "white";
|
|
|
|
font = "bigfont";
|
|
|
|
hourFormat = 24;
|
|
|
|
refreshInterval = 1;
|
|
|
|
} // args);
|
|
|
|
|
|
|
|
clocks = args@{ top, left, ... }:
|
|
|
|
wtfModule ({
|
|
|
|
type = "clocks";
|
|
|
|
title = "";
|
|
|
|
border = false;
|
|
|
|
colors.rows = {
|
|
|
|
even = "white";
|
|
|
|
odd = "white";
|
|
|
|
};
|
|
|
|
locations = {
|
|
|
|
Berlin = "Europe/Berlin";
|
|
|
|
Wellington = "Pacific/Auckland";
|
|
|
|
};
|
|
|
|
sort = "alphabetical";
|
|
|
|
refreshInterval = 60;
|
|
|
|
} // args);
|
|
|
|
|
|
|
|
resourceusage = args@{ top, left, ... }:
|
|
|
|
wtfModule ({
|
|
|
|
type = "resourceusage";
|
|
|
|
title = "";
|
|
|
|
cpuCombined = false;
|
|
|
|
refreshInterval = 5;
|
|
|
|
} // args);
|
|
|
|
|
|
|
|
power = args@{ top, left, ... }:
|
|
|
|
wtfModule ({
|
|
|
|
type = "power";
|
|
|
|
title = "";
|
|
|
|
refreshInterval = 100;
|
|
|
|
} // args);
|
|
|
|
|
|
|
|
prettyweather = args@{ top, left, ... }:
|
|
|
|
wtfModule ({
|
|
|
|
type = "prettyweather";
|
|
|
|
title = "";
|
|
|
|
city = "Wellington";
|
|
|
|
unit = "m";
|
|
|
|
view = 0;
|
|
|
|
language = "en";
|
|
|
|
refreshInterval = 3600;
|
|
|
|
} // args);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-01-06 14:36:38 +01:00
|
|
|
qJson = {
|
|
|
|
wtf = {
|
|
|
|
|
|
|
|
term = "rxvt-unicode-256color";
|
|
|
|
|
|
|
|
colors.border = {
|
|
|
|
focusable = "darkslateblue";
|
|
|
|
focused = "orange";
|
|
|
|
normal = "green";
|
|
|
|
};
|
|
|
|
|
|
|
|
grid = {
|
2020-01-07 03:44:59 +01:00
|
|
|
columns = [ 33 12 28 36 0 ];
|
2020-01-06 14:36:38 +01:00
|
|
|
rows = [ 9 3 7 6 0 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
refreshInterval = 1;
|
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
mods = with modules; {
|
2020-01-06 14:36:38 +01:00
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
digitalclock = digitalclock {
|
|
|
|
top = 0;
|
|
|
|
left = 0;
|
2020-01-06 14:36:38 +01:00
|
|
|
};
|
2020-01-07 00:07:17 +01:00
|
|
|
|
|
|
|
clocks = clocks {
|
|
|
|
top = 1;
|
|
|
|
left = 0;
|
2020-01-06 14:36:38 +01:00
|
|
|
};
|
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
top = resourceusage {
|
|
|
|
top = 0;
|
|
|
|
left = 1;
|
2020-01-07 03:44:59 +01:00
|
|
|
width = 2;
|
2020-01-06 14:36:38 +01:00
|
|
|
};
|
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
power = power {
|
|
|
|
top = 2;
|
|
|
|
left = 0;
|
2020-01-06 14:36:38 +01:00
|
|
|
};
|
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
rates = wtfModule {
|
2020-01-06 14:36:38 +01:00
|
|
|
type = "exchangerates";
|
2020-01-07 00:07:17 +01:00
|
|
|
top = 3;
|
|
|
|
left = 0;
|
2020-01-06 14:36:38 +01:00
|
|
|
title = "rates";
|
|
|
|
rates.NZD = [ "EUR" ];
|
|
|
|
rates.EUR = [ "NZD" ];
|
2020-01-07 03:44:59 +01:00
|
|
|
refreshInterval = 3600;
|
2020-01-06 14:36:38 +01:00
|
|
|
};
|
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
weather = prettyweather {
|
|
|
|
top = 0;
|
2020-01-07 03:44:59 +01:00
|
|
|
left = 3;
|
2020-01-06 14:36:38 +01:00
|
|
|
};
|
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
calendar = cmdRunner {
|
2020-01-06 14:36:38 +01:00
|
|
|
title = "";
|
|
|
|
args = [ "-3" "--monday" "--color=never" "-w" ];
|
|
|
|
cmd = "cal";
|
2020-01-07 00:07:17 +01:00
|
|
|
top = 1;
|
|
|
|
left = 1;
|
|
|
|
height = 2;
|
2020-01-07 03:44:59 +01:00
|
|
|
width = 3;
|
2020-01-06 14:36:38 +01:00
|
|
|
refreshInterval = 3600;
|
|
|
|
};
|
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
uptime = cmdRunner {
|
2020-01-06 14:36:38 +01:00
|
|
|
title = "uptime";
|
|
|
|
cmd = "uptime";
|
2020-01-07 00:07:17 +01:00
|
|
|
top = 3;
|
|
|
|
left = 1;
|
|
|
|
height = 1;
|
2020-01-07 03:44:59 +01:00
|
|
|
width = 3;
|
2020-01-06 14:36:38 +01:00
|
|
|
};
|
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
active-users = cmdRunner {
|
2020-01-06 14:36:38 +01:00
|
|
|
title = "users";
|
|
|
|
cmd = activeUsers;
|
2020-01-07 00:07:17 +01:00
|
|
|
top = 0;
|
2020-01-07 03:44:59 +01:00
|
|
|
left = 4;
|
2020-01-07 00:07:17 +01:00
|
|
|
height = 4;
|
|
|
|
width = 1;
|
2020-01-06 14:51:12 +01:00
|
|
|
refreshInterval = 30;
|
2020-01-06 14:36:38 +01:00
|
|
|
};
|
|
|
|
|
2020-01-07 00:07:17 +01:00
|
|
|
active-tasks = cmdRunner {
|
2020-01-06 14:36:38 +01:00
|
|
|
title = "active tasks";
|
|
|
|
cmd = activeTasks;
|
2020-01-07 00:07:17 +01:00
|
|
|
top = 4;
|
2020-01-07 03:44:59 +01:00
|
|
|
left = 2;
|
|
|
|
height = 1;
|
|
|
|
width = 3;
|
|
|
|
refreshInterval = 60;
|
|
|
|
};
|
|
|
|
|
|
|
|
next-week-tasks = cmdRunner {
|
|
|
|
title = "upcoming";
|
|
|
|
cmd = taskNextWeek;
|
|
|
|
top = 4;
|
2020-01-07 00:07:17 +01:00
|
|
|
left = 0;
|
|
|
|
height = 1;
|
2020-01-07 03:44:59 +01:00
|
|
|
width = 2;
|
2020-01-06 14:51:12 +01:00
|
|
|
refreshInterval = 60;
|
2020-01-06 14:36:38 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
qConfig = pkgs.writeText "config.yml" (builtins.toJSON qJson);
|
|
|
|
|
|
|
|
q = pkgs.writers.writeBashBin "q" ''
|
|
|
|
${unstable.wtf}/bin/wtfutil --config=${toString qConfig}
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
|
|
|
|
services.upower.enable = true;
|
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
unstable.wtf
|
|
|
|
q
|
|
|
|
#activeUsers
|
|
|
|
#activeTasks
|
|
|
|
pkgs.upower
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|