feat(aspen/system): Weather in i3status bar

Change-Id: Ib2572fea5fc81d6b4d321a2e317a02398d0ae612
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11292
Tested-by: BuildkiteCI
Reviewed-by: aspen <root@gws.fyi>
Autosubmit: aspen <root@gws.fyi>
This commit is contained in:
Aspen Smith 2024-03-31 12:54:34 -04:00 committed by aspen
parent d706ebda65
commit 35a96b47d5
3 changed files with 123 additions and 108 deletions

View file

@ -0,0 +1,12 @@
{ pkgs, ... }:
pkgs.python3Packages.py3status.overridePythonAttrs (old: rec {
name = "${pname}-${old.version}";
pname = "py3status-glittershark";
src = pkgs.fetchFromGitHub {
owner = "glittershark";
repo = "py3status";
rev = "f243be1458cdabd5a7524adb76b5db99006c810c";
sha256 = "0ffmv91562yk0wigriw4d5nfg2b32wqx8x78qvdqkawzvgbwrwvl";
};
})

View file

@ -1,5 +1,7 @@
{ config, lib, pkgs, ... }:
let
inherit (config.lib) depot;
mod = "Mod4";
solarized = import ../common/solarized.nix;
# TODO pull this out into lib
@ -7,16 +9,112 @@ let
msg=$(emacsclient --eval '${eval}' 2>&1)
echo "''${msg:1:-1}"
'';
screenlayout = {
home = pkgs.writeShellScript "screenlayout_home.sh" ''
xrandr \
--output eDP-1 --mode 1920x1200 --pos 0x960 --rotate normal \
--output DP-3 --primary --mode 3840x2160 --pos 1920x0 --rotate normal \
--output DP-1 --off \
--output DP-2 --off \
--output DP-4 --off
'';
};
i3status-conf = pkgs.writeText "i3status.conf" ''
general {
output_format = i3bar
colors = true
color_good = "#859900"
interval = 1
}
order += "external_script current_task"
order += "external_script inbox"
order += "spotify"
order += "weather_owm"
order += "volume_status"
order += "wireless ${config.system.machine.wirelessInterface}"
# order += "ethernet enp3s0f0"
order += "cpu_usage"
${lib.optionalString (!isNull config.system.machine.battery) ''
order += "battery ${toString config.system.machine.battery}"
''}
# order += "volume master"
order += "time"
order += "tztime utc"
mpd {
format = "%artist - %album - %title"
}
wireless ${config.system.machine.wirelessInterface} {
format_up = "W: (%quality - %essid - %bitrate) %ip"
format_down = "W: -"
}
ethernet enp3s0f0 {
format_up = "E: %ip"
format_down = "E: -"
}
battery ${toString config.system.machine.battery} {
format = "%status %percentage (%remaining)"
path = "/sys/class/power_supply/BAT%d/uevent"
low_threshold = 10
}
cpu_usage {
format = "CPU: %usage"
}
load {
format = "%5min"
}
time {
format = " %a %h %d %I:%M "
}
spotify {
color_playing = "#fdf6e3"
color_paused = "#93a1a1"
format_stopped = ""
format_down = ""
format = "{title} - {artist} ({album})"
}
external_script inbox {
script_path = '${emacsclient "(aspen/num-inbox-items-message)"}'
format = 'Inbox: {output}'
cache_timeout = 120
color = "#93a1a1"
}
external_script current_task {
script_path = '${
emacsclient "(aspen/org-current-clocked-in-task-message)"
}'
# format = '{output}'
cache_timeout = 60
color = "#93a1a1"
}
tztime utc {
timezone = "UTC"
format = " %H·%M "
}
volume_status {
format = " {percentage}"
format_muted = " X"
# device = "default"
# mixer_idx = 0
}
weather_owm {
api_key = '@owmApiKey@'
unit_temperature = 'c'
format = '{icon} {temperature}[ {rain}]'
}
'';
i3status-command = pkgs.writeShellScript "i3status.sh" ''
sed -s "s/@owmApiKey@/$(pass owm-api-key)/" \
< ${i3status-conf} \
> /tmp/i3status.conf
py3status -c /tmp/i3status.conf
'';
inherit (builtins) map;
inherit (lib) mkMerge range;
@ -60,7 +158,7 @@ in
home.packages = with pkgs; [
rofi
rofi-pass
python3Packages.py3status
depot.users.aspen.pkgs.py3status
i3lock
i3status
dconf # for gtk
@ -179,10 +277,6 @@ in
# Screen Layout
"${mod}+Shift+t" = "exec xrandr --auto";
"${mod}+t" = "exec ${screenlayout.home}";
"${mod}+Ctrl+t" = "exec ${pkgs.writeShellScript "fix_term.sh" ''
xrandr --output eDP-1 --off && ${screenlayout.home}
''}";
# Notifications
"${mod}+Shift+n" = "exec killall -SIGUSR1 .dunst-wrapped";
@ -224,99 +318,7 @@ in
};
bars = [{
statusCommand =
let
i3status-conf = pkgs.writeText "i3status.conf" ''
general {
output_format = i3bar
colors = true
color_good = "#859900"
interval = 1
}
order += "external_script current_task"
order += "external_script inbox"
order += "spotify"
order += "volume_status"
order += "wireless ${config.system.machine.wirelessInterface}"
# order += "ethernet enp3s0f0"
order += "cpu_usage"
${lib.optionalString (!isNull config.system.machine.battery) ''
order += "battery ${toString config.system.machine.battery}"
''}
# order += "volume master"
order += "time"
order += "tztime utc"
mpd {
format = "%artist - %album - %title"
}
wireless ${config.system.machine.wirelessInterface} {
format_up = "W: (%quality - %essid - %bitrate) %ip"
format_down = "W: -"
}
ethernet enp3s0f0 {
format_up = "E: %ip"
format_down = "E: -"
}
battery ${toString config.system.machine.battery} {
format = "%status %percentage"
path = "/sys/class/power_supply/BAT%d/uevent"
low_threshold = 10
}
cpu_usage {
format = "CPU: %usage"
}
load {
format = "%5min"
}
time {
format = " %a %h %d %I:%M "
}
spotify {
color_playing = "#fdf6e3"
color_paused = "#93a1a1"
format_stopped = ""
format_down = ""
format = "{title} - {artist} ({album})"
}
external_script inbox {
script_path = '${emacsclient "(aspen/num-inbox-items-message)"}'
format = 'Inbox: {output}'
cache_timeout = 120
color = "#93a1a1"
}
external_script current_task {
script_path = '${emacsclient "(aspen/org-current-clocked-in-task-message)"}'
# format = '{output}'
cache_timeout = 60
color = "#93a1a1"
}
tztime utc {
timezone = "UTC"
format = " %H·%M "
}
volume_status {
format = " {percentage}"
format_muted = " X"
# device = "default"
# mixer_idx = 0
}
'';
in
"py3status -c ${i3status-conf}";
statusCommand = "${i3status-command}";
inherit fonts;
position = "top";
colors = with solarized; rec {

View file

@ -5,6 +5,7 @@
nerdfonts
noto-fonts-emoji
twitter-color-emoji
weather-icons
];
fontconfig.defaultFonts.emoji = [ "Twitter Color Emoji" ];