user/{eww,hypridle,hyprlock}: configure based on options.me

This commit is contained in:
LavaDesu 2025-03-23 12:36:07 +11:00
parent f33525f565
commit 1a62545c3c
Signed by: cilly
GPG key ID: 6500251E087653C9
5 changed files with 78 additions and 37 deletions

View file

@ -1,18 +1,43 @@
{ config, lib, ... }: {
{ config, lib, ... }:
let
inherit (lib)
mkOption
types;
in {
options.me = {
environment = lib.mkOption {
type = lib.types.enum [ "desktop" "laptop" "headless" ];
environment = mkOption {
type = types.enum [ "desktop" "laptop" "headless" ];
default = "desktop";
};
fprint = lib.mkOption {
type = lib.types.bool;
fprint = mkOption {
type = types.bool;
default = false;
};
gui = lib.mkOption {
type = lib.types.bool;
gui = mkOption {
type = types.bool;
default = config.me.environment != "headless";
};
batteryDevice = mkOption {
type = types.nullOr types.string;
default = null;
};
kbBacklightDevice = mkOption {
type = types.nullOr types.string;
default = null;
};
hasBluetooth = mkOption {
type = types.bool;
default = config.me.environment == "laptop";
};
hasWifi = mkOption {
type = types.bool;
default = config.me.environment == "laptop";
};
};
}

View file

@ -6,10 +6,17 @@ let
dontUnpack = true;
installPhase = ''
cp -r ${../../res/eww} $out
substituteInPlace $out/eww.yuck \
--replace-fail "_BAT_ENABLED_" "${config.me.batteryPath != null}" \
--replace-fail "_BAT_PATH_" "${config.me.batteryPATH}" \
--replace-fail "_BT_ENABLED_" "${config.me.hasBluetooth}" \
--replace-fail "_WIFI_ENABLED_" "${config.me.hasWifi}"
substituteInPlace $out/eww.scss \
--replace-warn "EWW_BACKGROUND" "${config.catppuccin.hexcolors.crust}" \
--replace-warn "EWW_TEXT" "${config.catppuccin.hexcolors.text}" \
--replace-warn "EWW_ACCENT" "${config.catppuccin.hexcolors.${config.catppuccin.accent}}"
--replace-fail "EWW_BACKGROUND" "${config.catppuccin.hexcolors.crust}" \
--replace-fail "EWW_TEXT" "${config.catppuccin.hexcolors.text}" \
--replace-fail "EWW_ACCENT" "${config.catppuccin.hexcolors.${config.catppuccin.accent}}"
'';
};
in {

View file

@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
let
kblight = "light -s sysfs/leds/asus::kbd_backlight";
kblight = "light -s sysfs/leds/${config.me.kbBacklightDevice}";
in
{
home.packages = [ config.services.hypridle.package ];
@ -13,12 +13,13 @@ in
after_sleep_cmd = "hyprctl dispatch dpms on";
};
listener = [
listener = lib.optionals (config.me.kbBacklightDevice != null) [
{
timeout = 120;
on-timeout = "${kblight} -O && ${kblight} -S 0";
on-resume = "${kblight} -I";
}
] ++ [
{
timeout = 150;
on-timeout = "light -O && light -T 0.5";
@ -33,6 +34,7 @@ in
on-timeout = "hyprctl dispatch dpms off";
on-resume = "hyprctl dispatch dpms on";
}
] ++ lib.optionals (config.me.environment == "laptop") [
{
timeout = 600;
on-timeout = "systemctl suspend";

View file

@ -1,4 +1,4 @@
{ ... }: {
{ config, lib, ... }: {
programs.hyprlock = {
enable = true;
settings = {
@ -8,7 +8,7 @@
};
auth = {
fingerprint = {
enabled = true;
enabled = config.me.fprint;
ready_message = "Scan fingerprint to unlock";
};
};
@ -38,7 +38,7 @@
position = "-40,-10";
}
];
label = [
label = lib.optionals config.me.fprint [
# Fingerprint icon
{
monitor = "";
@ -61,17 +61,7 @@
halign = "center";
valign = "top";
}
# Fail text under input
{
monitor = "";
color = "$red";
font_family = "Open Sans";
font_size = 25;
text = "$FAIL $ATTEMPTS[]";
position = "0, -200";
halign = "center";
valign = "center";
}
] ++ lib.optionals (config.me.batteryDevice != null) [
# Battery icon
{
monitor = "";
@ -86,7 +76,7 @@
# Battery percentage
{
monitor = "";
text = ''cmd[update:60000] echo "<span weight='700'>$(cat /sys/class/power_supply/BATT/capacity)%</span>"'';
text = ''cmd[update:60000] echo "<span weight='700'>$(cat /sys/class/power_supply/${config.me.batteryDevice}/capacity)%</span>"'';
color = "$text";
font_size = 23;
font_family = "Open Sans";
@ -94,6 +84,7 @@
halign = "right";
valign = "top";
}
] ++ [
# Time and Date
{
monitor = "";
@ -105,6 +96,18 @@
position = "-70, -20";
text = ''cmd[update:1000] echo "<span alpha='70%' weight='550'>$(date '+%A, %d %B %Y')</span> <span weight='700'>$(date +%H:%M)</span><span alpha='70%' weight='550'>$(date +:%S)</span>"'';
}
# Fail text under input
{
monitor = "";
color = "$red";
font_family = "Open Sans";
font_size = 25;
text = "$FAIL $ATTEMPTS[]";
position = "0, -200";
halign = "center";
valign = "center";
}
];
input-field = {
monitor = "";

View file

@ -20,27 +20,31 @@
:focusable false
(bar))
(defvar bat-enabled _BAT_ENABLED_)
(defvar bt-enabled _BT_ENABLED_)
(defvar wifi-enabled _WIFI_ENABLED_)
(defvar bat-extended true)
(defvar bluetooth-extended false)
(defvar network-extended false)
(defvar time-extended false)
(defpoll ptime :interval "1s"
`date +%H:%M`)
(defpoll petimea :interval "1s" :run-while time-extended
`date "+%A, %d %B %Y "`)
(defpoll petimeb :interval "1s" :run-while time-extended
`date "+:%S"`)
(defpoll pbat_cap :interval "5s"
`cat /sys/class/power_supply/BATT/capacity`)
(defpoll pbat_status :interval "1s"
`cat /sys/class/power_supply/BATT/status`)
(defpoll network_strength :interval "1s"
(defpoll pbat_cap :interval "5s" :run-while bat-enabled
`cat /sys/class/power_supply/_BAT_PATH_/capacity`)
(defpoll pbat_status :interval "1s" :run-while bat-enabled
`cat /sys/class/power_supply/_BAT_PATH_/status`)
(defpoll network_strength :interval "1s" :run-while wifi-enabled
`nmcli -f IN-USE,SIGNAL device wifi | grep '*' | tr -d -c 0-9`)
(defpoll bluetooth_device :interval "1s"
(defpoll bluetooth_device :interval "1s" :run-while bt-enabled
`bluetoothctl devices Connected | grep Device | cut -d" " -f3-`)
(deflisten lnetwork :initial "" "./scripts/network.sh")
(deflisten lnetwork :initial "" :run-while wifi-enabled "./scripts/network.sh")
(deflisten ltitle :initial "" "./scripts/title.sh")
(deflisten lworkspaces :initial "[]" "./scripts/workspaces.sh")
(deflisten lcurrent_workspace :initial "1" "./scripts/active-workspace.sh")
@ -79,9 +83,9 @@
(box :orientation "horizontal"
:space-evenly false
:halign "end"
(bluetooth)
(network)
(battery)
(box :visible {bt-enabled} (bluetooth))
(box :visible {wifi-enabled} (network))
(box :visible {bat-enabled} (battery))
(time)))
(defwidget bluetooth []