Compare commits

...

2 Commits

Author SHA1 Message Date
Audrey 45d0956c6d mobile-timezone be upon ye 2025-12-30 18:25:03 -08:00
Audrey 1b73da471c tweaking dotfiles 2025-12-30 18:24:56 -08:00
9 changed files with 87 additions and 18 deletions

View File

@ -10,8 +10,6 @@ in {
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
boot.loader.efi.efiSysMountPoint = "/boot"; boot.loader.efi.efiSysMountPoint = "/boot";
time.timeZone = "America/Phoenix";
systemd.services.nix-key-setup = { systemd.services.nix-key-setup = {
description = "Generate a nix build signing key"; description = "Generate a nix build signing key";
script = '' script = ''
@ -91,7 +89,7 @@ in {
pkgs.nettools pkgs.nettools
pkgs.util-linux pkgs.util-linux
pkgs.systemd config.systemd.package
]); ]);
ZED_USE_DBUS = "1"; ZED_USE_DBUS = "1";

View File

@ -1,7 +1,7 @@
{ {
"modules-left": ["sway/workspaces", "sway/mode"], "modules-left": ["sway/workspaces", "sway/mode"],
"modules-center": ["clock"], "modules-center": ["clock"],
"modules-right": ["tray", "sway/scratchpad", "battery", "idle_inhibitor", "custom/notification", "power-profiles-daemon", "custom/power"], "modules-right": ["tray", "sway/scratchpad", "battery", "inhibitor", "custom/notification", "power-profiles-daemon", "custom/power"],
"sway/workspaces": { "sway/workspaces": {
"all-outputs": true "all-outputs": true
}, },
@ -23,12 +23,13 @@
"format-icons": ["", "", "", "", ""], "format-icons": ["", "", "", "", ""],
"max-length": 25, "max-length": 25,
"events": { "events": {
"on-discharging-low": "notify-send -u normal 'Low Battery'", "on-discharging-low": "notify-send -t 5000 -a System -i battery -u normal 'Low Battery'",
"on-discharging-warning": "notify-send -u normal 'Low Battery'", "on-discharging-warning": "notify-send -t 10000 -a System -i battery -u normal 'Very Low Battery'",
"on-discharging-critical": "notify-send -u critical 'Battery empty - system will power off soon'", "on-discharging-critical": "notify-send -a System -i battery -u critical 'Battery empty - system will power off soon'",
}, },
}, },
"idle_inhibitor": { "inhibitor": {
"what": ["idle", "sleep", "handle-lid-switch"],
"format": "{icon}", "format": "{icon}",
"format-icons": { "format-icons": {
"activated": "󰅶", "activated": "󰅶",
@ -63,7 +64,7 @@
}, },
"custom/notification": { "custom/notification": {
"tooltip": true, "tooltip": true,
"format": "<span size='10pt'>{icon}</span>", "format": "{icon}",
"format-icons": { "format-icons": {
"notification": "󱅫", "notification": "󱅫",
"none": "󰂜", "none": "󰂜",

View File

@ -61,8 +61,9 @@ window#waybar {
#custom-power, #custom-power,
#custom-menu, #custom-menu,
#power-profiles-daemon, #power-profiles-daemon,
#idle_inhibitor { #inhibitor,
padding: 0 10px; #custom-notification {
padding: 0 6px;
} }
#mode { #mode {
color: #cc3436; color: #cc3436;
@ -75,19 +76,16 @@ window#waybar {
padding: 1px 1px 1px 6px; padding: 1px 1px 1px 6px;
} }
/*-----Indicators----*/ /*-----Indicators----*/
#idle_inhibitor.activated { #inhibitor.activated {
color: #2dcc36; color: #2dcc36;
} }
#pulseaudio.muted { #pulseaudio.muted {
/*color: #cc3436;*/ /*color: #cc3436;*/
} }
#upower.charging { #battery.warning:not(.charging) {
color: #2dcc36;
}
#upower.warning:not(.charging) {
color: #e6e600; color: #e6e600;
} }
#upower.critical:not(.charging) { #battery.critical:not(.charging) {
color: #cc3436; color: #cc3436;
} }
#temperature.critical { #temperature.critical {

View File

@ -28,6 +28,7 @@
./sites/${name}/configuration.nix ./sites/${name}/configuration.nix
{ nixpkgs.buildPlatform = platform; } { nixpkgs.buildPlatform = platform; }
self.modules.audrey-sway self.modules.audrey-sway
self.modules.mobile-timezone
bingosync.nixosModules.default bingosync.nixosModules.default
#nixos-defcon.nixosModules.pkgsOverlay #nixos-defcon.nixosModules.pkgsOverlay
#nixos-defcon.nixosModules.tulip #nixos-defcon.nixosModules.tulip
@ -50,7 +51,7 @@
in builtins.listToAttrs packagesList; in builtins.listToAttrs packagesList;
modules = let modules = let
modulesFiles = builtins.attrNames (builtins.readDir ./modules); modulesFiles = builtins.attrNames (builtins.readDir ./modules);
toModulesList = filename: { name = nixpkgs.lib.strings.removeSuffix ".nix"filename; value = ./modules/${filename}; }; toModulesList = filename: { name = nixpkgs.lib.strings.removeSuffix ".nix" filename; value = ./modules/${filename}; };
modulesList = builtins.map toModulesList modulesFiles; modulesList = builtins.map toModulesList modulesFiles;
in builtins.listToAttrs modulesList; in builtins.listToAttrs modulesList;
}; };

