Compare commits

...

2 Commits

Author SHA1 Message Date
Audrey 3999949dab mobile-timezone be upon ye 2025-12-30 18:17:33 -08:00
Audrey d1f55b61b9 tweaking dotfiles 2025-12-30 18:17:10 -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.efiSysMountPoint = "/boot";
time.timeZone = "America/Phoenix";
systemd.services.nix-key-setup = {
description = "Generate a nix build signing key";
script = ''
@ -91,7 +89,7 @@ in {
pkgs.nettools
pkgs.util-linux
pkgs.systemd
config.systemd.package
]);
ZED_USE_DBUS = "1";

View File

@ -1,7 +1,7 @@
{
"modules-left": ["sway/workspaces", "sway/mode"],
"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": {
"all-outputs": true
},
@ -23,12 +23,13 @@
"format-icons": ["", "", "", "", ""],
"max-length": 25,
"events": {
"on-discharging-low": "notify-send -u normal 'Low Battery'",
"on-discharging-warning": "notify-send -u normal 'Low Battery'",
"on-discharging-critical": "notify-send -u critical 'Battery empty - system will power off soon'",
"on-discharging-low": "notify-send -t 5000 -a System -i battery -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 -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-icons": {
"activated": "󰅶",
@ -63,7 +64,7 @@
},
"custom/notification": {
"tooltip": true,
"format": "<span size='10pt'>{icon}</span>",
"format": "{icon}",
"format-icons": {
"notification": "󱅫",
"none": "󰂜",

View File

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

View File

@ -28,6 +28,7 @@
./sites/${name}/configuration.nix
{ nixpkgs.buildPlatform = platform; }
self.modules.audrey-sway
self.modules.mobile-timezone
bingosync.nixosModules.default
#nixos-defcon.nixosModules.pkgsOverlay
#nixos-defcon.nixosModules.tulip
@ -50,7 +51,7 @@
in builtins.listToAttrs packagesList;
modules = let
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;
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.hostId = "293a1290";
services.mobileTimezone.enable = true;
services.mobileTimezone.interface = "wlp0s20f3";
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
@ -139,4 +142,10 @@
enable = true;
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";
security.sudo.wheelNeedsPassword = false;

View File

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