2020-06-18 01:31:42 +02:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.profiles.xsession;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
xsession.windowManager.i3.config = {
|
|
|
|
bars = [];
|
|
|
|
startup = [
|
|
|
|
{ command = "systemctl --user restart polybar"; always = true; notification = false; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
services.polybar = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.polybar.override {
|
|
|
|
i3Support = true;
|
|
|
|
};
|
|
|
|
script = "polybar bot &";
|
|
|
|
config = {
|
|
|
|
"colors" = {
|
|
|
|
background = "#B2000000";
|
|
|
|
background-alt = "#444";
|
|
|
|
foreground = "#dfdfdf";
|
|
|
|
foreground-alt = "#BBB";
|
|
|
|
primary = "#ffb52a";
|
|
|
|
secondary = "#e60053";
|
|
|
|
alert = "#bd2c40";
|
|
|
|
};
|
|
|
|
"bar/bot" = {
|
|
|
|
bottom = true;
|
|
|
|
width = "100%";
|
|
|
|
height = 27;
|
|
|
|
|
|
|
|
font-0 = "MesloLGS NF:fontformat=truetype:pixelsize=11;1";
|
2021-04-02 21:51:46 +02:00
|
|
|
font-1 = "Kozuka Mincho Pro:pixelsize=11;1";
|
2020-06-18 01:31:42 +02:00
|
|
|
|
|
|
|
background = "\${colors.background}";
|
|
|
|
foreground = "\${colors.foreground}";
|
|
|
|
|
|
|
|
padding-left = "0";
|
|
|
|
padding-right = "2";
|
|
|
|
|
|
|
|
module-margin-left = "1";
|
|
|
|
module-margin-right = "2";
|
|
|
|
|
|
|
|
modules-left = "i3 title";
|
2022-05-23 04:14:19 +02:00
|
|
|
modules-right = "countdown minecraft wlan eth filesystem uquota cpu memory battery date";
|
2020-06-18 01:31:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
"module/i3" = {
|
|
|
|
type = "internal/i3";
|
|
|
|
format = "<label-state> <label-mode>";
|
|
|
|
scroll-up = "i3wm-wsnext";
|
|
|
|
scroll-down = "i3wm-wsprev";
|
|
|
|
|
|
|
|
label-mode-padding = "0";
|
|
|
|
label-mode-foreground = "#000";
|
|
|
|
label-mode-background = "\${colors.primary}";
|
|
|
|
|
|
|
|
label-focused = "%index%";
|
|
|
|
label-focused-background = "\${colors.background-alt}";
|
|
|
|
label-focused-underline= "\${colors.primary}";
|
|
|
|
label-focused-padding = "1";
|
|
|
|
|
|
|
|
label-unfocused = "%index%";
|
|
|
|
label-unfocused-padding = "1";
|
|
|
|
|
|
|
|
label-visible = "%index%";
|
|
|
|
label-visible-background = "\${self.label-focused-background}";
|
|
|
|
label-visible-underline = "\${self.label-focused-underline}";
|
|
|
|
label-visible-padding = "\${self.label-focused-padding}";
|
|
|
|
|
|
|
|
label-urgent = "%index%";
|
|
|
|
label-urgent-background = "\${colors.alert}";
|
|
|
|
label-urgent-padding = "1";
|
|
|
|
|
|
|
|
};
|
|
|
|
"module/title" = {
|
|
|
|
type = "internal/xwindow";
|
|
|
|
};
|
2022-04-03 17:28:22 +02:00
|
|
|
"module/wlan" = lib.mkIf (config.machine.wlan != null) {
|
2020-06-18 01:31:42 +02:00
|
|
|
type = "internal/network";
|
2021-08-20 19:20:18 +02:00
|
|
|
interface = config.machine.wlan;
|
2020-06-18 01:31:42 +02:00
|
|
|
interval = "3.0";
|
|
|
|
|
|
|
|
format-connected = "<ramp-signal> <label-connected>";
|
|
|
|
format-connected-underline = "#9f78e1";
|
|
|
|
label-connected = "(%signal%% on %essid%) %local_ip%";
|
|
|
|
|
|
|
|
format-disconnected = "";
|
|
|
|
|
|
|
|
ramp-signal-0 = "";
|
|
|
|
ramp-signal-1 = "";
|
|
|
|
ramp-signal-2 = "";
|
|
|
|
ramp-signal-3 = "";
|
|
|
|
ramp-signal-4 = "";
|
|
|
|
ramp-signal-foreground = "\${colors.foreground-alt}";
|
2020-07-11 04:08:58 +02:00
|
|
|
};
|
2022-04-24 00:23:48 +02:00
|
|
|
"module/eth" = lib.mkIf (config.machine.eth != null)
|
|
|
|
{
|
|
|
|
type = "internal/network";
|
|
|
|
interface = "${config.machine.eth}";
|
|
|
|
interval = "3.0";
|
|
|
|
|
|
|
|
format-connected-underline = "#55aa55";
|
|
|
|
format-connected-prefix = " ";
|
|
|
|
format-connected-prefix-foreground = "\${colors.foreground-alt}";
|
|
|
|
label-connected = "%local_ip%";
|
|
|
|
|
|
|
|
format-disconnected = "";
|
|
|
|
};
|
2020-06-18 01:31:42 +02:00
|
|
|
"module/filesystem" = {
|
|
|
|
type = "internal/fs";
|
|
|
|
interval = 25;
|
|
|
|
|
|
|
|
mount-0 = "/";
|
2022-05-02 23:45:57 +02:00
|
|
|
mount-1 = lib.mkIf (config.machine.secondary-fs != null) config.machine.secondary-fs;
|
2020-06-18 01:31:42 +02:00
|
|
|
|
|
|
|
label-mounted = "%{F#0a81f5}%mountpoint%%{F-}: %free%";
|
|
|
|
label-unmounted = "%mountpoint% not mounted";
|
|
|
|
label-unmounted-foreground = "\${colors.foreground-alt}";
|
|
|
|
};
|
|
|
|
"module/cpu" = {
|
|
|
|
type = "internal/cpu";
|
|
|
|
interval = 2;
|
|
|
|
format-prefix = " ";
|
|
|
|
format-prefix-foreground = "\${colors.foreground-alt}";
|
|
|
|
format-underline = "#f90000";
|
|
|
|
label = "%percentage:2%%";
|
|
|
|
};
|
|
|
|
"module/memory" = {
|
|
|
|
type = "internal/memory";
|
|
|
|
interval = "2";
|
|
|
|
format-prefix = " ";
|
|
|
|
format-prefix-foreground = "\${colors.foreground-alt}";
|
|
|
|
format-underline = "#4bffdc";
|
|
|
|
label = "%percentage_used%%";
|
|
|
|
};
|
|
|
|
"module/battery" = {
|
|
|
|
type = "internal/battery";
|
|
|
|
battery = "BAT0";
|
|
|
|
adapter = "AC";
|
|
|
|
|
|
|
|
format-charging = "<animation-charging> <label-charging>";
|
|
|
|
format-charging-underline = "#ffb52a";
|
|
|
|
|
|
|
|
format-discharging = "<animation-discharging> <label-discharging>";
|
|
|
|
format-discharging-underline = "\${self.format-charging-underline}";
|
|
|
|
|
|
|
|
format-full-prefix-foreground = "\${colors.foreground-alt}";
|
|
|
|
format-full-underline = "\${self.format-charging-underline}";
|
|
|
|
|
|
|
|
ramp-capacity-foreground = "\${colors.foreground-alt}";
|
|
|
|
|
|
|
|
format-full-prefix = " ";
|
|
|
|
|
|
|
|
ramp-capacity-0 = "";
|
|
|
|
ramp-capacity-1 = "";
|
|
|
|
ramp-capacity-2 = "";
|
|
|
|
|
|
|
|
animation-charging-0 = "";
|
|
|
|
animation-charging-1 = "";
|
|
|
|
animation-charging-2 = "";
|
|
|
|
animation-charging-foreground = "\${colors.foreground-alt}";
|
|
|
|
animation-charging-framerate = "750";
|
|
|
|
|
|
|
|
animation-discharging-0 = "";
|
|
|
|
animation-discharging-1 = "";
|
|
|
|
animation-discharging-2 = "";
|
|
|
|
animation-discharging-foreground = "\${colors.foreground-alt}";
|
|
|
|
animation-discharging-framerate = "750";
|
|
|
|
};
|
|
|
|
"module/date" = {
|
|
|
|
type = "internal/date";
|
|
|
|
internal = 5;
|
|
|
|
date = "%Y-%m-%d";
|
|
|
|
time = "%H:%M:%S";
|
|
|
|
label = "%date% %time%";
|
|
|
|
};
|
2022-05-03 01:54:31 +02:00
|
|
|
|
2022-05-23 04:14:19 +02:00
|
|
|
"module/countdown" = {
|
|
|
|
type = "custom/script";
|
|
|
|
exec-if = "test -f $HOME/countdown";
|
|
|
|
exec = "" + pkgs.writers.writeBash "countdown" ''
|
|
|
|
secs=$(( $(${pkgs.coreutils}/bin/date +%s -d $(${pkgs.coreutils}/bin/cat $HOME/countdown)) - $( ${pkgs.coreutils}/bin/date +%s ) ))
|
|
|
|
printf '%d:%02d:%02d:%02d\n' $((secs/86400)) $((secs%86400/3600)) $((secs%3600/60)) $((secs%60))
|
|
|
|
'';
|
|
|
|
interval = 1;
|
|
|
|
};
|
|
|
|
|
2022-05-03 01:54:31 +02:00
|
|
|
"module/minecraft" = {
|
|
|
|
type = "custom/script";
|
|
|
|
exec = "" + pkgs.writers.writePython3 "minecraft_status" { libraries = [ pkgs.python3.pkgs.mcstatus ]; flakeIgnore = [ "E722" ]; } ''
|
2022-06-02 02:16:36 +02:00
|
|
|
from mcstatus import JavaServer
|
2022-05-03 01:54:31 +02:00
|
|
|
pvv = JavaServer.lookup("minecraft.pvv.ntnu.no")
|
|
|
|
dods = JavaServer.lookup("mc.dodsorf.as")
|
|
|
|
|
|
|
|
try:
|
|
|
|
pvv_status = pvv.status()
|
2022-05-23 03:30:26 +02:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2022-05-03 01:54:31 +02:00
|
|
|
dods_status = dods.status()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
result = ""
|
|
|
|
try:
|
|
|
|
if pvv_status.players.online > 0:
|
|
|
|
result += ("P" + str(pvv_status.players.online))
|
|
|
|
except:
|
|
|
|
pass
|
2022-05-23 03:30:26 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
if dods_status.players.online > 0:
|
|
|
|
result += ("D" + str(dods_status.players.online))
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2022-05-03 01:54:31 +02:00
|
|
|
print(result)
|
|
|
|
'';
|
2022-05-03 17:59:55 +02:00
|
|
|
click-left = "" + pkgs.writers.writePython3 "minecraft_status" { libraries = with pkgs.python3.pkgs; [ mcstatus notify2 ]; flakeIgnore = [ "E722" ]; } ''
|
2022-06-02 02:16:36 +02:00
|
|
|
from mcstatus import JavaServer
|
2022-05-03 17:59:55 +02:00
|
|
|
import notify2
|
2022-05-03 01:54:31 +02:00
|
|
|
|
|
|
|
pvv = JavaServer.lookup("minecraft.pvv.ntnu.no")
|
|
|
|
dods = JavaServer.lookup("mc.dodsorf.as")
|
|
|
|
|
2022-05-03 17:59:55 +02:00
|
|
|
pvv_status = None
|
|
|
|
dods_status = None
|
|
|
|
|
2022-05-03 01:54:31 +02:00
|
|
|
try:
|
|
|
|
pvv_status = pvv.status()
|
2022-05-23 03:30:26 +02:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2022-05-03 01:54:31 +02:00
|
|
|
dods_status = dods.status()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
result = ""
|
2022-05-03 17:59:55 +02:00
|
|
|
if pvv_status is not None:
|
|
|
|
result += "PVV: "
|
2022-05-03 01:54:31 +02:00
|
|
|
for player in pvv_status.players.sample:
|
2022-05-05 03:44:07 +02:00
|
|
|
result += player.name + " "
|
2022-05-03 17:59:55 +02:00
|
|
|
result += "\n"
|
|
|
|
if dods_status is not None:
|
|
|
|
result += "DODS: "
|
|
|
|
for player in dods_status.players.sample:
|
2022-05-05 03:44:07 +02:00
|
|
|
result += player.name + " "
|
2022-05-03 17:59:55 +02:00
|
|
|
result += "\n"
|
|
|
|
|
|
|
|
notify2.init('Minecraft Server Status')
|
|
|
|
n = notify2.Notification("Minecraft Server Status", result)
|
|
|
|
n.show()
|
2022-05-03 01:54:31 +02:00
|
|
|
'';
|
|
|
|
interval = 10;
|
|
|
|
format = " <label>";
|
|
|
|
};
|
2020-06-18 01:31:42 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
2021-04-02 21:51:46 +02:00
|
|
|
|