diff --git a/flake.lock b/flake.lock index fc8a286..0f4e29a 100644 --- a/flake.lock +++ b/flake.lock @@ -50,22 +50,6 @@ } }, "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1746162366, - "narHash": "sha256-5SSSZ/oQkwfcAz/o/6TlejlVGqeK08wyREBQ5qFFPhM=", - "owner": "nix-community", - "repo": "flake-compat", - "rev": "0f158086a2ecdbb138cd0429410e44994f1b7e4b", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_2": { "flake": false, "locked": { "lastModified": 1696426674, @@ -81,7 +65,7 @@ "type": "github" } }, - "flake-compat_3": { + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1696426674, @@ -427,7 +411,7 @@ "nvf", "nixpkgs" ], - "rust-overlay": "rust-overlay_2" + "rust-overlay": "rust-overlay" }, "locked": { "lastModified": 1741118843, @@ -483,29 +467,6 @@ "type": "github" } }, - "nixos-cosmic": { - "inputs": { - "flake-compat": "flake-compat", - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable", - "rust-overlay": "rust-overlay" - }, - "locked": { - "lastModified": 1747826251, - "narHash": "sha256-Fe4AXmnnAKnh/wIe1ao4Pv/8m6WGA1ujwp6VApgos30=", - "owner": "lilyinstarlight", - "repo": "nixos-cosmic", - "rev": "9a67b4a289cd8994080398d40b57cfde8e8cfb0a", - "type": "github" - }, - "original": { - "owner": "lilyinstarlight", - "repo": "nixos-cosmic", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1736012469, @@ -537,22 +498,6 @@ "type": "github" } }, - "nixpkgs-stable": { - "locked": { - "lastModified": 1747676747, - "narHash": "sha256-LXkWBVqilgx7Pohwqu/ABxDVw+Cmi5/Mj2S2mpUH0Fw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "72841a4a8761d1aed92ef6169a636872c986c76d", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-24.11", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs_2": { "locked": { "lastModified": 1747744144, @@ -647,36 +592,14 @@ "nh": "nh", "nix-index-database": "nix-index-database", "nix-options-search": "nix-options-search", - "nixos-cosmic": "nixos-cosmic", "nixpkgs": "nixpkgs_2", "nvf": "nvf", - "rust-overlay": "rust-overlay_3", + "rust-overlay": "rust-overlay_2", "zig": "zig", "zls": "zls" } }, "rust-overlay": { - "inputs": { - "nixpkgs": [ - "nixos-cosmic", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1747795013, - "narHash": "sha256-c7i0xJ+xFhgjO9SWHYu5dF/7lq63RPDvwKAdjc6VCE4=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "6b1cf12374361859242a562e1933a7930649131a", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "rust-overlay_2": { "inputs": { "nixpkgs": [ "nvf", @@ -698,7 +621,7 @@ "type": "github" } }, - "rust-overlay_3": { + "rust-overlay_2": { "inputs": { "nixpkgs": [ "nixpkgs" @@ -924,7 +847,7 @@ }, "zig": { "inputs": { - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat", "flake-utils": "flake-utils_5", "nixpkgs": "nixpkgs_3" }, @@ -944,7 +867,7 @@ }, "zig-overlay": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_2", "flake-utils": "flake-utils_7", "nixpkgs": [ "zls", diff --git a/flake.nix b/flake.nix index b1d8603..c07de41 100644 --- a/flake.nix +++ b/flake.nix @@ -29,9 +29,6 @@ moonlight.url = "github:moonlight-mod/moonlight"; # Add `/develop` to the flake URL to use nightly. moonlight.inputs.nixpkgs.follows = "nixpkgs"; - nixos-cosmic.url = "github:lilyinstarlight/nixos-cosmic"; - nixos-cosmic.inputs.nixpkgs.follows = "nixpkgs"; - nh.url = "github:viperML/nh"; nh.inputs.nixpkgs.follows = "nixpkgs"; @@ -40,80 +37,76 @@ nix-index-database.url = "github:nix-community/nix-index-database"; nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = - { - self, - nixpkgs, - lix-module, - nixos-cosmic, - 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="; - }; - }); + 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}; + } + ); }) - ]; + systems + ); - # 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, ... }: + 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; @@ -122,49 +115,46 @@ # "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 = [ - nixos-cosmic.nixosModules.default - ]; - }; - # 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"; - }; - - # 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) - ); + # 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"; + }; + + # 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/modules/home/default.nix b/modules/home/default.nix index 98635b4..addf68f 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 e80cbab..38695d3 100644 --- a/modules/home/macos/sketchybar.nix +++ b/modules/home/macos/sketchybar.nix @@ -2,534 +2,538 @@ pkgs, lib, config, + host, ... }: { home.file = - 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.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 - 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/nixos/services.nix b/modules/nixos/services.nix index a5c6f0f..f0a8401 100644 --- a/modules/nixos/services.nix +++ b/modules/nixos/services.nix @@ -1,5 +1,4 @@ -{ pkgs, ... }: -{ +{pkgs, ...}: { services = { avahi = { enable = true; @@ -24,6 +23,7 @@ desktopManager.cosmic.enable = true; displayManager.cosmic-greeter.enable = true; + desktopManager.cosmic.xwayland.enable = true; # Auto mount devices udisks2 = { @@ -40,7 +40,7 @@ # Enable CUPS to print documents. printing = { enable = true; - drivers = [ pkgs.brlaser ]; # Brother printer driver + drivers = [pkgs.brlaser]; # Brother printer driver }; pipewire = { @@ -55,7 +55,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 b8bff36..596509a 100644 --- a/modules/shared/nix.nix +++ b/modules/shared/nix.nix @@ -24,13 +24,11 @@ "https://cache.nixos.org/?priority=10" "https://nix-community.cachix.org" - "https://cosmic.cachix.org/" # For haskell "https://cache.iog.io" ]; trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" # For haskell "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ]; diff --git a/users/natalie/desktop/configuration.nix b/users/natalie/desktop/configuration.nix index abc5094..1e0d3fc 100644 --- a/users/natalie/desktop/configuration.nix +++ b/users/natalie/desktop/configuration.nix @@ -3,8 +3,7 @@ user, host, ... -}: -{ +}: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix @@ -18,7 +17,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; @@ -35,7 +34,7 @@ steam = { enable = true; - package = with pkgs; steam.override { extraPkgs = pkgs: [ attr ]; }; + package = with pkgs; steam.override {extraPkgs = pkgs: [attr];}; }; git = { @@ -59,7 +58,7 @@ xdg.portal = { enable = true; - extraPortals = with pkgs; [ xdg-desktop-portal-gtk ]; + extraPortals = with pkgs; [xdg-desktop-portal-gtk]; }; virtualisation = { containers.enable = true; @@ -84,16 +83,14 @@ hybrid-sleep.enable = false; }; - packages = [ pkgs.observatory ]; - - 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"; @@ -148,7 +145,10 @@ ]; }; environment = { - sessionVariables.COSMIC_DATA_CONTROL_ENABLED = 1; + sessionVariables = { + COSMIC_DATA_CONTROL_ENABLED = 1; + NIXOS_OZONE_WL = "1"; + }; variables.EDITOR = "nvim"; systemPackages = with pkgs; [ @@ -170,7 +170,7 @@ }; interfaces.enp11s0.wakeOnLan = { enable = true; - policy = [ "magic" ]; + policy = ["magic"]; }; };