1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/lib/i3status-rust.nix

171 lines
4.9 KiB
Nix
Raw Normal View History

{ pkgs, wirelessInterface, colours, batteryName }:
let
inherit (pkgs) lib;
2020-06-10 17:37:25 +02:00
setsid = script:
pkgs.writers.writeDash "setsid-command" ''
${pkgs.utillinux}/bin/setsid ${script}
'';
coronaBlock = {
block = "custom";
interval = 60 * 2; # every two minutes
command = pkgs.writers.writeDash "corona" ''
${pkgs.curl}/bin/curl https://corona-stats.online/germany \
| ${pkgs.gnugrep}/bin/grep Germany \
| ${pkgs.gnused}/bin/sed 's/\s*//g' \
| ${pkgs.ansifilter}/bin/ansifilter \
| ${pkgs.gawk}/bin/awk -F'' '{print "🤒 " $8 " 💀 " $5}'
'';
};
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;
info_fg = colours.foreground;
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;
alternating_tint_fg = colours.background;
critical_bg = colours.background;
good_bg = colours.background;
idle_bg = colours.background;
info_bg = colours.background;
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
};
};
icons = {
name = "none";
overrides = {
bat = "🔋";
bat_charging = "🔌";
bat_discharging = "🔋";
2020-08-26 11:33:16 +02:00
bat_empty = " ";
bat_full = " ";
bat_half = " ";
bat_quarter = " ";
bat_three_quarters = " ";
cogs = "🚦 ";
cpu = "🖥 ";
2021-06-01 19:14:00 +02:00
disk_drive = "💽";
2020-08-26 11:33:16 +02:00
mail = "📧 ";
memory_mem = "🧠 ";
music = "🎵";
music_next = "";
music_pause = "";
music_play = "";
music_prev = "";
net_down = "";
2020-08-26 11:33:16 +02:00
net_up = "🌐";
net_vpn = "🛡 ";
2020-08-26 11:33:16 +02:00
net_wired = "🌐";
net_wireless = "📶";
pomodoro = "🍅 ";
time = "📅 ";
toggle_off = "👎";
toggle_on = "👍";
2020-08-26 11:33:16 +02:00
volume_empty = "🔈 ";
volume_full = "🔊 ";
volume_half = "🔉 ";
2020-08-26 11:33:16 +02:00
volume_muted = "🔇";
weather_clouds = "🌥";
2021-06-01 19:14:00 +02:00
weather_default = "🌡";
weather_rain = "🌧";
weather_snow = "🌨";
2021-06-01 19:14:00 +02:00
weather_sun = "🌣";
weather_thunder = "🌩";
};
};
2019-11-05 21:59:51 +01:00
block = [
{
block = "weather";
autolocate = true;
2021-06-01 19:14:00 +02:00
format = "{location}: {temp}C";
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;
2021-11-13 23:39:01 +01:00
command = let spacetime = import <niveum/configs/spacetime.nix>; in pkgs.writers.writePython3 "sun.py" { libraries = [ pkgs.python3Packages.astral ]; flakeIgnore = [ "E121" "E501" ]; }
''
import astral
2021-11-13 23:39:01 +01:00
import astral.moon
import astral.sun
2021-11-13 23:39:01 +01:00
moon_phases = {
0: "🌑",
3.5: "🌒",
7: "🌓",
10.5: "🌔",
14: "🌕",
17.5: "🌖",
21: "🌗",
24.5: "🌘",
28: "🌑",
}
current_phase = astral.moon.phase()
closest_phase = min(moon_phases.keys(), key=lambda x: abs(current_phase - x))
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)
print("🌅 {} 🌇 {} {} {}".format(sun["sunrise"].strftime("%R"), sun["sunset"].strftime("%R"), moon_phases[closest_phase], round(current_phase, 1)))
2021-10-19 17:59:14 +02:00
'';
}
(let service = "openvpn-hu-berlin"; in {
block = "custom";
interval = 5;
command = pkgs.writers.writeDash "net-device" ''
PATH=${lib.makeBinPath [ pkgs.systemd ]}
systemctl is-active --quiet ${service}.service && echo "🎓👍" || echo "🎓👎"
'';
on_click = pkgs.writers.writeDash "toggle" ''
PATH=${lib.makeBinPath [ pkgs.systemd pkgs.libnotify ]}
systemctl is-active --quiet ${service}.service && {
systemctl stop ${service}.service && notify-send -a "${service}" stopped
} || {
systemctl start ${service}.service && notify-send -a "${service}" started
}
'';
})
2019-11-05 21:59:51 +01:00
{
block = "net";
device = wirelessInterface;
2021-06-01 19:14:00 +02:00
format = "{ssid} {signal_strength}";
2019-11-05 21:59:51 +01:00
}
{
block = "battery";
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;
}
2020-06-10 17:37:25 +02:00
{ block = "load"; }
2019-11-05 21:59:51 +01:00
{
block = "time";
interval = 1;
format = "%Y-%m-%d (%W %a) %H:%M";
2019-11-05 21:59:51 +01:00
}
];
}