2022-03-10 21:52:12 +01:00
|
|
|
{
|
|
|
|
|
pkgs,
|
|
|
|
|
wirelessInterface,
|
|
|
|
|
colours,
|
|
|
|
|
batteryName,
|
|
|
|
|
}: let
|
2020-09-24 19:16:51 +02:00
|
|
|
inherit (pkgs) lib;
|
|
|
|
|
|
2020-06-10 17:37:25 +02:00
|
|
|
setsid = script:
|
|
|
|
|
pkgs.writers.writeDash "setsid-command" ''
|
2022-10-06 10:05:11 +02:00
|
|
|
${pkgs.util-linux}/bin/setsid ${script}
|
2020-06-10 17:37:25 +02:00
|
|
|
'';
|
2022-08-21 02:13:54 +02:00
|
|
|
|
|
|
|
|
accounts = import <niveum/lib/email.nix> {inherit lib;};
|
2020-06-10 17:37:25 +02:00
|
|
|
in {
|
2019-11-05 21:59:51 +01:00
|
|
|
theme = {
|
|
|
|
|
name = "plain";
|
|
|
|
|
overrides = {
|
|
|
|
|
critical_fg = colours.red.bright;
|
|
|
|
|
good_fg = colours.green.bright;
|
|
|
|
|
idle_fg = colours.foreground;
|
2022-08-19 11:26:27 +02:00
|
|
|
info_fg = colours.cyan.bright;
|
2019-11-05 21:59:51 +01:00
|
|
|
warning_fg = colours.yellow.bright;
|
2020-05-31 18:25:39 +02:00
|
|
|
warning_bg = colours.background;
|
2019-11-05 21:59:51 +01:00
|
|
|
alternating_tint_bg = colours.background;
|
2022-12-13 14:12:40 +01:00
|
|
|
alternating_tint_fg = colours.foreground;
|
2019-11-05 21:59:51 +01:00
|
|
|
critical_bg = colours.background;
|
|
|
|
|
good_bg = colours.background;
|
|
|
|
|
idle_bg = colours.background;
|
|
|
|
|
info_bg = colours.background;
|
2022-08-18 18:47:12 +02:00
|
|
|
separator = "";
|
2020-05-31 18:25:39 +02:00
|
|
|
separator_bg = "auto";
|
2020-09-03 19:16:49 +02:00
|
|
|
separator_fg = colours.black.bright;
|
2019-11-05 21:59:51 +01:00
|
|
|
};
|
|
|
|
|
};
|
2022-08-21 01:01:08 +02:00
|
|
|
icons.name = "awesome6";
|
2022-08-21 02:13:54 +02:00
|
|
|
icons.overrides.rss = "";
|
2022-08-22 10:28:06 +02:00
|
|
|
icons.overrides.vpn = "";
|
2022-08-23 21:44:34 +02:00
|
|
|
icons.overrides.irc = "";
|
2019-11-05 21:59:51 +01:00
|
|
|
block = [
|
2021-04-04 11:12:17 +02:00
|
|
|
{
|
|
|
|
|
block = "weather";
|
2021-04-05 10:08:01 +02:00
|
|
|
autolocate = true;
|
2021-06-01 19:14:00 +02:00
|
|
|
format = "{location}: {temp}C";
|
2021-04-04 11:12:17 +02:00
|
|
|
service = {
|
|
|
|
|
name = "openweathermap";
|
|
|
|
|
api_key = lib.strings.fileContents <secrets/openweathermap.key>;
|
|
|
|
|
city_id = "2950159";
|
|
|
|
|
units = "metric";
|
|
|
|
|
};
|
|
|
|
|
}
|
2021-10-19 17:59:14 +02:00
|
|
|
{
|
|
|
|
|
block = "custom";
|
2021-11-24 18:19:46 +01:00
|
|
|
interval = 60 * 5;
|
2022-03-10 21:52:12 +01:00
|
|
|
command = let
|
|
|
|
|
spacetime = import <niveum/configs/spacetime.nix>;
|
|
|
|
|
in
|
|
|
|
|
pkgs.writers.writePython3 "sun.py" {
|
|
|
|
|
libraries = [pkgs.python3Packages.astral];
|
|
|
|
|
flakeIgnore = ["E121" "E501"];
|
2021-11-13 23:39:01 +01:00
|
|
|
}
|
2022-03-10 21:52:12 +01:00
|
|
|
''
|
|
|
|
|
import astral
|
|
|
|
|
import astral.moon
|
|
|
|
|
import astral.sun
|
2021-11-13 23:39:01 +01:00
|
|
|
|
2022-03-10 21:52:12 +01:00
|
|
|
current_phase = astral.moon.phase()
|
2021-10-24 18:22:55 +02:00
|
|
|
|
2022-03-10 21:52:12 +01:00
|
|
|
city = astral.LocationInfo("Berlin", "Germany", "${spacetime.time.timeZone}", ${toString spacetime.location.latitude}, ${toString spacetime.location.longitude})
|
|
|
|
|
sun = astral.sun.sun(city.observer, date=astral.today(), tzinfo=city.timezone)
|
|
|
|
|
|
2022-08-21 01:01:08 +02:00
|
|
|
print("↑{} ↓{} {}{}".format(sun["sunrise"].strftime("%R"), sun["sunset"].strftime("%R"), "☽" if current_phase < 14 else "☾", round(current_phase, 1)))
|
2022-03-10 21:52:12 +01:00
|
|
|
'';
|
2021-10-19 17:59:14 +02:00
|
|
|
}
|
2022-08-22 10:28:48 +02:00
|
|
|
{
|
|
|
|
|
block = "github";
|
|
|
|
|
info = ["total"];
|
2022-11-29 11:59:42 +01:00
|
|
|
warning = ["mention" "review_requested" "team_mention" "manual" "invitation" "assign" "subscribed"];
|
2022-08-22 10:28:48 +02:00
|
|
|
}
|
2022-08-19 11:48:58 +02:00
|
|
|
{
|
|
|
|
|
block = "custom";
|
|
|
|
|
interval = 10;
|
|
|
|
|
command = "newsboat-unread-count";
|
|
|
|
|
json = true;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
block = "custom";
|
|
|
|
|
interval = 10;
|
|
|
|
|
command = pkgs.writers.writeDash "todo" ''
|
|
|
|
|
${pkgs.todoman}/bin/todo --porcelain | ${pkgs.jq}/bin/jq -r '
|
|
|
|
|
map(select(.due != null))
|
|
|
|
|
| (map(select(.due < now)) | length) as $overdue
|
|
|
|
|
| (map(select(.due >= now and .due < now + (60 * 60 * 24))) | length) as $dueToday
|
|
|
|
|
| {
|
|
|
|
|
icon: "tasks",
|
2022-08-22 10:29:04 +02:00
|
|
|
text: (($overdue + $dueToday) as $sum | if $sum > 0 then $sum | tostring else "" end),
|
2022-08-19 11:48:58 +02:00
|
|
|
state: (
|
|
|
|
|
if $overdue > 0 then
|
|
|
|
|
"Critical"
|
2022-08-19 14:22:17 +02:00
|
|
|
elif $dueToday > 0 then
|
|
|
|
|
"Warning"
|
2022-08-19 11:48:58 +02:00
|
|
|
else
|
2022-08-19 14:22:17 +02:00
|
|
|
"Idle"
|
2022-08-19 11:48:58 +02:00
|
|
|
end
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
'
|
|
|
|
|
'';
|
|
|
|
|
json = true;
|
2022-08-22 10:30:02 +02:00
|
|
|
hide_when_empty = true;
|
2022-08-19 11:48:58 +02:00
|
|
|
}
|
2022-08-21 02:13:54 +02:00
|
|
|
{
|
|
|
|
|
block = "custom";
|
|
|
|
|
interval = 60 * 5;
|
|
|
|
|
command = let
|
2022-08-30 19:33:07 +02:00
|
|
|
query-account = name: account: "${pkgs.writers.writeDash "query-imap-${name}" ''
|
|
|
|
|
${pkgs.coreutils}/bin/timeout 1 ${pkgs.curl}/bin/curl -sSL -u ${lib.escapeShellArg "${account.user}:${account.password}"} imaps://${account.imap} -X 'STATUS INBOX (UNSEEN)' \
|
|
|
|
|
| ${pkgs.gnugrep}/bin/grep -Eo '[0-9]+' \
|
|
|
|
|
| sed 's/^/{"${name}":/;s/$/}/'
|
|
|
|
|
''} &";
|
2022-08-21 02:13:54 +02:00
|
|
|
in
|
|
|
|
|
pkgs.writers.writeDash "unread-mail" ''
|
|
|
|
|
{
|
2022-08-22 10:30:02 +02:00
|
|
|
${lib.concatStringsSep "\n" (lib.mapAttrsToList query-account accounts)}
|
2022-08-30 19:33:07 +02:00
|
|
|
wait
|
|
|
|
|
} | jq -s 'if length == 0 then {text: "", icon: "mail", state: "Idle"} else
|
2022-08-22 10:30:02 +02:00
|
|
|
add
|
|
|
|
|
| (values | add) as $sum
|
2022-08-21 02:39:07 +02:00
|
|
|
| {
|
2022-08-22 10:30:02 +02:00
|
|
|
text: (if $sum > 0 then $sum | tostring else "" end),
|
2022-08-21 02:39:07 +02:00
|
|
|
icon: "mail",
|
|
|
|
|
state: (
|
2022-08-22 10:30:02 +02:00
|
|
|
if .uni > 0 or .["work-uni"] > 0 or .posteo > 0 then
|
2022-08-21 02:13:54 +02:00
|
|
|
"Warning"
|
|
|
|
|
elif $sum > 0 then
|
|
|
|
|
"Info"
|
|
|
|
|
else
|
|
|
|
|
"Idle"
|
|
|
|
|
end
|
2022-08-21 02:39:07 +02:00
|
|
|
)
|
2022-08-30 19:33:07 +02:00
|
|
|
} end'
|
2022-08-21 02:13:54 +02:00
|
|
|
'';
|
|
|
|
|
json = true;
|
2022-08-22 10:28:06 +02:00
|
|
|
hide_when_empty = true;
|
2022-08-23 21:44:34 +02:00
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
block = "custom";
|
|
|
|
|
interval = 60;
|
|
|
|
|
command = pkgs.writers.writeDash "weechat" ''
|
2022-08-30 19:33:07 +02:00
|
|
|
ssh -o ConnectTimeout=1 makanek cat /var/lib/weechat/hotlist.txt | sed 's/,/\n/g' | wc -l | jq '{
|
2022-08-23 21:44:34 +02:00
|
|
|
text: (if . > 0 then . | tostring else "" end),
|
|
|
|
|
state: (if . > 0 then "Info" else "Idle" end),
|
|
|
|
|
icon: "irc"
|
|
|
|
|
}'
|
|
|
|
|
'';
|
|
|
|
|
json = true;
|
|
|
|
|
hide_when_empty = true;
|
2022-08-21 02:13:54 +02:00
|
|
|
}
|
2022-01-27 16:25:10 +01:00
|
|
|
{
|
2021-05-18 20:38:26 +02:00
|
|
|
block = "custom";
|
|
|
|
|
interval = 5;
|
2022-01-27 16:25:10 +01:00
|
|
|
command = pkgs.writers.writeDash "hu-berlin-vpn" ''
|
2022-03-10 21:52:12 +01:00
|
|
|
PATH=${lib.makeBinPath [pkgs.systemd]}
|
2022-08-22 10:28:06 +02:00
|
|
|
(systemctl is-active --quiet openvpn-hu-berlin.service && echo '{"state": "Good", "text": "OpenVPN", "icon": "vpn"}') \
|
|
|
|
|
|| (systemctl is-active --quiet hu-vpn.service && echo '{"state": "Good", "text": "PPP+SSL", "icon": "vpn"}') \
|
|
|
|
|
|| echo '{"state": "Idle", "icon": "vpn", "text": ""}'
|
2021-05-18 20:38:26 +02:00
|
|
|
'';
|
2022-08-22 10:28:06 +02:00
|
|
|
json = true;
|
|
|
|
|
hide_when_empty = true;
|
2022-01-27 16:25:10 +01:00
|
|
|
}
|
2019-11-05 21:59:51 +01:00
|
|
|
{
|
|
|
|
|
block = "net";
|
2020-10-30 11:05:26 +01:00
|
|
|
device = wirelessInterface;
|
2021-06-01 19:14:00 +02:00
|
|
|
format = "{ssid} {signal_strength}";
|
2019-11-05 21:59:51 +01:00
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
block = "battery";
|
2020-10-30 11:05:26 +01:00
|
|
|
device = batteryName;
|
2019-11-05 21:59:51 +01:00
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
block = "sound";
|
2020-01-24 10:09:04 +01:00
|
|
|
on_click = "pavucontrol";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
block = "disk_space";
|
2021-06-01 19:14:00 +02:00
|
|
|
format = "{icon} {available}";
|
2019-11-05 21:59:51 +01:00
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
block = "memory";
|
|
|
|
|
display_type = "memory";
|
2021-06-01 19:14:00 +02:00
|
|
|
format_mem = "{mem_used;G}";
|
2019-11-05 21:59:51 +01:00
|
|
|
clickable = false;
|
|
|
|
|
}
|
2022-03-10 21:52:12 +01:00
|
|
|
{block = "load";}
|
2019-11-05 21:59:51 +01:00
|
|
|
{
|
2022-08-19 11:27:43 +02:00
|
|
|
block = "custom";
|
2022-08-22 10:30:29 +02:00
|
|
|
interval = 1;
|
2022-08-19 11:27:43 +02:00
|
|
|
json = true;
|
|
|
|
|
command = pkgs.writers.writeDash "time" ''
|
|
|
|
|
${pkgs.jq}/bin/jq -n \
|
|
|
|
|
--arg now "$(${pkgs.coreutils}/bin/date +'%Y-%m-%d (%W %a) %H:%M')" \
|
|
|
|
|
--argjson nextEvent "$(
|
|
|
|
|
${pkgs.khal}/bin/khal list --format "{start}" --day-format "" $(${pkgs.coreutils}/bin/date +'%Y-%m-%d %H:%M') 2>/dev/null \
|
|
|
|
|
| ${pkgs.gnugrep}/bin/grep -E '[0-9]{2}:[0-9]{2}' \
|
|
|
|
|
| ${pkgs.coreutils}/bin/head -1 \
|
|
|
|
|
| ${pkgs.coreutils}/bin/date --date="$(cat)" +%s
|
|
|
|
|
)" \
|
2022-08-19 11:29:42 +02:00
|
|
|
'{
|
2022-08-19 11:27:43 +02:00
|
|
|
text: $now,
|
|
|
|
|
icon: "time",
|
|
|
|
|
state: (
|
2022-08-19 11:29:42 +02:00
|
|
|
($nextEvent - now) as $deltaT
|
|
|
|
|
| if $deltaT < (5 * 60) then
|
2022-08-19 11:27:43 +02:00
|
|
|
"Critical"
|
|
|
|
|
elif $deltaT < (15 * 60) then
|
|
|
|
|
"Warning"
|
|
|
|
|
elif $deltaT < (60 * 60) then
|
|
|
|
|
"Info"
|
|
|
|
|
else
|
|
|
|
|
"Idle"
|
|
|
|
|
end
|
|
|
|
|
)
|
|
|
|
|
}'
|
|
|
|
|
'';
|
2019-11-05 21:59:51 +01:00
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
}
|