Formatting + update

This commit is contained in:
Aleksandr Lebedev 2025-07-25 22:56:40 +02:00
parent 93de64c64e
commit 9c895e9cc0
61 changed files with 2350 additions and 2100 deletions

View file

@ -1,83 +1,89 @@
{pkgs, hwconfig, ...}:
let
battery-path = "/sys/class/power_supply/${if hwconfig.hostname == "kylekrein-mac" then "macsmc-battery" else "BAT0"}";
get-battery-level = "${pkgs.writeShellScriptBin "get-battery-level" ''
cat ${battery-path}/capacity 2>/dev/null || echo "N/A"
''}/bin/get-battery-level";
get-status = "${pkgs.writeShellScriptBin "get-status" ''
cat ${battery-path}/status 2>/dev/null || echo "Unknown"
''}/bin/get-status";
get-icon = "${pkgs.writeShellScriptBin "get-icon" ''
BATTERY_LEVEL=$(${get-battery-level})
STATUS=$(${get-status})
if [[ "$BATTERY_LEVEL" == "N/A" ]]; then
ICON="󰂑 "
elif [[ "$STATUS" == "Charging" ]]; then
if [[ $BATTERY_LEVEL -ge 90 ]]; then
ICON="󰂋 "
elif [[ $BATTERY_LEVEL -ge 80 ]]; then
ICON="󰂊 "
elif [[ $BATTERY_LEVEL -ge 70 ]]; then
ICON="󰢞 "
elif [[ $BATTERY_LEVEL -ge 60 ]]; then
ICON="󰂉 "
elif [[ $BATTERY_LEVEL -ge 50 ]]; then
ICON="󰢝 "
elif [[ $BATTERY_LEVEL -ge 40 ]]; then
ICON="󰂈 "
elif [[ $BATTERY_LEVEL -ge 30 ]]; then
ICON="󰂇 "
elif [[ $BATTERY_LEVEL -ge 20 ]]; then
ICON="󰂆 "
elif [[ $BATTERY_LEVEL -ge 10 ]]; then
ICON="󰢜 "
else
ICON="󰢜 "
fi
else
if [[ $BATTERY_LEVEL -ge 90 ]]; then
ICON="󰂂 "
elif [[ $BATTERY_LEVEL -ge 70 ]]; then
ICON="󰂀 "
elif [[ $BATTERY_LEVEL -ge 50 ]]; then
ICON="󰁾 "
elif [[ $BATTERY_LEVEL -ge 30 ]]; then
ICON="󰁼 "
elif [[ $BATTERY_LEVEL -ge 10 ]]; then
ICON="󰁺 "
else
ICON="󰁺 "
fi
fi
echo "$ICON"
''}/bin/get-icon";
get-remaining-time = "${pkgs.writeShellScriptBin "get-remaining-time" ''
REMAINING_ENERGY=$(cat ${battery-path}/energy_now)
POWER_USAGE=$(cat ${battery-path}/power_now)
if [[ -n "$REMAINING_ENERGY" && -n "$POWER_USAGE" && "$POWER_USAGE" -ne 0 ]]; then
TIME_LEFT=$((0 - (REMAINING_ENERGY / POWER_USAGE)))
MINUTES_LEFT=$(((0 - ( (REMAINING_ENERGY * 60) / POWER_USAGE )) - (TIME_LEFT * 60)))
echo "$TIME_LEFT h $MINUTES_LEFT min"
else
echo ""
fi
''}/bin/get-remaining-time";
in
{
pkgs,
hwconfig,
...
}: let
battery-path = "/sys/class/power_supply/${
if hwconfig.hostname == "kylekrein-mac"
then "macsmc-battery"
else "BAT0"
}";
get-battery-level = "${pkgs.writeShellScriptBin "get-battery-level" ''
cat ${battery-path}/capacity 2>/dev/null || echo "N/A"
''}/bin/get-battery-level";
get-status = "${pkgs.writeShellScriptBin "get-status" ''
cat ${battery-path}/status 2>/dev/null || echo "Unknown"
''}/bin/get-status";
get-icon = "${pkgs.writeShellScriptBin "get-icon" ''
BATTERY_LEVEL=$(${get-battery-level})
STATUS=$(${get-status})
if [[ "$BATTERY_LEVEL" == "N/A" ]]; then
ICON="󰂑 "
elif [[ "$STATUS" == "Charging" ]]; then
if [[ $BATTERY_LEVEL -ge 90 ]]; then
ICON="󰂋 "
elif [[ $BATTERY_LEVEL -ge 80 ]]; then
ICON="󰂊 "
elif [[ $BATTERY_LEVEL -ge 70 ]]; then
ICON="󰢞 "
elif [[ $BATTERY_LEVEL -ge 60 ]]; then
ICON="󰂉 "
elif [[ $BATTERY_LEVEL -ge 50 ]]; then
ICON="󰢝 "
elif [[ $BATTERY_LEVEL -ge 40 ]]; then
ICON="󰂈 "
elif [[ $BATTERY_LEVEL -ge 30 ]]; then
ICON="󰂇 "
elif [[ $BATTERY_LEVEL -ge 20 ]]; then
ICON="󰂆 "
elif [[ $BATTERY_LEVEL -ge 10 ]]; then
ICON="󰢜 "
else
ICON="󰢜 "
fi
else
if [[ $BATTERY_LEVEL -ge 90 ]]; then
ICON="󰂂 "
elif [[ $BATTERY_LEVEL -ge 70 ]]; then
ICON="󰂀 "
elif [[ $BATTERY_LEVEL -ge 50 ]]; then
ICON="󰁾 "
elif [[ $BATTERY_LEVEL -ge 30 ]]; then
ICON="󰁼 "
elif [[ $BATTERY_LEVEL -ge 10 ]]; then
ICON="󰁺 "
else
ICON="󰁺 "
fi
fi
echo "$ICON"
''}/bin/get-icon";
get-remaining-time = "${pkgs.writeShellScriptBin "get-remaining-time" ''
REMAINING_ENERGY=$(cat ${battery-path}/energy_now)
POWER_USAGE=$(cat ${battery-path}/power_now)
if [[ -n "$REMAINING_ENERGY" && -n "$POWER_USAGE" && "$POWER_USAGE" -ne 0 ]]; then
TIME_LEFT=$((0 - (REMAINING_ENERGY / POWER_USAGE)))
MINUTES_LEFT=$(((0 - ( (REMAINING_ENERGY * 60) / POWER_USAGE )) - (TIME_LEFT * 60)))
echo "$TIME_LEFT h $MINUTES_LEFT min"
else
echo ""
fi
''}/bin/get-remaining-time";
in {
available = hwconfig.isLaptop;
icon = get-icon;
status = get-status;
time = get-remaining-time;
level = get-battery-level;
labelAdaptive = "${pkgs.writeShellScriptBin "labelAdaptive" ''
if [[ "$(${get-status})" == "Charging" ]]; then
echo "$(${get-battery-level})% $(${get-icon})"
else
echo "$(${get-remaining-time}) $(${get-icon})"
fi
if [[ "$(${get-status})" == "Charging" ]]; then
echo "$(${get-battery-level})% $(${get-icon})"
else
echo "$(${get-remaining-time}) $(${get-icon})"
fi
''}/bin/labelAdaptive";
labelPercent = "${pkgs.writeShellScriptBin "labelPercent" ''
echo "$(${get-battery-level})% $(${get-icon})"
echo "$(${get-battery-level})% $(${get-icon})"
''}/bin/labelPercent";
}