View File

@ -0,0 +1,37 @@
{
config,
pkgs,
lib,
...
}:
let cfg = config.services.mobileTimezone;
in {
options.services.mobileTimezone = {
enable = lib.mkEnableOption "automatic mobile timezone configuration";
interface = lib.mkOption {
description = "Interface to use to fetch a public IP";
type = lib.types.str;
};
};
config = lib.mkIf cfg.enable {
assertions = [
{ assertion = config.time.timeZone == null;
message = "mobileTimezone requires mutable time zone configuration";
}
{
assertion = config.networking.networkmanager.enable;
message = "mobileTimezone requires use of NetworkManager";
}
];
networking.networkmanager.dispatcherScripts = [{
source = pkgs.writeShellScript "mobile-timezone" ''
export WIRELESS_INTERFACE="${cfg.interface}"
export PATH="${lib.strings.makeBinPath (with pkgs; [ config.systemd.package bash geoipWithDatabase sudo curl gnugrep gnused coreutils libnotify procps gawk libc ])}"
if [[ "$2" == "connectivity-change" && "$CONNECTIVITY_STATE" == "FULL" ]]; then
${./mobile-timezone.sh}
fi
'';
}];
};
}

View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e
if [[ -z "$WIRELESS_INTERFACE" ]]; then
echo "Please set \$WIRELESS_INTERFACE" >&2
exit 1
fi
CURRENT_TZ="$(timedatectl | grep 'Time zone:' | cut -d: -f2 | cut -d' ' -f2)"
NEW_TZ="$(curl -Ss --interface "$WIRELESS_INTERFACE" https://ipaddresslocation.net/ip-to-timezone | grep -o 'Time Zone:.*' | cut -d' ' -f3)"
# COORDS="$(geoiplookup "$(curl -Ss --interface "$WIRELESS_INTERFACE" https://ipconfig.io)" | grep 'GeoIP City Edition, Rev 1' | grep -oE -- '-?[[:digit:]]+\.[[:digit:]]+, -?[[:digit:]]+\.[[:digit:]]+' | sed -E -e 's@, @+@g' -e 's@^@+@g' -e 's@\+-@-@g')"
# NEW_TZ="$( (echo 1; echo 1) | tzselect -c "$COORDS")"
if [[ "$NEW_TZ" != "$CURRENT_TZ" ]]; then
timedatectl set-timezone "$NEW_TZ"
pkill -USR2 waybar 2>/dev/null || true # reload current time immediately instead of waiting for the next update
for RUNTIME in /run/user/*; do
sudo -u "#${RUNTIME#/run/user/}" XDG_RUNTIME_DIR="$RUNTIME" notify-send -i clock -t 5000 -a System "$(echo "Time zone updated to $NEW_TZ"; echo "Current time is $(date +%r)")"
done
fi

View File

@ -16,6 +16,9 @@
networking.hostName = "daisy"; networking.hostName = "daisy";
networking.hostId = "293a1290"; networking.hostId = "293a1290";
services.mobileTimezone.enable = true;
services.mobileTimezone.interface = "wlp0s20f3";
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true; hardware.bluetooth.powerOnBoot = true;
@ -139,4 +142,10 @@
enable = true; enable = true;
qemu.package = pkgs.qemu_kvm; qemu.package = pkgs.qemu_kvm;
}; };
systemd.package = pkgs.systemd.overrideAttrs (prev: {
postPatch = (prev.postPatch or "") + ''
substituteInPlace src/nspawn/nspawn.c src/basic/time-util.c --replace-fail '"../etc/zoneinfo/"' '"../etc/zoneinfo/", "zoneinfo/"'
'';
});
} }

View File

@ -23,6 +23,8 @@
]; ];
}; };
time.timeZone = "America/Phoenix";
system.stateVersion = "24.11"; system.stateVersion = "24.11";
security.sudo.wheelNeedsPassword = false; security.sudo.wheelNeedsPassword = false;

View File

@ -11,6 +11,8 @@
networking.hostName = "tulip"; networking.hostName = "tulip";
networking.hostId = "3c342abd"; networking.hostId = "3c342abd";
time.timeZone = "America/Phoenix";
system.stateVersion = "24.11"; system.stateVersion = "24.11";
security.sudo.wheelNeedsPassword = false; security.sudo.wheelNeedsPassword = false;