added stuff
This commit is contained in:
parent
6d31f5b5a1
commit
7d4f626b7d
907 changed files with 70990 additions and 0 deletions
27
nyx/homes/notashelf/services/wayland/waybar/default.nix
Normal file
27
nyx/homes/notashelf/services/wayland/waybar/default.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
osConfig,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf;
|
||||
inherit (osConfig.modules) device;
|
||||
inherit (osConfig.modules.style.colorScheme) slug colors;
|
||||
|
||||
waybar_config = import ./presets/${slug}/config.nix {inherit osConfig config lib pkgs;};
|
||||
waybar_style = import ./presets/${slug}/style.nix {inherit colors;};
|
||||
|
||||
acceptedTypes = ["desktop" "laptop" "lite" "hybrid"];
|
||||
in {
|
||||
config = mkIf (builtins.elem device.type acceptedTypes) {
|
||||
home.packages = with pkgs.python3Packages; [requests];
|
||||
programs.waybar = {
|
||||
enable = false;
|
||||
systemd.enable = true;
|
||||
package = pkgs.waybar;
|
||||
settings = waybar_config;
|
||||
style = waybar_style;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,277 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
osConfig,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) optionalString primaryMonitor;
|
||||
|
||||
sys = osConfig.modules.system;
|
||||
in {
|
||||
mainBar = {
|
||||
layer = "top";
|
||||
position = "left";
|
||||
# monitor configuration, kind of dirty since it assumes DP-1 is my main monitor
|
||||
output = primaryMonitor osConfig; #builtins.elemAt monitors 0;
|
||||
width = 55;
|
||||
spacing = 7;
|
||||
margin-left = 6;
|
||||
margin-top = 9;
|
||||
margin-bottom = 9;
|
||||
margin-right = null;
|
||||
fixed-center = true;
|
||||
exclusive = true;
|
||||
modules-left = [
|
||||
"custom/search"
|
||||
"hyprland/workspaces"
|
||||
"custom/lock"
|
||||
"backlight"
|
||||
"battery"
|
||||
"custom/weather"
|
||||
"custom/todo"
|
||||
];
|
||||
modules-center = [];
|
||||
modules-right = [
|
||||
"cpu"
|
||||
(optionalString sys.bluetooth.enable "bluetooth")
|
||||
"gamemode"
|
||||
"pulseaudio"
|
||||
"network"
|
||||
"custom/swallow"
|
||||
"clock"
|
||||
"custom/power"
|
||||
];
|
||||
|
||||
"hyprland/workspaces" = let
|
||||
hyprctl = config.wayland.windowManager.hyprland.package + "/bin/hyprctl";
|
||||
in {
|
||||
on-click = "activate";
|
||||
on-scroll-up = "${hyprctl} dispatch workspace m+1";
|
||||
on-scroll-down = "${hyprctl} dispatch workspace m-1";
|
||||
format = "{icon}";
|
||||
active-only = true;
|
||||
all-outputs = true;
|
||||
format-icons = {
|
||||
"1" = "一";
|
||||
"2" = "二";
|
||||
"3" = "三";
|
||||
"4" = "四";
|
||||
"5" = "五";
|
||||
"6" = "六";
|
||||
"7" = "七";
|
||||
"8" = "八";
|
||||
"9" = "九";
|
||||
"10" = "十";
|
||||
};
|
||||
};
|
||||
|
||||
"custom/search" = {
|
||||
format = " ";
|
||||
tooltip = false;
|
||||
on-click = "${lib.getExe pkgs.killall} rofi || run-as-service $(rofi -show drun)";
|
||||
};
|
||||
|
||||
"custom/todo" = {
|
||||
format = "{}";
|
||||
tooltip = true;
|
||||
interval = 7;
|
||||
exec = let
|
||||
todo = pkgs.todo + "/bin/todo";
|
||||
sed = pkgs.gnused + "/bin/sed";
|
||||
wc = pkgs.coreutils + "/bin/wc";
|
||||
in
|
||||
pkgs.writeShellScript "todo-waybar" ''
|
||||
#!/bin/sh
|
||||
|
||||
total_todo=$(${todo} | ${wc} -l)
|
||||
todo_raw_done=$(${todo} raw done | ${sed} 's/^/ ◉ /' | ${sed} -z 's/\n/\\n/g')
|
||||
todo_raw_undone=$(${todo} raw todo | ${sed} 's/^/ ◉ /' | ${sed} -z 's/\n/\\n/g')
|
||||
done=$(${todo} raw done | ${wc} -l)
|
||||
undone=$(${todo} raw todo | ${wc} -l)
|
||||
tooltip=$(${todo})
|
||||
|
||||
left="$done/$total_todo"
|
||||
|
||||
header="<b>todo</b>\\n\\n"
|
||||
tooltip=""
|
||||
if [[ $total_todo -gt 0 ]]; then
|
||||
if [[ $undone -gt 0 ]]; then
|
||||
export tooltip="$header👷 Today, you need to do:\\n\\n $(echo $todo_raw_undone)\\n\\n✅ You have already done:\\n\\n $(echo $todo_raw_done)"
|
||||
export output=" 🗒️ \\n $left"
|
||||
else
|
||||
export tooltip="$header✅ All done!\\n🥤 Remember to stay hydrated!"
|
||||
export output=" 🎉 \\n $left"
|
||||
fi
|
||||
else
|
||||
export tooltip=""
|
||||
export output=""
|
||||
fi
|
||||
|
||||
printf '{"text": "%s", "tooltip": "%s" }' "$output" "$tooltip"
|
||||
'';
|
||||
return-type = "json";
|
||||
};
|
||||
|
||||
"custom/weather" = let
|
||||
waybar-wttr = pkgs.stdenv.mkDerivation {
|
||||
name = "waybar-wttr";
|
||||
buildInputs = [(pkgs.python3.withPackages (pythonPackages: with pythonPackages; [requests]))];
|
||||
unpackPhase = "true";
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp ${../../scripts/waybar-wttr.py} $out/bin/waybar-wttr
|
||||
chmod +x $out/bin/waybar-wttr
|
||||
'';
|
||||
};
|
||||
in {
|
||||
format = "{}";
|
||||
tooltip = true;
|
||||
interval = 30;
|
||||
exec = "${waybar-wttr}/bin/waybar-wttr";
|
||||
return-type = "json";
|
||||
};
|
||||
|
||||
"custom/lock" = {
|
||||
tooltip = false;
|
||||
on-click = "${pkgs.bash}/bin/bash -c '(sleep 0.5s; ${lib.getExe pkgs.swaylock-effects} --grace 0)' & disown";
|
||||
format = "";
|
||||
};
|
||||
|
||||
"custom/swallow" = {
|
||||
tooltip = false;
|
||||
on-click = let
|
||||
hyprctl = config.wayland.windowManager.hyprland.package + "/bin/hyprctl";
|
||||
notify-send = pkgs.libnotify + "/bin/notify-send";
|
||||
rg = pkgs.ripgrep + "/bin/rg";
|
||||
in
|
||||
pkgs.writeShellScript "waybar-swallow" ''
|
||||
#!/bin/sh
|
||||
if ${hyprctl} getoption misc:enable_swallow | ${rg} -q "int: 1"; then
|
||||
${hyprctl} keyword misc:enable_swallow false >/dev/null &&
|
||||
${notify-send} "Hyprland" "Turned off swallowing"
|
||||
else
|
||||
${hyprctl} keyword misc:enable_swallow true >/dev/null &&
|
||||
${notify-send} "Hyprland" "Turned on swallowing"
|
||||
fi
|
||||
'';
|
||||
format = "";
|
||||
};
|
||||
|
||||
"custom/power" = {
|
||||
tooltip = false;
|
||||
on-click = let
|
||||
sudo = pkgs.sudo + "/bin/sudo";
|
||||
rofi = config.programs.rofi.package + "/bin/rofi";
|
||||
poweroff = pkgs.systemd + "/bin/poweroff";
|
||||
reboot = pkgs.systemd + "/bin/reboot";
|
||||
in
|
||||
pkgs.writeShellScript "shutdown-waybar" ''
|
||||
|
||||
#!/bin/sh
|
||||
|
||||
off=" Shutdown"
|
||||
reboot=" Reboot"
|
||||
cancel=" Cancel"
|
||||
|
||||
sure="$(printf '%s\n%s\n%s' "$off" "$reboot" "$cancel" |
|
||||
${rofi} -dmenu -p ' Are you sure?')"
|
||||
|
||||
if [ "$sure" = "$off" ]; then
|
||||
${sudo} ${poweroff}
|
||||
elif [ "$sure" = "$reboot" ]; then
|
||||
${sudo} ${reboot}
|
||||
fi
|
||||
'';
|
||||
format = "";
|
||||
};
|
||||
clock = {
|
||||
format = ''
|
||||
{:%H
|
||||
%M}'';
|
||||
tooltip-format = ''
|
||||
<big>{:%Y %B}</big>
|
||||
<tt><small>{calendar}</small></tt>
|
||||
'';
|
||||
};
|
||||
|
||||
backlight = let
|
||||
brightnessctl = lib.getExe pkgs.brightnessctl;
|
||||
in {
|
||||
format = "{icon}";
|
||||
format-icons = ["" "" "" "" "" "" ""];
|
||||
#format-icons = ["" "" "" "" "" "" "" "" ""];
|
||||
on-scroll-up = "${brightnessctl} s 1%-";
|
||||
on-scroll-down = "${brightnessctl} s +1%";
|
||||
};
|
||||
|
||||
battery = {
|
||||
states = {
|
||||
warning = 30;
|
||||
critical = 15;
|
||||
};
|
||||
format = "{icon}";
|
||||
format-charging = "";
|
||||
format-plugged = "";
|
||||
format-alt = "{icon}";
|
||||
format-icons = ["" "" "" "" "" "" "" "" "" "" "" ""];
|
||||
};
|
||||
network = let
|
||||
nm-editor = "${pkgs.networkmanagerapplet}/bin/nm-connection-editor";
|
||||
in {
|
||||
format-wifi = "";
|
||||
format-ethernet = "";
|
||||
format-alt = "";
|
||||
format-disconnected = "";
|
||||
tooltip-format = "{ipaddr}/{ifname} via {gwaddr} ({signalStrength}%)";
|
||||
on-click-right = "${nm-editor}";
|
||||
};
|
||||
|
||||
pulseaudio = {
|
||||
scroll-step = 5;
|
||||
tooltip = true;
|
||||
tooltip-format = "{volume}";
|
||||
on-click = "${pkgs.killall}/bin/killall pavucontrol || ${pkgs.pavucontrol}/bin/pavucontrol";
|
||||
format = "{icon}";
|
||||
format-muted = "";
|
||||
format-icons = {
|
||||
default = ["" "" ""];
|
||||
};
|
||||
};
|
||||
|
||||
cpu = {
|
||||
interval = 10;
|
||||
format = "";
|
||||
max-length = 10;
|
||||
states = {
|
||||
"50" = 50;
|
||||
"60" = 75;
|
||||
"70" = 90;
|
||||
};
|
||||
};
|
||||
|
||||
bluetooth = {
|
||||
# controller = "controller1", // specify the alias of the controller if there are more than 1 on the system
|
||||
format = "";
|
||||
format-disabled = ""; # an empty format will hide the module
|
||||
format-connected = "";
|
||||
tooltip-format = "{controller_alias}\t{controller_address}";
|
||||
tooltip-format-connected = "{controller_alias}\t{controller_address}\n\n{device_enumerate}";
|
||||
tooltip-format-disabled = "";
|
||||
tooltip-format-enumerate-connected = "{device_alias}\t{device_address}";
|
||||
};
|
||||
|
||||
gamemode = {
|
||||
format = "";
|
||||
format-alt = "{glyph}";
|
||||
glyph = "";
|
||||
hide-not-running = true;
|
||||
use-icon = true;
|
||||
icon-name = "input-gaming-symbolic";
|
||||
icon-spacing = 4;
|
||||
icon-size = 20;
|
||||
tooltip = true;
|
||||
tooltip-format = "Games running: {count}";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,224 @@
|
|||
{colors}:
|
||||
with colors; let
|
||||
OSLogo = builtins.fetchurl rec {
|
||||
name = "OSLogo-${sha256}.png";
|
||||
sha256 = "14mbpw8jv1w2c5wvfvj8clmjw0fi956bq5xf9s2q3my14far0as8";
|
||||
url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/master/logo/nix-snowflake.svg";
|
||||
};
|
||||
in ''
|
||||
* {
|
||||
font-family: Material Design Icons, Iosevka Nerd Font Mono;
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
window#waybar {
|
||||
background-color: #${base00};
|
||||
border: .5px solid #${base01};
|
||||
border-radius: 20px;
|
||||
box-shadow: 2 3 2 2px #151515;
|
||||
color: #${base05};
|
||||
margin: 16px 16px;
|
||||
transition-property: background-color;
|
||||
transition-duration: .5s;
|
||||
}
|
||||
|
||||
window#waybar.hidden {
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
#custom-weather,
|
||||
#clock,
|
||||
#network,
|
||||
#custom-swallow,
|
||||
#custom-power,
|
||||
#cpu,
|
||||
#battery,
|
||||
#backlight,
|
||||
#memory,
|
||||
#workspaces,
|
||||
#custom-search,
|
||||
#custom-power,
|
||||
#custom-todo,
|
||||
#custom-lock,
|
||||
#custom-weather,
|
||||
#volume,
|
||||
#cpu,
|
||||
#bluetooth,
|
||||
#gamemode,
|
||||
#pulseaudio {
|
||||
border-radius: 15px;
|
||||
margin: 0px 7px 0px 7px;
|
||||
background-color: #${base02};
|
||||
padding: 10px 0px 10px 0px;
|
||||
}
|
||||
|
||||
|
||||
#workspaces button {
|
||||
background-color: transparent;
|
||||
/* Use box-shadow instead of border so the text isn't offset */
|
||||
color: #${base0D};
|
||||
font-size: 21px;
|
||||
/* padding-left: 6px; */
|
||||
box-shadow: inset 0 -3px transparent;
|
||||
}
|
||||
|
||||
#workspaces button:hover {
|
||||
color: #${base0C};
|
||||
box-shadow: inherit;
|
||||
text-shadow: inherit;
|
||||
}
|
||||
|
||||
#workspaces button.active {
|
||||
color: #${base0A};
|
||||
}
|
||||
|
||||
#workspaces button.urgent {
|
||||
color: #${base08};
|
||||
}
|
||||
|
||||
#custom-power {
|
||||
color: #${base08};
|
||||
}
|
||||
|
||||
#workspaces {
|
||||
font-size: 15px;
|
||||
background-color: #${base02};
|
||||
}
|
||||
|
||||
#network {
|
||||
color: #${base0D};
|
||||
padding: 14px 0px 14px 0px;
|
||||
}
|
||||
|
||||
#gamemode {
|
||||
color: #${base0D};
|
||||
}
|
||||
|
||||
#custom-weather {
|
||||
color: #${base05};
|
||||
background-color: #${base02};
|
||||
}
|
||||
|
||||
#cpu {
|
||||
color: rgba(0, 0, 0, 0.0);
|
||||
background-color: rgba(0, 0, 0, 0.0);
|
||||
margin: -50;
|
||||
}
|
||||
|
||||
#cpu.50 {
|
||||
color: #${base06};
|
||||
background-color: #${base02};
|
||||
border-radius: 15px;
|
||||
margin: 0px 7px 0px 7px;
|
||||
padding: 10px 0px 10px 0px;
|
||||
}
|
||||
|
||||
#cpu.60 {
|
||||
color: #${base09};
|
||||
background-color: #${base02};
|
||||
border-radius: 15px;
|
||||
margin: 0px 7px 0px 7px;
|
||||
padding: 10px 0px 10px 0px;
|
||||
}
|
||||
|
||||
#cpu.70 {
|
||||
color: #${base08};
|
||||
background-color: #${base02};
|
||||
border-radius: 15px;
|
||||
margin: 0px 7px 0px 7px;
|
||||
padding: 10px 0px 10px 0px;
|
||||
}
|
||||
|
||||
#bluetooth {
|
||||
color: #${base0E};
|
||||
}
|
||||
|
||||
#bluetooth.off,
|
||||
#bluetooth.pairable,
|
||||
#bluetooth.discovering,
|
||||
#bluetooth.disabled {
|
||||
color: rgba(0, 0, 0, 0.0);
|
||||
background-color: rgba(0, 0, 0, 0.0);
|
||||
margin: -50;
|
||||
}
|
||||
|
||||
#clock {
|
||||
color: #${base05};
|
||||
background-color: #${base02};
|
||||
font-weight: 700;
|
||||
font-size: 20px;
|
||||
padding: 5px 0px 5px 0px;
|
||||
font-family: "Iosevka Term";
|
||||
}
|
||||
|
||||
#pulseaudio {
|
||||
color: #${base0B};
|
||||
padding: 5px 0px 5px 0px;
|
||||
font-size: 30;
|
||||
}
|
||||
|
||||
#pulseaudio.source-muted,
|
||||
#pulseaudio.muted {
|
||||
color: #${base08};
|
||||
padding: 16px 0px 16px 0px;
|
||||
font-size: 15;
|
||||
}
|
||||
|
||||
#custom-swallow {
|
||||
color: #${base0E};
|
||||
padding: 14px 0px 14px 0px;
|
||||
}
|
||||
|
||||
#custom-lock {
|
||||
color: #${base0D};
|
||||
font-size: 27;
|
||||
padding: 6px 0px 6px 0px;
|
||||
}
|
||||
|
||||
#custom-todo {
|
||||
color: #${base05};
|
||||
padding-left: 2px;
|
||||
}
|
||||
|
||||
#custom-power {
|
||||
margin-bottom: 7px;
|
||||
padding: 14px 0px 14px 0px;
|
||||
}
|
||||
|
||||
#custom-search {
|
||||
background-image: url("${OSLogo}");
|
||||
background-size: 65%;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
#backlight {
|
||||
color: #${base0A};
|
||||
}
|
||||
|
||||
#battery {
|
||||
color: #${base0C};
|
||||
}
|
||||
|
||||
#battery.warning {
|
||||
color: #${base09};
|
||||
}
|
||||
|
||||
#battery.critical:not(.charging) {
|
||||
color: #${base08};
|
||||
}
|
||||
|
||||
tooltip {
|
||||
font-family: 'Lato', sans-serif;
|
||||
border-radius: 15px;
|
||||
padding: 20px;
|
||||
margin: 30px;
|
||||
}
|
||||
|
||||
tooltip label {
|
||||
font-family: 'Lato', sans-serif;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
''
|
|
@ -0,0 +1,276 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
osConfig,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) optionalString primaryMonitor;
|
||||
|
||||
sys = osConfig.modules.system;
|
||||
in {
|
||||
mainBar = {
|
||||
layer = "top";
|
||||
position = "left";
|
||||
# monitor configuration, kind of dirty since it assumes DP-1 is my main monitor
|
||||
output = primaryMonitor osConfig;
|
||||
width = 55;
|
||||
spacing = 7;
|
||||
margin-left = 6;
|
||||
margin-top = 9;
|
||||
margin-bottom = 9;
|
||||
margin-right = null;
|
||||
fixed-center = true;
|
||||
exclusive = true;
|
||||
modules-left = [
|
||||
"custom/search"
|
||||
"hyprland/workspaces"
|
||||
"backlight"
|
||||
"battery"
|
||||
"custom/weather"
|
||||
"custom/todo"
|
||||
];
|
||||
modules-center = [];
|
||||
modules-right = [
|
||||
"cpu"
|
||||
(optionalString sys.bluetooth.enable "bluetooth")
|
||||
"gamemode"
|
||||
"pulseaudio"
|
||||
"network"
|
||||
"custom/swallow"
|
||||
"clock"
|
||||
"custom/power"
|
||||
];
|
||||
|
||||
"hyprland/workspaces" = let
|
||||
hyprctl = config.wayland.windowManager.hyprland.package + "/bin/hyprctl";
|
||||
in {
|
||||
on-click = "activate";
|
||||
on-scroll-up = "${hyprctl} dispatch workspace m+1";
|
||||
on-scroll-down = "${hyprctl} dispatch workspace m-1";
|
||||
format = "{icon}";
|
||||
active-only = true;
|
||||
all-outputs = true;
|
||||
format-icons = {
|
||||
"1" = "一";
|
||||
"2" = "二";
|
||||
"3" = "三";
|
||||
"4" = "四";
|
||||
"5" = "五";
|
||||
"6" = "六";
|
||||
"7" = "七";
|
||||
"8" = "八";
|
||||
"9" = "九";
|
||||
"10" = "十";
|
||||
};
|
||||
};
|
||||
|
||||
"custom/search" = {
|
||||
format = " ";
|
||||
tooltip = false;
|
||||
on-click = "${lib.getExe pkgs.killall} rofi || run-as-service $(rofi -show drun)";
|
||||
};
|
||||
|
||||
"custom/todo" = {
|
||||
format = "{}";
|
||||
tooltip = true;
|
||||
interval = 7;
|
||||
exec = let
|
||||
todo = pkgs.todo + "/bin/todo";
|
||||
sed = pkgs.gnused + "/bin/sed";
|
||||
wc = pkgs.coreutils + "/bin/wc";
|
||||
in
|
||||
pkgs.writeShellScript "todo-waybar" ''
|
||||
#!/bin/sh
|
||||
|
||||
total_todo=$(${todo} | ${wc} -l)
|
||||
todo_raw_done=$(${todo} raw done | ${sed} 's/^/ ◉ /' | ${sed} -z 's/\n/\\n/g')
|
||||
todo_raw_undone=$(${todo} raw todo | ${sed} 's/^/ ◉ /' | ${sed} -z 's/\n/\\n/g')
|
||||
done=$(${todo} raw done | ${wc} -l)
|
||||
undone=$(${todo} raw todo | ${wc} -l)
|
||||
tooltip=$(${todo})
|
||||
|
||||
left="$done/$total_todo"
|
||||
|
||||
header="<b>todo</b>\\n\\n"
|
||||
tooltip=""
|
||||
if [[ $total_todo -gt 0 ]]; then
|
||||
if [[ $undone -gt 0 ]]; then
|
||||
export tooltip="$header👷 Today, you need to do:\\n\\n $(echo $todo_raw_undone)\\n\\n✅ You have already done:\\n\\n $(echo $todo_raw_done)"
|
||||
export output=" 🗒️ \\n $left"
|
||||
else
|
||||
export tooltip="$header✅ All done!\\n🥤 Remember to stay hydrated!"
|
||||
export output=" 🎉 \\n $left"
|
||||
fi
|
||||
else
|
||||
export tooltip=""
|
||||
export output=""
|
||||
fi
|
||||
|
||||
printf '{"text": "%s", "tooltip": "%s" }' "$output" "$tooltip"
|
||||
'';
|
||||
return-type = "json";
|
||||
};
|
||||
|
||||
"custom/weather" = let
|
||||
waybar-wttr = pkgs.stdenv.mkDerivation {
|
||||
name = "waybar-wttr";
|
||||
buildInputs = [(pkgs.python3.withPackages (pythonPackages: with pythonPackages; [requests]))];
|
||||
unpackPhase = "true";
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp ${../../scripts/waybar-wttr.py} $out/bin/waybar-wttr
|
||||
chmod +x $out/bin/waybar-wttr
|
||||
'';
|
||||
};
|
||||
in {
|
||||
format = "{}";
|
||||
tooltip = true;
|
||||
interval = 30;
|
||||
exec = "${waybar-wttr}/bin/waybar-wttr";
|
||||
return-type = "json";
|
||||
};
|
||||
|
||||
"custom/lock" = {
|
||||
tooltip = false;
|
||||
on-click = "${pkgs.bash}/bin/bash -c '(sleep 0.5s; ${lib.getExe pkgs.swaylock-effects} --grace 0)' & disown";
|
||||
format = "";
|
||||
};
|
||||
|
||||
"custom/swallow" = {
|
||||
tooltip = false;
|
||||
on-click = let
|
||||
hyprctl = config.wayland.windowManager.hyprland.package + "/bin/hyprctl";
|
||||
notify-send = pkgs.libnotify + "/bin/notify-send";
|
||||
rg = pkgs.ripgrep + "/bin/rg";
|
||||
in
|
||||
pkgs.writeShellScript "waybar-swallow" ''
|
||||
#!/bin/sh
|
||||
if ${hyprctl} getoption misc:enable_swallow | ${rg} -q "int: 1"; then
|
||||
${hyprctl} keyword misc:enable_swallow false >/dev/null &&
|
||||
${notify-send} "Hyprland" "Turned off swallowing"
|
||||
else
|
||||
${hyprctl} keyword misc:enable_swallow true >/dev/null &&
|
||||
${notify-send} "Hyprland" "Turned on swallowing"
|
||||
fi
|
||||
'';
|
||||
format = "";
|
||||
};
|
||||
|
||||
"custom/power" = {
|
||||
tooltip = false;
|
||||
on-click = let
|
||||
sudo = pkgs.sudo + "/bin/sudo";
|
||||
rofi = config.programs.rofi.package + "/bin/rofi";
|
||||
poweroff = pkgs.systemd + "/bin/poweroff";
|
||||
reboot = pkgs.systemd + "/bin/reboot";
|
||||
in
|
||||
pkgs.writeShellScript "shutdown-waybar" ''
|
||||
|
||||
#!/bin/sh
|
||||
|
||||
off=" Shutdown"
|
||||
reboot=" Reboot"
|
||||
cancel=" Cancel"
|
||||
|
||||
sure="$(printf '%s\n%s\n%s' "$off" "$reboot" "$cancel" |
|
||||
${rofi} -dmenu -p ' Are you sure?')"
|
||||
|
||||
if [ "$sure" = "$off" ]; then
|
||||
${sudo} ${poweroff}
|
||||
elif [ "$sure" = "$reboot" ]; then
|
||||
${sudo} ${reboot}
|
||||
fi
|
||||
'';
|
||||
format = "";
|
||||
};
|
||||
clock = {
|
||||
format = ''
|
||||
{:%H
|
||||
%M}'';
|
||||
tooltip-format = ''
|
||||
<big>{:%Y %B}</big>
|
||||
<tt><small>{calendar}</small></tt>
|
||||
'';
|
||||
};
|
||||
|
||||
backlight = let
|
||||
brightnessctl = lib.getExe pkgs.brightnessctl;
|
||||
in {
|
||||
format = "{icon}";
|
||||
format-icons = ["" "" "" "" "" "" ""];
|
||||
#format-icons = ["" "" "" "" "" "" "" "" ""];
|
||||
on-scroll-up = "${brightnessctl} s 1%-";
|
||||
on-scroll-down = "${brightnessctl} s +1%";
|
||||
};
|
||||
|
||||
battery = {
|
||||
states = {
|
||||
warning = 30;
|
||||
critical = 15;
|
||||
};
|
||||
format = "{icon}";
|
||||
format-charging = "";
|
||||
format-plugged = "";
|
||||
format-alt = "{icon}";
|
||||
format-icons = ["" "" "" "" "" "" "" "" "" "" "" ""];
|
||||
};
|
||||
network = let
|
||||
nm-editor = "${pkgs.networkmanagerapplet}/bin/nm-connection-editor";
|
||||
in {
|
||||
format-wifi = "";
|
||||
format-ethernet = "";
|
||||
format-alt = "";
|
||||
format-disconnected = "";
|
||||
tooltip-format = "{ipaddr}/{ifname} via {gwaddr} ({signalStrength}%)";
|
||||
on-click-right = "${nm-editor}";
|
||||
};
|
||||
|
||||
pulseaudio = {
|
||||
scroll-step = 5;
|
||||
tooltip = true;
|
||||
tooltip-format = "{volume}";
|
||||
on-click = "${pkgs.killall}/bin/killall pavucontrol || ${pkgs.pavucontrol}/bin/pavucontrol";
|
||||
format = "{icon}";
|
||||
format-muted = "";
|
||||
format-icons = {
|
||||
default = ["" "" ""];
|
||||
};
|
||||
};
|
||||
|
||||
cpu = {
|
||||
interval = 10;
|
||||
format = "";
|
||||
max-length = 10;
|
||||
states = {
|
||||
"50" = 50;
|
||||
"60" = 75;
|
||||
"70" = 90;
|
||||
};
|
||||
};
|
||||
|
||||
bluetooth = {
|
||||
# controller = "controller1", // specify the alias of the controller if there are more than 1 on the system
|
||||
format = "";
|
||||
format-disabled = ""; # an empty format will hide the module
|
||||
format-connected = "";
|
||||
tooltip-format = "{controller_alias}\t{controller_address}";
|
||||
tooltip-format-connected = "{controller_alias}\t{controller_address}\n\n{device_enumerate}";
|
||||
tooltip-format-disabled = "";
|
||||
tooltip-format-enumerate-connected = "{device_alias}\t{device_address}";
|
||||
};
|
||||
|
||||
gamemode = {
|
||||
format = "";
|
||||
format-alt = "{glyph}";
|
||||
glyph = "";
|
||||
hide-not-running = true;
|
||||
use-icon = true;
|
||||
icon-name = "input-gaming-symbolic";
|
||||
icon-spacing = 4;
|
||||
icon-size = 20;
|
||||
tooltip = true;
|
||||
tooltip-format = "Games running: {count}";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
{colors}:
|
||||
with colors; let
|
||||
OSLogo = builtins.fetchurl rec {
|
||||
name = "OSLogo-${sha256}.png";
|
||||
sha256 = "14mbpw8jv1w2c5wvfvj8clmjw0fi956bq5xf9s2q3my14far0as8";
|
||||
url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/master/logo/nix-snowflake.svg";
|
||||
};
|
||||
in ''
|
||||
* {
|
||||
font-family: Material Design Icons, Iosevka Nerd Font Mono;
|
||||
font-size: 19px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
window#waybar {
|
||||
background-color: #${base00};
|
||||
border: .5px solid #${base01};
|
||||
border-radius: 14px;
|
||||
box-shadow: 2 3 2 2px #151515;
|
||||
color: #${base05};
|
||||
margin: 16px 16px;
|
||||
transition-property: background-color;
|
||||
transition-duration: .5s;
|
||||
}
|
||||
|
||||
window#waybar.hidden {
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
#clock,
|
||||
#network,
|
||||
#custom-power,
|
||||
#cpu,
|
||||
#battery,
|
||||
#backlight,
|
||||
#memory,
|
||||
#workspaces,
|
||||
#custom-search,
|
||||
#custom-power,
|
||||
#custom-todo,
|
||||
#custom-lock,
|
||||
#custom-weather,
|
||||
#custom-swallow,
|
||||
#volume,
|
||||
#bluetooth,
|
||||
#gamemode,
|
||||
#pulseaudio {
|
||||
border-radius: 14px;
|
||||
margin: 0px 7px 0px 7px;
|
||||
background-color: #${base01};
|
||||
padding: 10px 0px 10px 0px;
|
||||
}
|
||||
|
||||
#workspaces {
|
||||
font-size: 14px;
|
||||
background-color: #${base01};
|
||||
}
|
||||
|
||||
#workspaces button {
|
||||
background-color: transparent;
|
||||
border-radius: 14px;
|
||||
color: #${base04};
|
||||
font-size: 21px;
|
||||
/* Use box-shadow instead of border so the text isn't offset */
|
||||
box-shadow: inset 0 -3px transparent;
|
||||
}
|
||||
|
||||
#workspaces button:hover {
|
||||
color: #${base0C};
|
||||
box-shadow: inherit;
|
||||
text-shadow: inherit;
|
||||
}
|
||||
|
||||
#workspaces button.active {
|
||||
color: #${base0A};
|
||||
}
|
||||
|
||||
#workspaces button.urgent {
|
||||
color: #${base08};
|
||||
}
|
||||
|
||||
#network {
|
||||
/* prevents the network icon from being too squashed */
|
||||
padding: 14px 0px 14px 0px;
|
||||
}
|
||||
|
||||
#cpu {
|
||||
color: rgba(0, 0, 0, 0.0);
|
||||
background-color: rgba(0, 0, 0, 0.0);
|
||||
margin: -50;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
#cpu.50 {
|
||||
color: #${base06};
|
||||
background-color: #${base02};
|
||||
border-radius: 15px;
|
||||
margin: 0px 7px 0px 7px;
|
||||
padding: 10px 0px 10px 0px;
|
||||
}
|
||||
|
||||
#cpu.60 {
|
||||
color: #${base09};
|
||||
background-color: #${base02};
|
||||
border-radius: 15px;
|
||||
margin: 0px 7px 0px 7px;
|
||||
padding: 10px 0px 10px 0px;
|
||||
}
|
||||
|
||||
#cpu.70 {
|
||||
color: #${base08};
|
||||
background-color: #${base02};
|
||||
border-radius: 15px;
|
||||
margin: 0px 7px 0px 7px;
|
||||
padding: 10px 0px 10px 0px;
|
||||
}
|
||||
|
||||
#bluetooth.off,
|
||||
#bluetooth.pairable,
|
||||
#bluetooth.discovering,
|
||||
#bluetooth.disabled {
|
||||
color: rgba(0, 0, 0, 0.0);
|
||||
background-color: rgba(0, 0, 0, 0.0);
|
||||
margin: -50;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
#clock {
|
||||
color: #${base05};
|
||||
background-color: #${base01};
|
||||
font-weight: 700;
|
||||
font-size: 20px;
|
||||
padding: 5px 0px 5px 0px;
|
||||
font-family: "Iosevka Term";
|
||||
}
|
||||
|
||||
#pulseaudio {
|
||||
padding: 5px 0px 5px 0px;
|
||||
font-size: 30;
|
||||
}
|
||||
|
||||
#pulseaudio.source-muted,
|
||||
#pulseaudio.muted {
|
||||
color: #${base08};
|
||||
padding: 16px 0px 16px 0px;
|
||||
font-size: 15;
|
||||
}
|
||||
|
||||
#custom-swallow {
|
||||
padding: 14px 0px 14px 0px;
|
||||
}
|
||||
|
||||
#custom-todo {
|
||||
padding-left: 2px;
|
||||
background-color: #${base01};
|
||||
}
|
||||
|
||||
#custom-power {
|
||||
margin-bottom: 7px;
|
||||
padding: 14px 0px 14px 0px;
|
||||
}
|
||||
|
||||
#custom-search {
|
||||
background-image: url("${OSLogo}");
|
||||
background-size: 65%;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
#custom-power {
|
||||
margin-bottom: 7px;
|
||||
padding: 14px 0px 14px 0px;
|
||||
color: #${base0A};
|
||||
}
|
||||
|
||||
#battery {
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
#battery.warning {
|
||||
color: #${base09};
|
||||
}
|
||||
|
||||
#battery.critical:not(.charging) {
|
||||
color: #${base08};
|
||||
}
|
||||
|
||||
tooltip {
|
||||
font-family: 'Lato', sans-serif;
|
||||
border-radius: 14px;
|
||||
padding: 20px;
|
||||
margin: 30px;
|
||||
}
|
||||
|
||||
tooltip label {
|
||||
font-family: 'Lato', sans-serif;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
''
|
168
nyx/homes/notashelf/services/wayland/waybar/scripts/waybar-wttr.py
Executable file
168
nyx/homes/notashelf/services/wayland/waybar/scripts/waybar-wttr.py
Executable file
|
@ -0,0 +1,168 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import json
|
||||
import requests
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
logging.basicConfig(level=logging.ERROR)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
CACHE_EXPIRATION = 60
|
||||
XDG_CACHE_HOME = os.getenv("XDG_CACHE_HOME", os.path.expanduser("~/.cache"))
|
||||
CACHE_DIR = os.path.join(XDG_CACHE_HOME, "waybar-wttr")
|
||||
FALLBACK_CACHE_DIR = "/tmp"
|
||||
CACHE_FILE = os.path.join(CACHE_DIR, "weather_cache.json")
|
||||
|
||||
SUNNY = "☀️"
|
||||
CLOUDY = "☁️"
|
||||
RAIN = "🌧️"
|
||||
SNOW = "❄️"
|
||||
THUNDERSTORM = "⛈️"
|
||||
PARTLY_CLOUDY = "⛅️"
|
||||
CLEAR = "☀️"
|
||||
|
||||
HOURS_AGO_THRESHOLD = 2
|
||||
TEMP_THRESHOLD_COLD = 10
|
||||
TEMP_THRESHOLD_HOT = 0
|
||||
|
||||
|
||||
def ensure_cache_directory():
|
||||
try:
|
||||
if not os.path.exists(CACHE_DIR):
|
||||
os.makedirs(CACHE_DIR, exist_ok=True)
|
||||
except Exception as e:
|
||||
logger.error(f"Error creating cache directory: {e}")
|
||||
|
||||
|
||||
def get_weather_data():
|
||||
ensure_cache_directory()
|
||||
try:
|
||||
response = requests.get("https://wttr.in/?format=j1")
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error(f"Error fetching weather data: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def get_cached_weather_data():
|
||||
try:
|
||||
if os.path.exists(CACHE_FILE):
|
||||
with open(CACHE_FILE, "r") as cache_file:
|
||||
cached_data = json.load(cache_file)
|
||||
cache_time = datetime.strptime(
|
||||
cached_data["timestamp"], "%Y-%m-%d %H:%M:%S"
|
||||
)
|
||||
if datetime.now() - cache_time < timedelta(minutes=CACHE_EXPIRATION):
|
||||
return cached_data["data"]
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading cached data: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def cache_weather_data(data):
|
||||
try:
|
||||
with open(CACHE_FILE, "w") as cache_file:
|
||||
cached_data = {
|
||||
"data": data,
|
||||
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
}
|
||||
json.dump(cached_data, cache_file)
|
||||
except Exception as e:
|
||||
logger.error(f"Error caching data: {e}")
|
||||
|
||||
|
||||
def format_time(time):
|
||||
return time.replace("00", "").zfill(2)
|
||||
|
||||
|
||||
def format_temp(temp):
|
||||
return f"{temp}°".ljust(4)
|
||||
|
||||
|
||||
def get_emoji_for_condition(condition):
|
||||
emoji_map = {
|
||||
"Sunny": SUNNY,
|
||||
"Cloudy": CLOUDY,
|
||||
"Rain": RAIN,
|
||||
"Snow": SNOW,
|
||||
"Thunder": THUNDERSTORM,
|
||||
"Partly Cloudy": PARTLY_CLOUDY,
|
||||
"Clear": CLEAR,
|
||||
}
|
||||
return emoji_map.get(condition, "")
|
||||
|
||||
|
||||
def format_conditions(hour):
|
||||
condition_probabilities = {
|
||||
"chanceoffog": "Fog",
|
||||
"chanceoffrost": "Frost",
|
||||
"chanceofovercast": "Overcast",
|
||||
"chanceofrain": "Rain",
|
||||
"chanceofsnow": "Snow",
|
||||
"chanceofsunshine": "Sunshine",
|
||||
"chanceofthunder": "Thunder",
|
||||
"chanceofwindy": "Wind",
|
||||
}
|
||||
if "chanceofpartlycloudy" in hour:
|
||||
condition_probabilities["chanceofpartlycloudy"] = "Partly Cloudy"
|
||||
conditions = []
|
||||
for event, description in condition_probabilities.items():
|
||||
if event in hour:
|
||||
probability = int(hour[event])
|
||||
if probability > 0:
|
||||
emoji = get_emoji_for_condition(description)
|
||||
conditions.append(f"{emoji} {description} {probability}%")
|
||||
return ", ".join(conditions)
|
||||
|
||||
|
||||
def format_weather_data(weather_data):
|
||||
current_condition = weather_data["current_condition"][0]
|
||||
temp = int(current_condition["FeelsLikeC"])
|
||||
temp_sign = "+" if TEMP_THRESHOLD_HOT > temp > TEMP_THRESHOLD_COLD else ""
|
||||
formatted_data = {
|
||||
"text": f" {SUNNY} \n {temp_sign}{temp}°",
|
||||
"tooltip": f"<b>{current_condition['weatherDesc'][0]['value']} {current_condition['temp_C']}°</b>\n"
|
||||
f"Feels like: {current_condition['FeelsLikeC']}°\n"
|
||||
f"Wind: {current_condition['windspeedKmph']}Km/h\n"
|
||||
f"Humidity: {current_condition['humidity']}%\n",
|
||||
}
|
||||
for i, day in enumerate(weather_data["weather"]):
|
||||
formatted_data["tooltip"] += f"\n<b>"
|
||||
if i == 0:
|
||||
formatted_data["tooltip"] += "Today, "
|
||||
if i == 1:
|
||||
formatted_data["tooltip"] += "Tomorrow, "
|
||||
formatted_data["tooltip"] += f"{day['date']}</b>\n"
|
||||
formatted_data["tooltip"] += f"⬆️ {day['maxtempC']}° ⬇️ {day['mintempC']}° "
|
||||
formatted_data[
|
||||
"tooltip"
|
||||
] += f"🌅 {day['astronomy'][0]['sunrise']} 🌇 {day['astronomy'][0]['sunset']}\n"
|
||||
now = datetime.now()
|
||||
for hour in day["hourly"]:
|
||||
hour_time = format_time(hour["time"])
|
||||
if i == 0 and int(hour_time) < now.hour - HOURS_AGO_THRESHOLD:
|
||||
continue
|
||||
formatted_data[
|
||||
"tooltip"
|
||||
] += f"{hour_time} {get_emoji_for_condition(hour['weatherDesc'][0]['value'])} {format_temp(hour['FeelsLikeC'])} {hour['weatherDesc'][0]['value']}, {format_conditions(hour)}\n"
|
||||
return formatted_data
|
||||
|
||||
|
||||
def main():
|
||||
ensure_cache_directory()
|
||||
cached_data = get_cached_weather_data()
|
||||
if cached_data:
|
||||
print(json.dumps(cached_data))
|
||||
return
|
||||
weather_data = get_weather_data()
|
||||
if weather_data:
|
||||
formatted_data = format_weather_data(weather_data)
|
||||
cache_weather_data(formatted_data)
|
||||
print(json.dumps(formatted_data))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue