diff --git a/flake.lock b/flake.lock index 0f4e29a..fd97db6 100644 --- a/flake.lock +++ b/flake.lock @@ -595,6 +595,7 @@ "nixpkgs": "nixpkgs_2", "nvf": "nvf", "rust-overlay": "rust-overlay_2", + "zen-browser": "zen-browser", "zig": "zig", "zls": "zls" } @@ -845,6 +846,26 @@ "type": "github" } }, + "zen-browser": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1748059546, + "narHash": "sha256-e0jy8RU8ofOdeS5gF9Hir+M5Wn0q7D8MkpeQXsOJdu4=", + "owner": "youwen5", + "repo": "zen-browser-flake", + "rev": "716a5af28d686d67146d01b14112c919b6133a84", + "type": "github" + }, + "original": { + "owner": "youwen5", + "repo": "zen-browser-flake", + "type": "github" + } + }, "zig": { "inputs": { "flake-compat": "flake-compat", diff --git a/flake.nix b/flake.nix index c07de41..c0754a5 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,10 @@ moonlight.url = "github:moonlight-mod/moonlight"; # Add `/develop` to the flake URL to use nightly. moonlight.inputs.nixpkgs.follows = "nixpkgs"; + zen-browser = { + url = "github:youwen5/zen-browser-flake"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nh.url = "github:viperML/nh"; nh.inputs.nixpkgs.follows = "nixpkgs"; @@ -37,76 +41,79 @@ nix-index-database.url = "github:nix-community/nix-index-database"; nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { - self, - nixpkgs, - lix-module, - darwin, - ... - } @ inputs: let - lib = nixpkgs.lib; - # TODO: apply these overlays sooner and remove uses of legacyPackages elsewhere. - overlays = [ - inputs.zig.overlays.default - inputs.rust-overlay.overlays.default - inputs.nh.overlays.default + outputs = + { + self, + nixpkgs, + lix-module, + darwin, + ... + }@inputs: + let + lib = nixpkgs.lib; + # TODO: apply these overlays sooner and remove uses of legacyPackages elsewhere. + overlays = [ + inputs.zig.overlays.default + inputs.rust-overlay.overlays.default + inputs.nh.overlays.default - # https://github.com/LnL7/nix-darwin/issues/1041 - (_: prev: { - karabiner-elements = prev.karabiner-elements.overrideAttrs (old: { - version = "14.13.0"; + # https://github.com/LnL7/nix-darwin/issues/1041 + (_: prev: { + karabiner-elements = prev.karabiner-elements.overrideAttrs (old: { + version = "14.13.0"; - src = prev.fetchurl { - inherit (old.src) url; - hash = "sha256-gmJwoht/Tfm5qMecmq1N6PSAIfWOqsvuHU8VDJY8bLw="; - }; - }); - }) - ]; - - # Users of this flake currently use x86_64 Linux and Apple Silicon - systems = [ - "x86_64-linux" - "aarch64-darwin" - ]; - forAllSystems = f: - builtins.listToAttrs ( - builtins.map (system: { - name = system; - value = f ( - inputs - // { - inherit system; - pkgs = nixpkgs.legacyPackages.${system}; - } - ); + src = prev.fetchurl { + inherit (old.src) url; + hash = "sha256-gmJwoht/Tfm5qMecmq1N6PSAIfWOqsvuHU8VDJY8bLw="; + }; + }); }) - systems - ); + ]; - mkSystem = import ./lib/mkSystem.nix { - inherit - overlays - nixpkgs - lix-module - inputs - mkNeovim - ; - }; - mkNeovim = import ./lib/mkNeovim.nix { - inherit - self - overlays - nixpkgs - inputs - ; - }; - in rec { - inherit self; - # "nix fmt" - formatter = forAllSystems (inputs: inputs.pkgs.nixfmt-tree); - packages = forAllSystems ( - {system, ...}: + # Users of this flake currently use x86_64 Linux and Apple Silicon + systems = [ + "x86_64-linux" + "aarch64-darwin" + ]; + forAllSystems = + f: + builtins.listToAttrs ( + builtins.map (system: { + name = system; + value = f ( + inputs + // { + inherit system; + pkgs = nixpkgs.legacyPackages.${system}; + } + ); + }) systems + ); + + mkSystem = import ./lib/mkSystem.nix { + inherit + overlays + nixpkgs + lix-module + inputs + mkNeovim + ; + }; + mkNeovim = import ./lib/mkNeovim.nix { + inherit + self + overlays + nixpkgs + inputs + ; + }; + in + rec { + inherit self; + # "nix fmt" + formatter = forAllSystems (inputs: inputs.pkgs.nixfmt-tree); + packages = forAllSystems ( + { system, ... }: { nvim-chloe = mkNeovim "chloe" system; nvim-natalie = mkNeovim "natalie" system; @@ -115,46 +122,48 @@ # "nix run .#darwin-rebuild" darwin-rebuild = darwin.packages.aarch64-darwin.darwin-rebuild; } - ); + ); - # natalie's desktop computer - nixosConfigurations.nixos = mkSystem "nixos" { - user = "natalie"; - host = "desktop"; - system = "x86_64-linux"; - extraModules = [ - ]; - }; - # natalie's laptop - darwinConfigurations."Natalies-MacBook-Air" = mkSystem "Natalies-MacBook-Air" { - user = "natalie"; - host = "laptop"; - system = "aarch64-darwin"; - }; + # natalie's desktop computer + nixosConfigurations.nixos = mkSystem "nixos" { + user = "natalie"; + host = "desktop"; + system = "x86_64-linux"; + extraModules = [ + ]; + }; + # natalie's laptop + darwinConfigurations."Natalies-MacBook-Air" = mkSystem "Natalies-MacBook-Air" { + user = "natalie"; + host = "laptop"; + system = "aarch64-darwin"; + }; - # chloe's mac studio "sandwich" - darwinConfigurations.sandwich = mkSystem "sandwich" { - user = "chloe"; - host = "sandwich"; - system = "aarch64-darwin"; - }; - # chloe's macbook air "paperback" - darwinConfigurations.paperback = mkSystem "paperback" { - user = "chloe"; - host = "paperback"; - system = "aarch64-darwin"; - }; + # chloe's mac studio "sandwich" + darwinConfigurations.sandwich = mkSystem "sandwich" { + user = "chloe"; + host = "sandwich"; + system = "aarch64-darwin"; + }; + # chloe's macbook air "paperback" + darwinConfigurations.paperback = mkSystem "paperback" { + user = "chloe"; + host = "paperback"; + system = "aarch64-darwin"; + }; - # generate checks for "nix flake check --all-systems --no-build" - checks.aarch64-darwin = builtins.listToAttrs ( - builtins.map ( - name: let - d = darwinConfigurations.${name}.system; - in { - name = "darwinConfiguration-" + d.name; - value = d; - } - ) (builtins.attrNames darwinConfigurations) - ); - }; + # generate checks for "nix flake check --all-systems --no-build" + checks.aarch64-darwin = builtins.listToAttrs ( + builtins.map ( + name: + let + d = darwinConfigurations.${name}.system; + in + { + name = "darwinConfiguration-" + d.name; + value = d; + } + ) (builtins.attrNames darwinConfigurations) + ); + }; } diff --git a/lib/mkNeovim.nix b/lib/mkNeovim.nix index 5602fae..72e6d9c 100644 --- a/lib/mkNeovim.nix +++ b/lib/mkNeovim.nix @@ -4,7 +4,9 @@ # TODO: apply overlays here overlays, inputs, -}: user: system: let +}: +user: system: +let darwin = nixpkgs.lib.strings.hasSuffix "-darwin" system; host = { @@ -15,15 +17,15 @@ userDir = ../users + "/${user}"; userConfig = import (userDir + "/user.nix"); in - (inputs.nvf.lib.neovimConfiguration { - pkgs = nixpkgs.legacyPackages.${system}; - modules = builtins.filter (f: f != null) [ - (../users + ("/" + user + "/vim.nix")) - ../modules/neovim - ]; - extraSpecialArgs = { - inherit host; - flake = self; - user = userConfig; - }; - }).neovim +(inputs.nvf.lib.neovimConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + modules = builtins.filter (f: f != null) [ + (../users + ("/" + user + "/vim.nix")) + ../modules/neovim + ]; + extraSpecialArgs = { + inherit host; + flake = self; + user = userConfig; + }; +}).neovim diff --git a/modules/home/default.nix b/modules/home/default.nix index addf68f..98635b4 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -8,14 +8,14 @@ host, mainHomeImports, ... -}: let +}: +let cfg = config.programs; -in { - imports = - mainHomeImports - ++ [ - ./macos/sketchybar.nix - ]; +in +{ + imports = mainHomeImports ++ [ + ./macos/sketchybar.nix + ]; programs = { home-manager.enable = true; nix-index.enable = true; @@ -80,7 +80,7 @@ in { } ]; shellAliases = - {} + { } // lib.optionalAttrs (!host.darwin) { reboot-windows = "sudo efibootmgr --bootnext 0000; sudo reboot -h now"; }; diff --git a/modules/home/macos/sketchybar.nix b/modules/home/macos/sketchybar.nix index 38695d3..f42a1f0 100644 --- a/modules/home/macos/sketchybar.nix +++ b/modules/home/macos/sketchybar.nix @@ -4,536 +4,539 @@ config, host, ... -}: { +}: +{ home.file = - {} + { } // lib.optionalAttrs host.darwin ( - lib.attrsets.mapAttrs (file: value: ( - lib.attrsets.overrideExisting value {enable = config.shared.darwin.tiling.enable;} - )) { - sketchybarrc = { - executable = true; - target = ".config/sketchybar/sketchybarrc"; - text = '' - #!/usr/bin/env sh + lib.attrsets.mapAttrs + ( + file: value: (lib.attrsets.overrideExisting value { enable = config.shared.darwin.tiling.enable; }) + ) + { + sketchybarrc = { + executable = true; + target = ".config/sketchybar/sketchybarrc"; + text = '' + #!/usr/bin/env sh - source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors + source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors - ITEM_DIR="$HOME/.config/sketchybar/items" # Directory where the items are configured - PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # Directory where all the plugin scripts are stored + ITEM_DIR="$HOME/.config/sketchybar/items" # Directory where the items are configured + PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # Directory where all the plugin scripts are stored - FONT="SF Pro" # Needs to have Regular, Bold, Semibold, Heavy and Black variants - PADDINGS=3 # All paddings use this value (icon, label, background) + FONT="SF Pro" # Needs to have Regular, Bold, Semibold, Heavy and Black variants + PADDINGS=3 # All paddings use this value (icon, label, background) - # Setting up the general bar appearance and default values - ${pkgs.sketchybar}/bin/sketchybar --bar height=40 \ - blur_radius=30 \ - position=top \ - sticky=on \ - padding_left=10 \ - padding_right=10 + # Setting up the general bar appearance and default values + ${pkgs.sketchybar}/bin/sketchybar --bar height=40 \ + blur_radius=30 \ + position=top \ + sticky=on \ + padding_left=10 \ + padding_right=10 - ${pkgs.sketchybar}/bin/sketchybar --default icon.font="SF Pro:Semibold:12.0" \ - icon.color=$ITEM_COLOR \ - label.font="SF Pro:Semibold:12.0" \ - label.color=$ITEM_COLOR \ - background.color=$ACCENT_COLOR \ - background.corner_radius=10 \ - background.height=20 \ - padding_left=4 \ - padding_right=4 \ - icon.padding_left=6 \ - icon.padding_right=3 \ - label.padding_left=3 \ - label.padding_right=6 + ${pkgs.sketchybar}/bin/sketchybar --default icon.font="SF Pro:Semibold:12.0" \ + icon.color=$ITEM_COLOR \ + label.font="SF Pro:Semibold:12.0" \ + label.color=$ITEM_COLOR \ + background.color=$ACCENT_COLOR \ + background.corner_radius=10 \ + background.height=20 \ + padding_left=4 \ + padding_right=4 \ + icon.padding_left=6 \ + icon.padding_right=3 \ + label.padding_left=3 \ + label.padding_right=6 - # Left - # source "$ITEM_DIR/apple.sh" - source "$ITEM_DIR/spaces.sh" - source "$ITEM_DIR/front_app.sh" + # Left + # source "$ITEM_DIR/apple.sh" + source "$ITEM_DIR/spaces.sh" + source "$ITEM_DIR/front_app.sh" - # Center - # source "$ITEM_DIR/spotify.sh" - source "$ITEM_DIR/calendar.sh" + # Center + # source "$ITEM_DIR/spotify.sh" + source "$ITEM_DIR/calendar.sh" - # Right - source $ITEM_DIR/calendar.sh - source $ITEM_DIR/wifi.sh - source $ITEM_DIR/battery.sh - source $ITEM_DIR/volume.sh + # Right + source $ITEM_DIR/calendar.sh + source $ITEM_DIR/wifi.sh + source $ITEM_DIR/battery.sh + source $ITEM_DIR/volume.sh - # Forcing all item scripts to run (never do this outside of sketchybarrc) - ${pkgs.sketchybar}/bin/sketchybar --update + # Forcing all item scripts to run (never do this outside of sketchybarrc) + ${pkgs.sketchybar}/bin/sketchybar --update - echo "sketchybar configuation loaded.." - ''; - }; - icons = { - executable = true; - target = ".config/sketchybar/plugins/icons.sh"; - text = '' - #!/usr/bin/env sh + echo "sketchybar configuation loaded.." + ''; + }; + icons = { + executable = true; + target = ".config/sketchybar/plugins/icons.sh"; + text = '' + #!/usr/bin/env sh - # Source the icon map with all the application icons - source ${pkgs.sketchybar-app-font}/bin/icon_map.sh + # Source the icon map with all the application icons + source ${pkgs.sketchybar-app-font}/bin/icon_map.sh - # Create a cache directory if it doesn't exist - CACHE_DIR="$HOME/.cache/sketchybar" - mkdir -p "$CACHE_DIR" + # Create a cache directory if it doesn't exist + CACHE_DIR="$HOME/.cache/sketchybar" + mkdir -p "$CACHE_DIR" - # Cache file for icon mappings - ICON_CACHE="$CACHE_DIR/icon_cache.txt" + # Cache file for icon mappings + ICON_CACHE="$CACHE_DIR/icon_cache.txt" - # Create the cache file if it doesn't exist - if [ ! -f "$ICON_CACHE" ]; then - touch "$ICON_CACHE" - fi - - # Check if the app is already in cache - APP_NAME=$(if [ "$1" = "Zen" ]; then echo "Zen Browser"; else echo "$1"; fi) - - CACHED_ICON=$(grep "^$APP_NAME|" "$ICON_CACHE" | cut -d '|' -f2) - - if [ -n "$CACHED_ICON" ]; then - # Cache hit, return the icon - echo "$CACHED_ICON" - exit 0 - fi - - # Get icon from the mapping function - __icon_map "$APP_NAME" - - if [ -n "$icon_result" ]; then - echo "$APP_NAME|$icon_result" >>"$ICON_CACHE" - fi - - echo "$icon_result" - ''; - }; - colors = { - executable = true; - target = ".config/sketchybar/colors.sh"; - text = '' - - export TRANSPARENT=0x00ffffff - - # -- Gray Scheme -- - export ITEM_COLOR=0xff000000 - export ACCENT_COLOR=0xffc3c6cb - - # -- White Scheme -- - # export ITEM_COLOR=0xff000000 - # export ACCENT_COLOR=0xffffffff - - # -- Teal Scheme -- - # export ITEM_COLOR=0xff000000 - # export ACCENT_COLOR=0xff2cf9ed - - # -- Purple Scheme -- - # export ITEM_COLOR=0xff000000 - # export ACCENT_COLOR=0xffeb46f9 - - # -- Red Scheme --- - # export ITEM_COLOR=0xff000000 - # export ACCENT_COLOR=0xffff2453 - - # -- Blue Scheme --- - # export ITEM_COLOR=0xff000000 - # export ACCENT_COLOR=0xff15bdf9 - - # -- Green Scheme -- - # export ITEM_COLOR=0xff000000 - # export ACCENT_COLOR=0xff1dfca1 - - # -- Orange Scheme -- - # export ITEM_COLOR=0xffffffff - # export ACCENT_COLOR=0xfff97716 - - # -- Yellow Scheme -- - # export ITEM_COLOR=0xff000000 - # export ACCENT_COLOR=0xfff7fc17 - ''; - }; - items_wifi = { - executable = true; - target = ".config/sketchybar/items/wifi.sh"; - text = '' - #!/usr/bin/env/ sh - - sketchybar --add item wifi right \ - --set wifi \ - icon="􀙥" \ - label="Updating..." \ - script="$PLUGIN_DIR/wifi.sh" \ - --subscribe wifi wifi_change - ''; - }; - items_battery = { - executable = true; - target = ".config/sketchybar/items/battery.sh"; - text = '' - #!/usr/bin/env/ sh - sketchybar --add item battery right \ - --set battery update_freq=180 \ - script="$PLUGIN_DIR/battery.sh" \ - --subscribe battery system_woke power_source_change - ''; - }; - items_calendar = { - executable = true; - target = ".config/sketchybar/items/calendar.sh"; - text = '' - #!/usr/bin/env sh - sketchybar --add item calendar right \ - --set calendar icon=􀧞 \ - update_freq=15 \ - script="$PLUGIN_DIR/calendar.sh" - ''; - }; - items_front_app = { - executable = true; - target = ".config/sketchybar/items/front_app.sh"; - text = '' - #!/usr/bin/env sh - - sketchybar --add item front_app left \ - --set front_app background.color=$ACCENT_COLOR \ - icon.color=$ITEM_COLOR \ - label.color=$ITEM_COLOR \ - icon.font="sketchybar-app-font:Regular:12.0" \ - label.font="SF Pro:Semibold:12.0" \ - script="$PLUGIN_DIR/front_app.sh" \ - --subscribe front_app front_app_switched - ''; - }; - items_spaces = { - executable = true; - target = ".config/sketchybar/items/spaces.sh"; - text = '' - sketchybar --add event aerospace_workspace_change - - sketchybar --add item aerospace_dummy left \ - --set aerospace_dummy display=0 \ - script="$PLUGIN_DIR/spaces.sh" \ - --subscribe aerospace_dummy aerospace_workspace_change - - for m in $(aerospace list-monitors | awk '{print $1}'); do - for sid in $(aerospace list-workspaces --monitor $m); do - sketchybar --add space space.$sid left \ - --set space.$sid space=$sid \ - icon=$sid \ - background.color=$TRANSPARENT \ - label.color=$ACCENT_COLOR \ - icon.color=$ACCENT_COLOR \ - display=$m \ - label.font="sketchybar-app-font:Regular:12.0" \ - icon.font="SF Pro:Semibold:12.0" \ - label.padding_right=10 \ - label.y_offset=-1 \ - click_script="$PLUGIN_DIR/space_click.sh $sid" - - apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" | - awk -F '|' '{gsub(/^ *| *$/, "", $2); if (!seen[$2]++) print $2}') - - icon_strip="" - if [ "''${apps}" != "" ]; then - while read -r app; do - icon_strip+=" $($PLUGIN_DIR/icons.sh "$app")" - done <<<"''${apps}" - else - icon_strip=" —" - fi - - sketchybar --set space.$sid label="$icon_strip" - - done - - for empty_space in $(aerospace list-workspaces --monitor $m --empty); do - sketchybar --set space.$empty_space display=0 - done - for focus in $(aerospace list-workspaces --focused); do - sketchybar --set space.$focus background.drawing=on \ - background.color=$ACCENT_COLOR \ - label.color=$ITEM_COLOR \ - icon.color=$ITEM_COLOR - done - done - ''; - }; - - items_volume = { - executable = true; - target = ".config/sketchybar/items/volume.sh"; - text = '' - #/usr/bin/env sh - - sketchybar --add item volume right \ - --set volume script="$PLUGIN_DIR/volume.sh" \ - --subscribe volume volume_change - ''; - }; - plugins_wifi = { - executable = true; - target = ".config/sketchybar/plugins/wifi.sh"; - text = '' - #/usr/bin/env sh - - SSID=$(system_profiler SPAirPortDataType | awk '/Current Network Information:/ { getline; print substr($0, 13, (length($0) - 13)); exit }') - - if [ "$SSID" = "" ]; then - sketchybar --set $NAME icon="􀙈" label="Disconnected" - else - sketchybar --set $NAME icon="􀙇" label="$SSID" - fi - - ''; - }; - plugins_calendar = { - executable = true; - target = ".config/sketchybar/plugins/calendar.sh"; - - text = '' - #/usr/bin/env sh - - sketchybar --set $NAME label="$(date +'%a %d %b %I:%M %p')" - ''; - }; - plugins_spaces = { - executable = true; - target = ".config/sketchybar/plugins/spaces.sh"; - text = '' - #!/usr/bin/env sh - - source "$CONFIG_DIR/colors.sh" - - update_workspace_appearance() { - local sid=$1 - local is_focused=$2 - - if [ "$is_focused" = "true" ]; then - sketchybar --set space.$sid background.drawing=on \ - background.color=$ACCENT_COLOR \ - label.color=$ITEM_COLOR \ - icon.color=$ITEM_COLOR - else - sketchybar --set space.$sid background.drawing=off \ - label.color=$ACCENT_COLOR \ - icon.color=$ACCENT_COLOR - fi - } - - update_icons() { - m=$1 - sid=$2 - - apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" \ - | awk -F '|' '{gsub(/^ *| *$/, "", $2); if (!seen[$2]++) print $2}' \ - | sort) - - icon_strip="" - if [ "''${apps}" != "" ]; then - while read -r app; do - icon_strip+=" $($CONFIG_DIR/plugins/icons.sh "$app")" - done <<<"''${apps}" - else - icon_strip=" —" + # Create the cache file if it doesn't exist + if [ ! -f "$ICON_CACHE" ]; then + touch "$ICON_CACHE" fi - sketchybar --animate sin 10 --set space.$sid label="$icon_strip" - } + # Check if the app is already in cache + APP_NAME=$(if [ "$1" = "Zen" ]; then echo "Zen Browser"; else echo "$1"; fi) - update_workspace_appearance "$PREV_WORKSPACE" "false" - update_workspace_appearance "$FOCUSED_WORKSPACE" "true" + CACHED_ICON=$(grep "^$APP_NAME|" "$ICON_CACHE" | cut -d '|' -f2) - for m in $(aerospace list-monitors | awk '{print $1}'); do - for sid in $(aerospace list-workspaces --monitor $m --visible); do - sketchybar --set space.$sid display=$m + if [ -n "$CACHED_ICON" ]; then + # Cache hit, return the icon + echo "$CACHED_ICON" + exit 0 + fi - update_icons "$m" "$sid" + # Get icon from the mapping function + __icon_map "$APP_NAME" - update_icons "$m" "$PREV_WORKSPACE" + if [ -n "$icon_result" ]; then + echo "$APP_NAME|$icon_result" >>"$ICON_CACHE" + fi - apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" | wc -l) - if [ "''${apps}" -eq 0 ]; then - sketchybar --set space.$sid display=0 - fi - done - done - ''; - }; + echo "$icon_result" + ''; + }; + colors = { + executable = true; + target = ".config/sketchybar/colors.sh"; + text = '' - plugins_space_click = { - executable = true; - target = ".config/sketchybar/plugins/space_click.sh"; - text = '' - #/usr/bin/env/ sh + export TRANSPARENT=0x00ffffff - apps=$(aerospace list-windows --workspace $1 | awk -F '|' '{gsub(/^ *| *$/, "", $2); print $2}') - focused=$(aerospace list-workspaces --focused) + # -- Gray Scheme -- + export ITEM_COLOR=0xff000000 + export ACCENT_COLOR=0xffc3c6cb - if [ "''${apps}" = "" ] && [ "''${focused}" != "$1" ]; then - sketchybar --set space.$1 display=0 - else - aerospace workspace $1 - fi - ''; - }; - plugins_volume = { - executable = true; - target = ".config/sketchybar/plugins/volume.sh"; - text = '' - #!/usr/bin/env sh + # -- White Scheme -- + # export ITEM_COLOR=0xff000000 + # export ACCENT_COLOR=0xffffffff - # The volume_change event supplies a $INFO variable in which the current volume - # percentage is passed to the script. + # -- Teal Scheme -- + # export ITEM_COLOR=0xff000000 + # export ACCENT_COLOR=0xff2cf9ed - if [ "$SENDER" = "volume_change" ]; then + # -- Purple Scheme -- + # export ITEM_COLOR=0xff000000 + # export ACCENT_COLOR=0xffeb46f9 - VOLUME=$INFO + # -- Red Scheme --- + # export ITEM_COLOR=0xff000000 + # export ACCENT_COLOR=0xffff2453 - case $VOLUME in - [6-9][0-9] | 100) - ICON="􀊩" - ;; - [3-5][0-9]) - ICON="􀊥" - ;; - [1-9] | [1-2][0-9]) - ICON="􀊡" - ;; - *) ICON="􀊣" ;; - esac + # -- Blue Scheme --- + # export ITEM_COLOR=0xff000000 + # export ACCENT_COLOR=0xff15bdf9 - sketchybar --set $NAME icon="$ICON" label="$VOLUME%" - fi - ''; - }; - plugins_front_app = { - executable = true; - target = ".config/sketchybar/plugins/front_app.sh"; - text = '' - # Some events send additional information specific to the event in the $INFO - # variable. E.g. the front_app_switched event sends the name of the newly - # focused application in the $INFO variable: - # https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting + # -- Green Scheme -- + # export ITEM_COLOR=0xff000000 + # export ACCENT_COLOR=0xff1dfca1 + + # -- Orange Scheme -- + # export ITEM_COLOR=0xffffffff + # export ACCENT_COLOR=0xfff97716 + + # -- Yellow Scheme -- + # export ITEM_COLOR=0xff000000 + # export ACCENT_COLOR=0xfff7fc17 + ''; + }; + items_wifi = { + executable = true; + target = ".config/sketchybar/items/wifi.sh"; + text = '' + #!/usr/bin/env/ sh + + sketchybar --add item wifi right \ + --set wifi \ + icon="􀙥" \ + label="Updating..." \ + script="$PLUGIN_DIR/wifi.sh" \ + --subscribe wifi wifi_change + ''; + }; + items_battery = { + executable = true; + target = ".config/sketchybar/items/battery.sh"; + text = '' + #!/usr/bin/env/ sh + sketchybar --add item battery right \ + --set battery update_freq=180 \ + script="$PLUGIN_DIR/battery.sh" \ + --subscribe battery system_woke power_source_change + ''; + }; + items_calendar = { + executable = true; + target = ".config/sketchybar/items/calendar.sh"; + text = '' + #!/usr/bin/env sh + sketchybar --add item calendar right \ + --set calendar icon=􀧞 \ + update_freq=15 \ + script="$PLUGIN_DIR/calendar.sh" + ''; + }; + items_front_app = { + executable = true; + target = ".config/sketchybar/items/front_app.sh"; + text = '' + #!/usr/bin/env sh + + sketchybar --add item front_app left \ + --set front_app background.color=$ACCENT_COLOR \ + icon.color=$ITEM_COLOR \ + label.color=$ITEM_COLOR \ + icon.font="sketchybar-app-font:Regular:12.0" \ + label.font="SF Pro:Semibold:12.0" \ + script="$PLUGIN_DIR/front_app.sh" \ + --subscribe front_app front_app_switched + ''; + }; + items_spaces = { + executable = true; + target = ".config/sketchybar/items/spaces.sh"; + text = '' + sketchybar --add event aerospace_workspace_change + + sketchybar --add item aerospace_dummy left \ + --set aerospace_dummy display=0 \ + script="$PLUGIN_DIR/spaces.sh" \ + --subscribe aerospace_dummy aerospace_workspace_change - app_switched() { for m in $(aerospace list-monitors | awk '{print $1}'); do - for sid in $(aerospace list-workspaces --monitor $m --visible); do + for sid in $(aerospace list-workspaces --monitor $m); do + sketchybar --add space space.$sid left \ + --set space.$sid space=$sid \ + icon=$sid \ + background.color=$TRANSPARENT \ + label.color=$ACCENT_COLOR \ + icon.color=$ACCENT_COLOR \ + display=$m \ + label.font="sketchybar-app-font:Regular:12.0" \ + icon.font="SF Pro:Semibold:12.0" \ + label.padding_right=10 \ + label.y_offset=-1 \ + click_script="$PLUGIN_DIR/space_click.sh $sid" - apps=$( (echo "$INFO"; aerospace list-windows --monitor "$m" --workspace "$sid" \ - | awk -F '|' '{gsub(/^ *| *$/, "", $2); print $2}') \ - | awk '!seen[$0]++' | sort) + apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" | + awk -F '|' '{gsub(/^ *| *$/, "", $2); if (!seen[$2]++) print $2}') icon_strip="" if [ "''${apps}" != "" ]; then while read -r app; do - icon_strip+=" $($CONFIG_DIR/plugins/icons.sh "$app")" + icon_strip+=" $($PLUGIN_DIR/icons.sh "$app")" done <<<"''${apps}" else icon_strip=" —" fi - sketchybar --animate sin 10 --set space.$sid label="$icon_strip" + sketchybar --set space.$sid label="$icon_strip" + + done + + for empty_space in $(aerospace list-workspaces --monitor $m --empty); do + sketchybar --set space.$empty_space display=0 + done + for focus in $(aerospace list-workspaces --focused); do + sketchybar --set space.$focus background.drawing=on \ + background.color=$ACCENT_COLOR \ + label.color=$ITEM_COLOR \ + icon.color=$ITEM_COLOR done done - } + ''; + }; - if [ "$SENDER" = "front_app_switched" ]; then + items_volume = { + executable = true; + target = ".config/sketchybar/items/volume.sh"; + text = '' + #/usr/bin/env sh - sketchybar --set $NAME label="$INFO" icon="$($CONFIG_DIR/plugins/icons.sh "$INFO")" + sketchybar --add item volume right \ + --set volume script="$PLUGIN_DIR/volume.sh" \ + --subscribe volume volume_change + ''; + }; + plugins_wifi = { + executable = true; + target = ".config/sketchybar/plugins/wifi.sh"; + text = '' + #/usr/bin/env sh - app_switched - fi - ''; - }; - plugins_battery = { - executable = true; - target = ".config/sketchybar/plugins/battery.sh"; - text = '' - #!/usr/bin/env sh - source "$CONFIG_DIR/colors.sh" + SSID=$(system_profiler SPAirPortDataType | awk '/Current Network Information:/ { getline; print substr($0, 13, (length($0) - 13)); exit }') - PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) - CHARGING=$(pmset -g batt | grep 'AC Power') + if [ "$SSID" = "" ]; then + sketchybar --set $NAME icon="􀙈" label="Disconnected" + else + sketchybar --set $NAME icon="􀙇" label="$SSID" + fi - if [ $PERCENTAGE = "" ]; then - exit 0 - fi + ''; + }; + plugins_calendar = { + executable = true; + target = ".config/sketchybar/plugins/calendar.sh"; - case ''${PERCENTAGE} in - 9[0-9] | 100) - ICON="􀛨" - COLOR=$ITEM_COLOR - ;; - [6-8][0-9]) - ICON="􀺸" - COLOR=$ITEM_COLOR - ;; - [3-5][0-9]) - ICON="􀺶" - COLOR="0xFFd97706" - ;; - [1-2][0-9]) - ICON="􀛩" - COLOR="0xFFf97316" - ;; - *) - ICON="􀛪" - COLOR="0xFFef4444" - ;; - esac + text = '' + #/usr/bin/env sh - if [[ $CHARGING != "" ]]; then - ICON="􀢋" - COLOR=$ITEM_COLOR - fi + sketchybar --set $NAME label="$(date +'%a %d %b %I:%M %p')" + ''; + }; + plugins_spaces = { + executable = true; + target = ".config/sketchybar/plugins/spaces.sh"; + text = '' + #!/usr/bin/env sh - # The item invoking this script (name $NAME) will get its icon and label - # updated with the current battery status - sketchybar --set $NAME icon="$ICON" label="''${PERCENTAGE}%" icon.color="$COLOR" - ''; - }; - plugins_aerospace = { - executable = true; - target = ".config/sketchybar/plugins/aerospace.sh"; - text = '' - #!/usr/bin/env bash - source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors + source "$CONFIG_DIR/colors.sh" - highlight_focused_workspace() { - if [[ "$1" = "$FOCUSED_WORKSPACE" ]] - then - ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=on label.width=0 + update_workspace_appearance() { + local sid=$1 + local is_focused=$2 + + if [ "$is_focused" = "true" ]; then + sketchybar --set space.$sid background.drawing=on \ + background.color=$ACCENT_COLOR \ + label.color=$ITEM_COLOR \ + icon.color=$ITEM_COLOR + else + sketchybar --set space.$sid background.drawing=off \ + label.color=$ACCENT_COLOR \ + icon.color=$ACCENT_COLOR + fi + } + + update_icons() { + m=$1 + sid=$2 + + apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" \ + | awk -F '|' '{gsub(/^ *| *$/, "", $2); if (!seen[$2]++) print $2}' \ + | sort) + + icon_strip="" + if [ "''${apps}" != "" ]; then + while read -r app; do + icon_strip+=" $($CONFIG_DIR/plugins/icons.sh "$app")" + done <<<"''${apps}" + else + icon_strip=" —" + fi + + sketchybar --animate sin 10 --set space.$sid label="$icon_strip" + } + + update_workspace_appearance "$PREV_WORKSPACE" "false" + update_workspace_appearance "$FOCUSED_WORKSPACE" "true" + + for m in $(aerospace list-monitors | awk '{print $1}'); do + for sid in $(aerospace list-workspaces --monitor $m --visible); do + sketchybar --set space.$sid display=$m + + update_icons "$m" "$sid" + + update_icons "$m" "$PREV_WORKSPACE" + + apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" | wc -l) + if [ "''${apps}" -eq 0 ]; then + sketchybar --set space.$sid display=0 + fi + done + done + ''; + }; + + plugins_space_click = { + executable = true; + target = ".config/sketchybar/plugins/space_click.sh"; + text = '' + #/usr/bin/env/ sh + + apps=$(aerospace list-windows --workspace $1 | awk -F '|' '{gsub(/^ *| *$/, "", $2); print $2}') + focused=$(aerospace list-workspaces --focused) + + if [ "''${apps}" = "" ] && [ "''${focused}" != "$1" ]; then + sketchybar --set space.$1 display=0 else - ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=off label.width=dynamic + aerospace workspace $1 fi - } + ''; + }; + plugins_volume = { + executable = true; + target = ".config/sketchybar/plugins/volume.sh"; + text = '' + #!/usr/bin/env sh - illuminate_mode() { - if [[ "$mode" = "service" ]] - then - ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$ORANGE - elif [[ "$mode" = "resize" ]] - then - ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$GREEN - else - ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$BACKGROUND_1 + # The volume_change event supplies a $INFO variable in which the current volume + # percentage is passed to the script. + + if [ "$SENDER" = "volume_change" ]; then + + VOLUME=$INFO + + case $VOLUME in + [6-9][0-9] | 100) + ICON="􀊩" + ;; + [3-5][0-9]) + ICON="􀊥" + ;; + [1-9] | [1-2][0-9]) + ICON="􀊡" + ;; + *) ICON="􀊣" ;; + esac + + sketchybar --set $NAME icon="$ICON" label="$VOLUME%" fi - } - case "$SENDER" in - "aerospace_workspace_change") - highlight_focused_workspace $1 + ''; + }; + plugins_front_app = { + executable = true; + target = ".config/sketchybar/plugins/front_app.sh"; + text = '' + # Some events send additional information specific to the event in the $INFO + # variable. E.g. the front_app_switched event sends the name of the newly + # focused application in the $INFO variable: + # https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting + + app_switched() { + for m in $(aerospace list-monitors | awk '{print $1}'); do + for sid in $(aerospace list-workspaces --monitor $m --visible); do + + apps=$( (echo "$INFO"; aerospace list-windows --monitor "$m" --workspace "$sid" \ + | awk -F '|' '{gsub(/^ *| *$/, "", $2); print $2}') \ + | awk '!seen[$0]++' | sort) + + icon_strip="" + if [ "''${apps}" != "" ]; then + while read -r app; do + icon_strip+=" $($CONFIG_DIR/plugins/icons.sh "$app")" + done <<<"''${apps}" + else + icon_strip=" —" + fi + + sketchybar --animate sin 10 --set space.$sid label="$icon_strip" + done + done + } + + if [ "$SENDER" = "front_app_switched" ]; then + + sketchybar --set $NAME label="$INFO" icon="$($CONFIG_DIR/plugins/icons.sh "$INFO")" + + app_switched + fi + ''; + }; + plugins_battery = { + executable = true; + target = ".config/sketchybar/plugins/battery.sh"; + text = '' + #!/usr/bin/env sh + source "$CONFIG_DIR/colors.sh" + + PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) + CHARGING=$(pmset -g batt | grep 'AC Power') + + if [ $PERCENTAGE = "" ]; then + exit 0 + fi + + case ''${PERCENTAGE} in + 9[0-9] | 100) + ICON="􀛨" + COLOR=$ITEM_COLOR ;; - "aerospace_mode_change") - illuminate_mode + [6-8][0-9]) + ICON="􀺸" + COLOR=$ITEM_COLOR ;; - esac - ''; - }; - } + [3-5][0-9]) + ICON="􀺶" + COLOR="0xFFd97706" + ;; + [1-2][0-9]) + ICON="􀛩" + COLOR="0xFFf97316" + ;; + *) + ICON="􀛪" + COLOR="0xFFef4444" + ;; + esac + + if [[ $CHARGING != "" ]]; then + ICON="􀢋" + COLOR=$ITEM_COLOR + fi + + # The item invoking this script (name $NAME) will get its icon and label + # updated with the current battery status + sketchybar --set $NAME icon="$ICON" label="''${PERCENTAGE}%" icon.color="$COLOR" + ''; + }; + plugins_aerospace = { + executable = true; + target = ".config/sketchybar/plugins/aerospace.sh"; + text = '' + #!/usr/bin/env bash + source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors + + highlight_focused_workspace() { + if [[ "$1" = "$FOCUSED_WORKSPACE" ]] + then + ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=on label.width=0 + else + ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=off label.width=dynamic + fi + } + + illuminate_mode() { + if [[ "$mode" = "service" ]] + then + ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$ORANGE + elif [[ "$mode" = "resize" ]] + then + ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$GREEN + else + ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$BACKGROUND_1 + fi + } + case "$SENDER" in + "aerospace_workspace_change") + highlight_focused_workspace $1 + ;; + "aerospace_mode_change") + illuminate_mode + ;; + esac + ''; + }; + } ); } diff --git a/modules/macos/system.nix b/modules/macos/system.nix index 4dca169..7bea701 100644 --- a/modules/macos/system.nix +++ b/modules/macos/system.nix @@ -4,9 +4,11 @@ pkgs, lib, ... -}: let +}: +let tiling = config.shared.darwin.tiling.enable; -in { +in +{ # Use touchid or watch to activate sudo security.pam.services.sudo_local = { enable = true; diff --git a/modules/nixos/services.nix b/modules/nixos/services.nix index f0a8401..c48ebc1 100644 --- a/modules/nixos/services.nix +++ b/modules/nixos/services.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ services = { avahi = { enable = true; @@ -40,7 +41,7 @@ # Enable CUPS to print documents. printing = { enable = true; - drivers = [pkgs.brlaser]; # Brother printer driver + drivers = [ pkgs.brlaser ]; # Brother printer driver }; pipewire = { @@ -55,7 +56,7 @@ openssh = { enable = true; - ports = [22]; + ports = [ 22 ]; settings = { PasswordAuthentication = true; UseDns = true; diff --git a/modules/shared/nix.nix b/modules/shared/nix.nix index 596509a..1300a0f 100644 --- a/modules/shared/nix.nix +++ b/modules/shared/nix.nix @@ -1,4 +1,5 @@ -{inputs, ...}: { +{ inputs, ... }: +{ nixpkgs.config = { allowUnfree = true; }; diff --git a/users/natalie/desktop/configuration.nix b/users/natalie/desktop/configuration.nix index 1e0d3fc..f4f95c2 100644 --- a/users/natalie/desktop/configuration.nix +++ b/users/natalie/desktop/configuration.nix @@ -3,7 +3,8 @@ user, host, ... -}: { +}: +{ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix @@ -17,7 +18,7 @@ enable = true; # Certain features, including CLI integration and system authentication support, # require enabling PolKit integration on some desktop environments (e.g. Plasma). - polkitPolicyOwners = [user.username]; + polkitPolicyOwners = [ user.username ]; }; noisetorch.enable = true; @@ -34,7 +35,7 @@ steam = { enable = true; - package = with pkgs; steam.override {extraPkgs = pkgs: [attr];}; + package = with pkgs; steam.override { extraPkgs = pkgs: [ attr ]; }; }; git = { @@ -58,7 +59,7 @@ xdg.portal = { enable = true; - extraPortals = with pkgs; [xdg-desktop-portal-gtk]; + extraPortals = with pkgs; [ xdg-desktop-portal-gtk ]; }; virtualisation = { containers.enable = true; @@ -83,14 +84,14 @@ hybrid-sleep.enable = false; }; - services.monitord.wantedBy = ["multi-user.target"]; + services.monitord.wantedBy = [ "multi-user.target" ]; }; i18n = { # Select internationalisation properties. defaultLocale = "en_US.UTF-8"; - supportedLocales = ["all"]; + supportedLocales = [ "all" ]; extraLocaleSettings = { LC_ADDRESS = "en_US.UTF-8"; @@ -170,7 +171,7 @@ }; interfaces.enp11s0.wakeOnLan = { enable = true; - policy = ["magic"]; + policy = [ "magic" ]; }; }; diff --git a/users/natalie/desktop/home.nix b/users/natalie/desktop/home.nix index d3aa825..10d4da9 100644 --- a/users/natalie/desktop/home.nix +++ b/users/natalie/desktop/home.nix @@ -8,6 +8,7 @@ ... }: { + programs.mangohud.enable = true; home = { stateVersion = "23.05"; # Please read the comment before changing. @@ -29,6 +30,7 @@ wineWowPackages.stable winetricks (prismlauncher.override { gamemodeSupport = true; }) + umu-launcher #window manager stuff wofi @@ -50,8 +52,8 @@ signal-desktop inputs.zls.packages.x86_64-linux.zls rust-bin.stable.latest.default + inputs.zen-browser.packages.x86_64-linux.default ]; - # programs.mangohud.enable = true; }; # xdg.mimeApps.defaultApplications."inode/directory" = "dolphin.desktop"; diff --git a/users/natalie/home.nix b/users/natalie/home.nix index 230fe96..526e94c 100644 --- a/users/natalie/home.nix +++ b/users/natalie/home.nix @@ -2,7 +2,8 @@ pkgs, lib, ... -} @ args: { +}@args: +{ programs = { # sort-lines:start atuin.enable = true; diff --git a/users/natalie/laptop/configuration.nix b/users/natalie/laptop/configuration.nix index b4c7312..1d8bff8 100644 --- a/users/natalie/laptop/configuration.nix +++ b/users/natalie/laptop/configuration.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ environment.systemPackages = with pkgs; [ pinentry_mac ]; @@ -6,7 +7,7 @@ # Custom configuration modules in "modules" are shared between users, # and can be configured in this "shared" namespace shared.darwin = { - macAppStoreApps = ["wireguard"]; + macAppStoreApps = [ "wireguard" ]; }; # Create /etc/zshrc that loads the nix-darwin environment. diff --git a/users/natalie/vim/default.nix b/users/natalie/vim/default.nix index 7568a91..9afa34b 100644 --- a/users/natalie/vim/default.nix +++ b/users/natalie/vim/default.nix @@ -1,4 +1,5 @@ -{...}: { +{ ... }: +{ imports = [ ./keybinds.nix ./languages.nix diff --git a/users/natalie/vim/lean.nix b/users/natalie/vim/lean.nix index 8503935..45fb293 100644 --- a/users/natalie/vim/lean.nix +++ b/users/natalie/vim/lean.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ vim = { lazy.plugins."lean.nvim" = { enabled = true; diff --git a/users/natalie/vim/visuals.nix b/users/natalie/vim/visuals.nix index a4f0ac6..9cb6d77 100644 --- a/users/natalie/vim/visuals.nix +++ b/users/natalie/vim/visuals.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ vim = { visuals = { indent-blankline = {