diff options
Diffstat (limited to 'common/modules/window_managers/dwm/scripts.nix')
| -rw-r--r-- | common/modules/window_managers/dwm/scripts.nix | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/common/modules/window_managers/dwm/scripts.nix b/common/modules/window_managers/dwm/scripts.nix deleted file mode 100644 index 25ecc19..0000000 --- a/common/modules/window_managers/dwm/scripts.nix +++ /dev/null @@ -1,113 +0,0 @@ -homeManager: -{ pkgs, lib, ... }: -let - sync_dms = pkgs.writeShellScriptBin "sync_dms" '' - jq=${pkgs.jq}/bin/jq - SETTINGS_FILE="$HOME/.config/noctalia/settings.json" - WALLPAPER_FILE="$HOME/.cache/noctalia/wallpapers.json" - - # --- Helpers --- - - get_setting() { - $jq -r "$1" "$SETTINGS_FILE" - } - - toggle_nightlight_state() { - local tmp=$(mktemp) - # Flips the boolean cleanly without changing it to a string - $jq '.nightLight.enabled = (.nightLight.enabled | not)' "$SETTINGS_FILE" > "$tmp" && mv "$tmp" "$SETTINGS_FILE" - } - - # --- Modules --- - - apply_wallpaper() { - # Read dark mode and monitor preferences from settings.json - local is_dark=$(get_setting '.colorSchemes.darkMode') - local monitor=$(get_setting '.colorSchemes.monitorForColors') - - # Default to eDP-1 if monitor setting is missing - if [[ "$monitor" == "null" || -z "$monitor" ]]; then - monitor="eDP-1" - fi - - local mode="light" - if [[ "$is_dark" == "true" ]]; then - mode="dark" - fi - - # Use jq variables to safely parse the nested monitor and mode keys - local wall=$($jq -r --arg mon "$monitor" --arg mode "$mode" '.wallpapers[$mon][$mode]' "$WALLPAPER_FILE") - - if [[ "$wall" != "null" && -n "$wall" ]]; then - ${pkgs.xwallpaper}/bin/xwallpaper --zoom "$wall" - fi - } - - apply_nightlight() { - local is_night_mode=$(get_setting '.nightLight.enabled') - local night_temp=$(get_setting '.nightLight.nightTemp') - - if [[ "$is_night_mode" == "true" ]]; then - echo "bitch $is_night_mode" - # -P resets prior adjustments, -O applies one-shot manual temperature - ${pkgs.redshift}/bin/redshift -P -O "$night_temp" - else - # -x clears all redshift adjustments - ${pkgs.redshift}/bin/redshift -x - fi - } - - sync_all() { - apply_wallpaper - apply_nightlight - } - - dmenu_settings() { - local is_night_mode=$(get_setting '.nightLight.enabled') - local options="Toggle NightMode (Currently $is_night_mode)\nSync Now" - - local choice=$(echo -e "$options" | dmenu -p "Settings:") - - case "$choice" in - *"NightMode"*) - toggle_nightlight_state - # Immediately apply the new state after toggling - apply_nightlight - ;; - "Sync Now") - sync_all - ;; - esac - } - - # --- Main --- - - case "$1" in - settings) dmenu_settings ;; - *) sync_all ;; - esac - ''; - logout_dmenu = pkgs.writeShellScriptBin "logout_dmenu" '' - options="Lock\nLogout\nReboot\nShutdown" - - choice=$(echo -e "$options" | dmenu -p "System:") - - case "$choice" in - Lock) slock ;; - Logout) pkill dwm ;; - Reboot) reboot ;; - Shutdown) poweroff ;; - *) exit 1 ;; - esac - ''; -in -{ - config = lib.mkIf homeManager ( - lib.optionalAttrs homeManager { - home.packages = with pkgs; [ - sync_dms - logout_dmenu - ]; - } - ); -} |