View file

@ -1,10 +1,20 @@
{config, username, pkgs, lib, inputs, hwconfig, ...}: {
imports = [
./git.nix
] ++ lib.optional (lib.strings.hasInfix "kylekrein" hwconfig.hostname) (
{
config,
username,
pkgs,
lib,
inputs,
hwconfig,
...
}: {
imports =
[
./git.nix
]
++ lib.optional (lib.strings.hasInfix "kylekrein" hwconfig.hostname) (
import ./niri.nix {
inherit pkgs;
inherit config;
inherit config;
inherit username;
inherit inputs;
inherit hwconfig;

View file

@ -1,21 +1,28 @@
{ pkgs, lib, hwconfig, ... }:
let
profile-image = ./nixos-warbler.png;
battery-level = (import ./battery-status.nix {inherit pkgs; inherit hwconfig;}).labelPercent;
in
{
pkgs,
lib,
hwconfig,
...
}: let
profile-image = ./nixos-warbler.png;
battery-level =
(import ./battery-status.nix {
inherit pkgs;
inherit hwconfig;
}).labelPercent;
in {
programs.hyprlock = {
enable = true;
settings = {
general = {
#enable_fingerprint = true;
disable_loading_bar = true;
hide_cursor = true;
no_fade_in = false;
grace = 10;
disable_loading_bar = true;
hide_cursor = true;
no_fade_in = false;
grace = 10;
};
background = {
path = "${../../modules/hyprland/wallpaper.jpg}";
path = "${../../modules/hyprland/wallpaper.jpg}";
blur_passes = 1;
blur_size = 7;
noise = 0.0117;
@ -25,14 +32,14 @@ in
vibrancy_darkness = 0.0;
};
image = {
path = "${profile-image}";
size = 150;
border_size = 4;
#border_color = "rgb(0C96F9)";
rounding = -1; # Negative means circle
position = "0, 220";
halign = "center";
valign = "center";
path = "${profile-image}";
size = 150;
border_size = 4;
#border_color = "rgb(0C96F9)";
rounding = -1; # Negative means circle
position = "0, 220";
halign = "center";
valign = "center";
};
input-field = {
size = "600, 100";
@ -52,41 +59,41 @@ in
halign = "center";
valign = "center";
};
label = [
{
text = "$USER";
font_family = "Fira Code";
font_size = 56;
position = "0, 100";
halign = "center";
valign = "center";
}
{
text = "$TIME";
font_family = "Roboto";
font_size = 72;
position = "-40, -40";
halign = "right";
valign = "top";
}
{
text = "$LAYOUT";
font_family = "JetBrains Mono";
font_size = 28;
position = "-20, 20";
halign = "right";
valign = "bottom";
}
] ++ lib.optional (hwconfig.isLaptop) (
{
label =
[
{
text = "$USER";
font_family = "Fira Code";
font_size = 56;
position = "0, 100";
halign = "center";
valign = "center";
}
{
text = "$TIME";
font_family = "Roboto";
font_size = 72;
position = "-40, -40";
halign = "right";
valign = "top";
}
{
text = "$LAYOUT";
font_family = "JetBrains Mono";
font_size = 28;
position = "-20, 20";
halign = "right";
valign = "bottom";
}
]
++ lib.optional (hwconfig.isLaptop) {
text = ''cmd[update:10000] ${battery-level}'';
font_family = "JetBrains Mono";
font_size = 28;
position = "20, 20";
halign = "left";
valign = "bottom";
});
};
};
};
}

View file

@ -1,2 +1,2 @@
{ pkgs }:
pkgs.lisgd.override { conf = ./lisgd-config.h; }
{pkgs}:
pkgs.lisgd.override {conf = ./lisgd-config.h;}

View file

@ -1,8 +1,15 @@
#https://github.com/sodiboo/niri-flake/blob/main/default-config.kdl.nix
#https://github.com/sodiboo/niri-flake/blob/main/docs.md
#https://github.com/sodiboo/system/blob/main/niri.mod.nix
{config, pkgs, lib, inputs, hwconfig, username, ...}:
{
config,
pkgs,
lib,
inputs,
hwconfig,
username,
...
}: {
programs.fuzzel = {
enable = true;
settings.main.terminal = "kitty";
@ -14,74 +21,76 @@
./waybar
./hyprlock.nix
];
home.packages = with pkgs;[
nwg-drawer
wlogout
brightnessctl
fuzzel
waybar
swaybg
libnotify
hyprlock
networkmanagerapplet
] ++ lib.optionals (hwconfig.hasTouchscreen) (with pkgs;[
wvkbd # https://github.com/jjsullivan5196/wvkbd
]);
home.packages = with pkgs;
[
nwg-drawer
wlogout
brightnessctl
fuzzel
waybar
swaybg
libnotify
hyprlock
networkmanagerapplet
]
++ lib.optionals (hwconfig.hasTouchscreen) (with pkgs; [
wvkbd # https://github.com/jjsullivan5196/wvkbd
]);
programs.niri = {
settings = {
outputs = lib.mkIf (hwconfig.hostname == "kylekrein-homepc") {
"DP-1" = {
scale = 1.6;
position.x = 1600;
position.y = 0;
};
"DP-3" = {
scale = 1.6;
position.x = 0;
position.y = 0;
};
"DP-1" = {
scale = 1.6;
position.x = 1600;
position.y = 0;
};
"DP-3" = {
scale = 1.6;
position.x = 0;
position.y = 0;
};
};
spawn-at-startup = let
set-low-brightness = lib.mkIf (hwconfig.isLaptop) {
command = [
"${lib.getExe pkgs.brightnessctl}"
"set"
"25%"
];
};
touchscreen-gestures = lib.mkIf (hwconfig.hasTouchscreen) {
set-low-brightness = lib.mkIf (hwconfig.isLaptop) {
command = [
"${lib.getExe (import ./lisgd.nix { inherit pkgs; })}" #https://git.sr.ht/~mil/lisgd
"${lib.getExe pkgs.brightnessctl}"
"set"
"25%"
];
};
touchscreen-gestures = lib.mkIf (hwconfig.hasTouchscreen) {
command = [
"${lib.getExe (import ./lisgd.nix {inherit pkgs;})}" #https://git.sr.ht/~mil/lisgd
];
};
in [
set-low-brightness
touchscreen-gestures
{
set-low-brightness
touchscreen-gestures
{
command = [
"${lib.getExe pkgs.networkmanagerapplet}"
];
}
{
{
command = [
"${lib.getExe pkgs.networkmanagerapplet}"
];
}
{
{
command = [
"dbus-update-activation-environment"
"--systemd"
"--all"
"--systemd"
"--all"
];
}
{
{
command = [
"${pkgs.solaar}/bin/solaar"
"-w"
"hide"
"-w"
"hide"
];
}
{
{
command = [
"${lib.getExe pkgs.swaybg}"
"-m"
@ -90,7 +99,7 @@
"${../../modules/hyprland/wallpaper.jpg}"
];
}
{
{
command = [
"emacs"
"--daemon"
@ -99,96 +108,100 @@
];
layout = {
preset-column-widths = [
{proportion = 1.0 / 2.0;}
{proportion = 1.0;}
{proportion = 2.0 / 3.0;}
{proportion = 1.0 / 3.0;}
{proportion = 1.0 / 2.0;}
{proportion = 1.0;}
{proportion = 2.0 / 3.0;}
{proportion = 1.0 / 3.0;}
];
default-column-width = {proportion = 1.0 / 2.0;};
};
binds = with config.lib.niri.actions;
let
sh = spawn "sh" "-c";
binds = with config.lib.niri.actions; let
sh = spawn "sh" "-c";
emacs = action: sh "emacsclient -c --eval \"${action}\"";
homedir = "/home/${username}/";
screenshot-annotate = sh ''${lib.getExe pkgs.grim} -g "$(${lib.getExe pkgs.slurp} -w 0)" -t ppm - | ${lib.getExe pkgs.satty} --early-exit --copy-command 'wl-copy' --filename '-' --initial-tool brush'';
in {
"Mod+E".action = sh "emacsclient -c";
"Mod+Shift+C".action = sh "dolphin";
"Mod+C".action = emacs ''(dirvish \"${homedir}\")'';
"Mod+T".action = spawn "kitty";
"Mod+D".action = spawn "fuzzel";
"Mod+B".action = spawn "librewolf";
"Mod+H".action = show-hotkey-overlay;
"Mod+F".action = fullscreen-window;
"Mod+R".action = switch-preset-column-width;
"Mod+Q".action = close-window;
"Mod+Shift+S".action = screenshot-annotate;
"Mod+1".action = focus-workspace 1;
"Mod+2".action = focus-workspace 2;
"Mod+3".action = focus-workspace 3;
"Mod+4".action = focus-workspace 4;
"Mod+5".action = focus-workspace 5;
"Mod+6".action = focus-workspace 6;
"Mod+7".action = focus-workspace 7;
"Mod+8".action = focus-workspace 8;
"Mod+9".action = focus-workspace 9;
"Mod+0".action = focus-workspace 10;
"Mod+Shift+1".action.move-column-to-workspace = 1;
"Mod+Shift+2".action.move-column-to-workspace = 2;
"Mod+Shift+3".action.move-column-to-workspace = 3;
"Mod+Shift+4".action.move-column-to-workspace = 4;
"Mod+Shift+5".action.move-column-to-workspace = 5;
"Mod+Shift+6".action.move-column-to-workspace = 6;
"Mod+Shift+7".action.move-column-to-workspace = 7;
"Mod+Shift+8".action.move-column-to-workspace = 8;
"Mod+Shift+9".action.move-column-to-workspace = 9;
"Mod+Shift+0".action.move-column-to-workspace = 10;
"Mod+Left".action = focus-column-left;
"Mod+Right".action = focus-column-right;
"Mod+Up".action = focus-workspace-up;
"Mod+Down".action = focus-workspace-down;
"Mod+Shift+Left".action = move-column-left;
"Mod+Shift+Right".action = move-column-right;
"Mod+Shift+Up".action = move-column-to-workspace-up;
"Mod+Shift+Down".action = move-column-to-workspace-down;
"Mod+Ctrl+Left".action = focus-monitor-left;
"Mod+Ctrl+Right".action = focus-monitor-right;
"Mod+Shift+Ctrl+Left".action = move-column-to-monitor-left;
"Mod+Shift+Ctrl+Right".action = move-column-to-monitor-right;
screenshot-annotate = sh ''${lib.getExe pkgs.grim} -g "$(${lib.getExe pkgs.slurp} -w 0)" -t ppm - | ${lib.getExe pkgs.satty} --early-exit --copy-command 'wl-copy' --filename '-' --initial-tool brush'';
in {
"Mod+E".action = sh "emacsclient -c";
"Mod+Shift+C".action = sh "dolphin";
"Mod+C".action = emacs ''(dirvish \"${homedir}\")'';
"Mod+T".action = spawn "kitty";
"Mod+D".action = spawn "fuzzel";
"Mod+B".action = spawn "librewolf";
"Mod+H".action = show-hotkey-overlay;
"Mod+F".action = fullscreen-window;
"Mod+R".action = switch-preset-column-width;
"Mod+Q".action = close-window;
"Mod+Shift+S".action = screenshot-annotate;
"Mod+1".action = focus-workspace 1;
"Mod+2".action = focus-workspace 2;
"Mod+3".action = focus-workspace 3;
"Mod+4".action = focus-workspace 4;
"Mod+5".action = focus-workspace 5;
"Mod+6".action = focus-workspace 6;
"Mod+7".action = focus-workspace 7;
"Mod+8".action = focus-workspace 8;
"Mod+9".action = focus-workspace 9;
"Mod+0".action = focus-workspace 10;
"Mod+Shift+1".action.move-column-to-workspace = 1;
"Mod+Shift+2".action.move-column-to-workspace = 2;
"Mod+Shift+3".action.move-column-to-workspace = 3;
"Mod+Shift+4".action.move-column-to-workspace = 4;
"Mod+Shift+5".action.move-column-to-workspace = 5;
"Mod+Shift+6".action.move-column-to-workspace = 6;
"Mod+Shift+7".action.move-column-to-workspace = 7;
"Mod+Shift+8".action.move-column-to-workspace = 8;
"Mod+Shift+9".action.move-column-to-workspace = 9;
"Mod+Shift+0".action.move-column-to-workspace = 10;
"XF86AudioRaiseVolume".action = sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+";
"Mod+Left".action = focus-column-left;
"Mod+Right".action = focus-column-right;
"Mod+Up".action = focus-workspace-up;
"Mod+Down".action = focus-workspace-down;
"Mod+Shift+Left".action = move-column-left;
"Mod+Shift+Right".action = move-column-right;
"Mod+Shift+Up".action = move-column-to-workspace-up;
"Mod+Shift+Down".action = move-column-to-workspace-down;
"Mod+Ctrl+Left".action = focus-monitor-left;
"Mod+Ctrl+Right".action = focus-monitor-right;
"Mod+Shift+Ctrl+Left".action = move-column-to-monitor-left;
"Mod+Shift+Ctrl+Right".action = move-column-to-monitor-right;
"XF86AudioRaiseVolume".action = sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+";
"XF86AudioLowerVolume".action = sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-";
"XF86AudioMute".action = sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
"XF86MonBrightnessUp".action = sh "brightnessctl set 10%+";
"XF86MonBrightnessDown".action = sh "brightnessctl set 10%-";
#"Mod+Tab".action = focus-window-down-or-column-right;
#"Mod+Tab".action = focus-window-down-or-column-right;
#"Mod+Shift+Tab".action = focus-window-up-or-column-left;
"Mod+Tab".action = toggle-overview;
"Mod+Tab".action = toggle-overview;
};
input = {
focus-follows-mouse = {
#enable = true;
};
warp-mouse-to-focus.enable = true;
keyboard = {
xkb.layout = "us, ru, de";
xkb.options = "grp:lctrl_toggle, ctrl:nocaps" + (if hwconfig.hostname == "kylekrein-mac" then ", altwin:swap_alt_win" else "");
track-layout = "window";
numlock = true;
};
touchpad = {
tap = true;
#accel-profile = "adaptive";
click-method = "clickfinger";
};
focus-follows-mouse = {
#enable = true;
};
warp-mouse-to-focus.enable = true;
keyboard = {
xkb.layout = "us, ru, de";
xkb.options =
"grp:lctrl_toggle, ctrl:nocaps"
+ (
if hwconfig.hostname == "kylekrein-mac"
then ", altwin:swap_alt_win"
else ""
);
track-layout = "window";
numlock = true;
};
touchpad = {
tap = true;
#accel-profile = "adaptive";
click-method = "clickfinger";
};
};
cursor = {
hide-after-inactive-ms = 10000;
hide-after-inactive-ms = 10000;
};
gestures.hot-corners.enable = true;
prefer-no-csd = true;
@ -196,68 +209,77 @@
XDG_SESSION_TYPE = "wayland";
__GL_GSYNC_ALLOWED = "1";
QT_QPA_PLATFORM = "wayland";
DISPLAY = ":0";
DISPLAY = ":0";
};
window-rules = [
{ #active
matches = [
{
#active
matches = [
{
is-active = true;
}
];
opacity = 1.0;
}
{ #inactive
matches = [
is-active = true;
}
];
opacity = 1.0;
}
{
#inactive
matches = [
{
is-active = false;
}
];
opacity = 1.0;
}
{ #opaque
matches = [
is-active = false;
}
];
opacity = 1.0;
}
{
#opaque
matches = [
{
app-id = "emacs";
}
{
app-id = "blender";
}
];
opacity = 1.0;
}
{ #app-launcher
matches = [
app-id = "emacs";
}
{
title = "emacs-run-launcher";
}
];
open-floating = true;
open-focused = true;
}
{ #PiP
matches = [
app-id = "blender";
}
];
opacity = 1.0;
}
{
#app-launcher
matches = [
{
title = "Picture-in-Picture";
}
];
open-floating = true;
open-focused = false;
opacity = 1.0;
default-floating-position = { x = 0; y = 0; relative-to = "top-right"; };
}
title = "emacs-run-launcher";
}
];
open-floating = true;
open-focused = true;
}
{
#PiP
matches = [
{
title = "Picture-in-Picture";
}
];
open-floating = true;
open-focused = false;
opacity = 1.0;
default-floating-position = {
x = 0;
y = 0;
relative-to = "top-right";
};
}
];
debug = lib.mkIf (hwconfig.hostname == "kylekrein-mac") {
render-drm-device = "/dev/dri/renderD128";
render-drm-device = "/dev/dri/renderD128";
};
xwayland-satellite = {
enable = true;
path = "${lib.getExe pkgs.xwayland-satellite-unstable}";
enable = true;
path = "${lib.getExe pkgs.xwayland-satellite-unstable}";
};
};
};
services.hypridle = let
services.hypridle = let
niri = lib.getExe config.programs.niri.package;
loginctl = "${pkgs.systemd}/bin/loginctl";
pidof = "${pkgs.procps}/bin/pidof";
@ -265,43 +287,44 @@
systemctl = "${pkgs.systemd}/bin/systemctl";
#locking-script = "${pkgs.swaylock}/bin/swaylock --daemonize";
#unlocking-script = "pkill -SIGUSR1 swaylock";
suspendScript = cmd: pkgs.writeShellScript "suspend-script" ''
# check if any player has status "Playing"
${lib.getExe pkgs.playerctl} -a status | ${lib.getExe pkgs.ripgrep} Playing -q
# only suspend if nothing is playing
if [ $? == 1 ]; then
${cmd}
fi
'';
in{
suspendScript = cmd:
pkgs.writeShellScript "suspend-script" ''
# check if any player has status "Playing"
${lib.getExe pkgs.playerctl} -a status | ${lib.getExe pkgs.ripgrep} Playing -q
# only suspend if nothing is playing
if [ $? == 1 ]; then
${cmd}
fi
'';
in {
enable = true;
settings.general = {
before_sleep_cmd = "${pidof} hyprlock || ${loginctl} lock-session;#${niri} msg action power-off-monitors";
after_sleep_cmd = "#${niri} msg action power-on-monitors";
lock_cmd = "${locking-script}";
};
settings.listener = let
secondary = "${systemctl} suspend";
in lib.mkIf (hwconfig.isLaptop) [
#{
# timeout = 30;
# command = "pidof hyprlock && ${secondary}";
#}
{
timeout = 870;
on-timeout = "${suspendScript ''${pkgs.libnotify}/bin/notify-send "You are idle. Going to sleep in 30 seconds"''}";
}
{
timeout = 900;
on-timeout = "${suspendScript "${systemctl} suspend"}";
}
];
settings.listener = let
secondary = "${systemctl} suspend";
in
lib.mkIf (hwconfig.isLaptop) [
#{
# timeout = 30;
# command = "pidof hyprlock && ${secondary}";
#}
{
timeout = 870;
on-timeout = "${suspendScript ''${pkgs.libnotify}/bin/notify-send "You are idle. Going to sleep in 30 seconds"''}";
}
{
timeout = 900;
on-timeout = "${suspendScript "${systemctl} suspend"}";
}
];
};
services = {
mako = {
enable = false;
settings = {
};
};
};

View file

@ -1,67 +1,76 @@
{ pkgs, lib, hwconfig, ... }:
let
battery = (import ../battery-status.nix {inherit pkgs; inherit hwconfig;});
in
{
pkgs,
lib,
hwconfig,
...
}: let
battery = import ../battery-status.nix {
inherit pkgs;
inherit hwconfig;
};
in {
programs.waybar = {
enable = true;
systemd.enable = true;
#window#waybar {
# background: transparent;
#border-bottom: none;
#}
#${builtins.readFile "${pkgs.waybar}/etc/xdg/waybar/style.css"}
style = ''
${builtins.readFile ./waybarstyle.css}'';
settings = [{
# background: transparent;
#border-bottom: none;
#}
#${builtins.readFile "${pkgs.waybar}/etc/xdg/waybar/style.css"}
style = ''
${builtins.readFile ./waybarstyle.css}'';
settings = [
{
height = 36;
layer = "top";
position = "top";
tray = { spacing = 3; };
modules-center = [
#"hyprland/window"
"clock"
];
modules-left = [
"custom/drawer"
"wlr/taskbar"
"niri/workspaces"
"niri/window"
tray = {spacing = 3;};
modules-center = [
#"hyprland/window"
"clock"
];
modules-right = lib.optional hwconfig.isLaptop "backlight"
++ [
"pulseaudio"
#"network"
#"cpu"
"memory"
#"temperature"
"niri/language"
] ++ lib.optional battery.available "custom/battery"
++ [
"tray"
"custom/notification"
#"custom/disablehypridle"
"custom/power"
modules-left = [
"custom/drawer"
"wlr/taskbar"
"niri/workspaces"
"niri/window"
];
modules-right =
lib.optional hwconfig.isLaptop "backlight"
++ [
"pulseaudio"
#"network"
#"cpu"
"memory"
#"temperature"
"niri/language"
]
++ lib.optional battery.available "custom/battery"
++ [
"tray"
"custom/notification"
#"custom/disablehypridle"
"custom/power"
];
battery = {
format = " {time} {icon} ";
format-alt = " {capacity}% {icon} ";
format-charging = " {capacity}% ";
format-icons = [ "" "" "" "" "" ];
format-icons = ["" "" "" "" ""];
format-plugged = " {capacity}% ";
states = {
critical = 10;
warning = 20;
};
};
backlight = {
format = "{percent}% 󰛩";
on-scroll-up = "${pkgs.brightnessctl}/bin/brightnessctl s 5%+";
on-scroll-down = "${pkgs.brightnessctl}/bin/brightnessctl s 5%-";
};
backlight = {
format = "{percent}% 󰛩";
on-scroll-up = "${pkgs.brightnessctl}/bin/brightnessctl s 5%+";
on-scroll-down = "${pkgs.brightnessctl}/bin/brightnessctl s 5%-";
};
"custom/battery" = {
exec ="${pkgs.writeShellScriptBin "battery-widget" ''
exec = "${pkgs.writeShellScriptBin "battery-widget" ''
${battery.labelAdaptive}
${battery.labelPercent}
''}/bin/battery-widget";
@ -69,7 +78,7 @@ ${builtins.readFile ./waybarstyle.css}'';
tooltip = true;
};
clock = {
format = "{:%a %d | %H:%M}";
format = "{:%a %d | %H:%M}";
format-alt = "{:%d.%m.%Y}";
tooltip-format = "{:%d.%m.%Y | %H:%M}";
};
@ -77,30 +86,30 @@ ${builtins.readFile ./waybarstyle.css}'';
format = "{usage}% ";
tooltip = false;
};
"custom/drawer" = {
format = "<span foreground='white'>󱄅</span>";
tooltip = false;
on-click = ''nwg-drawer -fm "dolphin" -closebtn "right" -nocats -term "kitty" -ovl -wm "niri" -s "${./drawerstyle.css}" '';
};
"niri/language" = {
format = "{}";
format-en = "EN";
format-ru = "RU";
format-de = "DE";
on-click = "niri msg action switch-layout next";
on-click-right = "niri msg action switch-layout prev";
"custom/drawer" = {
format = "<span foreground='white'>󱄅</span>";
tooltip = false;
on-click = ''nwg-drawer -fm "dolphin" -closebtn "right" -nocats -term "kitty" -ovl -wm "niri" -s "${./drawerstyle.css}" '';
};
"niri/language" = {
format = "{}";
format-en = "EN";
format-ru = "RU";
format-de = "DE";
on-click = "niri msg action switch-layout next";
on-click-right = "niri msg action switch-layout prev";
};
"wlr/taskbar" = {
format = "{icon}";
icon-size = 18;
tooltip-format = "{title}";
on-click = "activate";
on-click-middle = "close";
};
memory = {
interval = 1;
format = " {used}/{total}Gb";
};
"wlr/taskbar" = {
format = "{icon}";
icon-size = 18;
tooltip-format = "{title}";
on-click = "activate";
on-click-middle = "close";
};
memory = {
interval = 1;
format = " {used}/{total}Gb";
};
network = {
interval = 1;
format-alt = "{ifname}: {ipaddr}/{cidr}";
@ -117,7 +126,7 @@ ${builtins.readFile ./waybarstyle.css}'';
format-bluetooth-muted = " {format_source}";
format-icons = {
car = "";
default = [ " " " " " " ];
default = [" " " " " "];
handsfree = "";
headphones = "";
headset = "";
@ -129,49 +138,49 @@ ${builtins.readFile ./waybarstyle.css}'';
format-source-muted = " ";
on-click = "${pkgs.pwvucontrol}/bin/pwvucontrol";
};
"hyprland/submap" = { format = ''<span style="italic">{}</span>''; };
"hyprland/submap" = {format = ''<span style="italic">{}</span>'';};
temperature = {
critical-threshold = 80;
format = "{temperatureC}°C {icon}";
format-icons = [ "" "" "" ];
format-icons = ["" "" ""];
};
"hyprland/workspaces" = {
disable-scroll = true;
all-outputs = false;
warp-on-scroll = true;
format = "{name}{icon} ";
format-icons = {
urgent = "";
active = "";
default = "";
};
#persistent-workspaces = {
# "*" = 3;
#};
disable-scroll = true;
all-outputs = false;
warp-on-scroll = true;
format = "{name}{icon} ";
format-icons = {
urgent = "";
active = "";
default = "";
};
#persistent-workspaces = {
# "*" = 3;
#};
};
"custom/power" = {
format = "";
tooltip = false;
on-click = "wlogout";
format = "";
tooltip = false;
on-click = "wlogout";
};
"custom/notification" = {
tooltip = false;
format = "{icon}";
format-icons = {
notification = "<span foreground='red'></span>";
none = "";
dnd-notification = "<span foreground='red'></span>";
dnd-none = "";
};
return-type = "json";
exec-if = "which swaync-client";
exec = "swaync-client -swb";
on-click = "sleep 0.1 && swaync-client -t -sw";
on-click-right = "sleep 0.1 && swaync-client -d -sw";
escape = true;
tooltip = false;
format = "{icon}";
format-icons = {
notification = "<span foreground='red'></span>";
none = "";
dnd-notification = "<span foreground='red'></span>";
dnd-none = "";
};
return-type = "json";
exec-if = "which swaync-client";
exec = "swaync-client -swb";
on-click = "sleep 0.1 && swaync-client -t -sw";
on-click-right = "sleep 0.1 && swaync-client -d -sw";
escape = true;
};
"custom/disablehypridle" = {
@ -191,6 +200,7 @@ ${builtins.readFile ./waybarstyle.css}'';
fi
'';
};
}];
}
];
};
}