diff --git a/flake.lock b/flake.lock index 4e2094c..1bb56c9 100644 --- a/flake.lock +++ b/flake.lock @@ -137,11 +137,11 @@ ] }, "locked": { - "lastModified": 1757230583, - "narHash": "sha256-4uqu7sFPOaVTCogsxaGMgbzZ2vK40GVGMfUmrvK3/LY=", + "lastModified": 1759387127, + "narHash": "sha256-uuwJAP92SkHmnI1zo7rrK/gEuHtb97vFZcMa5w+0SZA=", "owner": "Jovian-Experiments", "repo": "Jovian-NixOS", - "rev": "fc3960e6c32c9d4f95fff2ef84444284d24d3bea", + "rev": "0cc290e05882745060fccfe6d7d073f913e0cce7", "type": "github" }, "original": { @@ -183,11 +183,11 @@ ] }, "locked": { - "lastModified": 1758447883, - "narHash": "sha256-yGA6MV0E4JSEXqLTb4ZZkmdJZcoQ8HUzihRRX12Bvpg=", + "lastModified": 1758805352, + "narHash": "sha256-BHdc43Lkayd+72W/NXRKHzX5AZ+28F3xaUs3a88/Uew=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "25381509d5c91bbf3c30e23abc6d8476d2143cd1", + "rev": "c48e963a5558eb1c3827d59d21c5193622a1477c", "type": "github" }, "original": { @@ -225,11 +225,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1758592316, - "narHash": "sha256-1RXYdsASXZsnwhegIzT7+zmnpIrCQCM+8nfv40M3Yio=", + "lastModified": 1758765258, + "narHash": "sha256-orU21BYUJn/7zMhIYbY7T5EDqZ8NtRMSH/f8Qtu047Q=", "owner": "Infinidoge", "repo": "nix-minecraft", - "rev": "f6f93f79b9337ccc089beda439d2a8d5920a9812", + "rev": "5a6c66b90ab4519b7578b54300abc308008c544e", "type": "github" }, "original": { @@ -272,11 +272,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1758427187, - "narHash": "sha256-pHpxZ/IyCwoTQPtFIAG2QaxuSm8jWzrzBGjwQZIttJc=", + "lastModified": 1759381078, + "narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "554be6495561ff07b6c724047bdd7e0716aa7b46", + "rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 6c080fd..7648721 100644 --- a/flake.nix +++ b/flake.nix @@ -95,6 +95,7 @@ ./modules/applications/darwin.nix ./modules/desktop/de/darwin.nix ./modules/desktop/de/aerospace.nix + ./modules/desktop/programs/sketchybar.nix ./modules/hardware/darwin.nix ./modules/nix/darwin.nix ./modules/network/vpn/tailscale-darwin.nix diff --git a/modules/desktop/programs/sketchybar.nix b/modules/desktop/programs/sketchybar.nix index f23e6a8..116fb65 100644 --- a/modules/desktop/programs/sketchybar.nix +++ b/modules/desktop/programs/sketchybar.nix @@ -1,7 +1,9 @@ { config, lib, pkgs, ... }: { - services.skhd.enable = true; - services.sketchybar.enable = true; system.defaults.NSGlobalDomain._HIHideMenuBar = true; + + homebrew.brews = [ + "FelixKratz/formulae/sketchybar" + ]; } diff --git a/stow/.config/aerospace/aerospace.toml b/stow/.config/aerospace/aerospace.toml index 1d2d3bd..a6b9a69 100644 --- a/stow/.config/aerospace/aerospace.toml +++ b/stow/.config/aerospace/aerospace.toml @@ -1,7 +1,15 @@ # You can use it to add commands that run after AeroSpace startup. # Available commands : https://nikitabobko.github.io/AeroSpace/commands after-startup-command = [ - 'exec-and-forget borders active_color=0xfff74f9e inactive_color=0xffffa8f1 width=6.0' + 'exec-and-forget borders active_color=0xfff74f9e inactive_color=0xffffa8f1 width=6.0', + 'exec-and-forget sh ~/.cache/matugen-jankyborders.sh', + 'exec-and-forget sketchybar' +] + + +# Notify Sketchybar about workspace change +exec-on-workspace-change = ['/bin/bash', '-c', + 'sketchybar --trigger aerospace_workspace_change FOCUSED_WORKSPACE=$AEROSPACE_FOCUSED_WORKSPACE' ] # Start AeroSpace at login - breaks nix darwin diff --git a/stow/.config/matugen/config.toml b/stow/.config/matugen/config.toml index 9857e16..1f9aaeb 100644 --- a/stow/.config/matugen/config.toml +++ b/stow/.config/matugen/config.toml @@ -53,3 +53,13 @@ output_path = '~/.config/hypr/hyprlock.conf' [templates.vesktop] input_path = './templates/discord.css' output_path = '~/.config/vesktop/themes/midnight-discord.css' + +[templates.sketchybar] +input_path = './templates/sketchybar.sh' +output_path = '~/.config/sketchybar/colours.sh' +post_hook = 'sketchybar --reload' + +[templates.jankyborders] +input_path = './templates/jankyborders.sh' +output_path = '~/.cache/matugen-jankyborders.sh' +post_hook = 'sh ~/.cache/matugen-jankyborders.sh' diff --git a/stow/.config/matugen/templates/jankyborders.sh b/stow/.config/matugen/templates/jankyborders.sh new file mode 100644 index 0000000..085b48a --- /dev/null +++ b/stow/.config/matugen/templates/jankyborders.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +borders active_color=0xFF{{colors.primary.default.hex_stripped}} inactive_color=0xFF{{colors.surface_dim.default.hex_stripped}} width=6.0 diff --git a/stow/.config/matugen/templates/sketchybar.sh b/stow/.config/matugen/templates/sketchybar.sh new file mode 100644 index 0000000..b5ee3d4 --- /dev/null +++ b/stow/.config/matugen/templates/sketchybar.sh @@ -0,0 +1,3 @@ +export PRIMARY_COLOUR=0xFF{{colors.primary.default.hex_stripped}} +export SECONDARY_COLOUR=0xFF{{colors.secondary.default.hex_stripped}} +export BACKGROUND_COLOUR=0xFF{{colors.background.default.hex_stripped}} diff --git a/stow/.config/sketchybar/.gitignore b/stow/.config/sketchybar/.gitignore new file mode 100644 index 0000000..ea7df9d --- /dev/null +++ b/stow/.config/sketchybar/.gitignore @@ -0,0 +1 @@ +colours.sh diff --git a/stow/.config/sketchybar/plugins/aerospace.sh b/stow/.config/sketchybar/plugins/aerospace.sh new file mode 100755 index 0000000..d25758d --- /dev/null +++ b/stow/.config/sketchybar/plugins/aerospace.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# make sure it's executable with: +# chmod +x ~/.config/sketchybar/plugins/aerospace.sh +# +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +source $SCRIPT_DIR/../colours.sh + +if [ "$1" = "$FOCUSED_WORKSPACE" ]; then + # If workspace is focused + sketchybar --set $NAME background.color=$PRIMARY_COLOUR label.color=$BACKGROUND_COLOUR +else + sketchybar --set $NAME background.color=$BACKGROUND_COLOUR label.color=$PRIMARY_COLOUR +fi diff --git a/stow/.config/sketchybar/plugins/clock.sh b/stow/.config/sketchybar/plugins/clock.sh index 2716ee4..b60d4b5 100755 --- a/stow/.config/sketchybar/plugins/clock.sh +++ b/stow/.config/sketchybar/plugins/clock.sh @@ -12,4 +12,4 @@ else sketchybar --set "$NAME" label.padding_right=20 fi -sketchybar --set "$NAME" label=" $(date +'%a %d %b')  $(date +'%I:%M %p')" +sketchybar --set "$NAME" label="$(date +'%l:%M %p')" diff --git a/stow/.config/sketchybar/plugins/input-method.sh b/stow/.config/sketchybar/plugins/input-method.sh new file mode 100755 index 0000000..ebdf189 --- /dev/null +++ b/stow/.config/sketchybar/plugins/input-method.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# from: https://apple.stackexchange.com/questions/251666/how-to-get-current-input-language-of-the-input-source + +#!/usr/local/bin/bash +# Checks current keyboard input source (aka language) + +#These are the strings that MacOS uses to identify the current input source +ENGLISH="Australian" +HIRIGANA="com.apple.inputmethod.Japanese" +KATANA="com.apple.inputmethod.Japanese.Katakana" + +WESTERN_LANGUAGE=$(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | grep 'KeyboardLayout Name' | sed -E 's/^.+ = \"?([^\"]+)\"?;$/\1/') + +# If the current language is not western one, then check a different variable +EASTERN_LANGUAGE=$(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | grep -w 'Input Mode' | head -1 | sed -E 's/^.+ = \"?([^\"]+)\"?;$/\1/') + +if [ "$WESTERN_LANGUAGE" = "$ENGLISH" ]; then + LABEL="English" + ICON="🇬🇧" +elif [ "$EASTERN_LANGUAGE" = "$HIRIGANA" ]; then + LABEL="Japanese" + ICON="🇯🇵" +elif [ "$EASTERN_LANGUAGE" = "$KATANA" ]; then + LABEL="Katakana" + ICON="🈴" +fi + +sketchybar --set "$NAME" label="$LABEL" icon="$ICON" diff --git a/stow/.config/sketchybar/plugins/music.sh b/stow/.config/sketchybar/plugins/music.sh new file mode 100755 index 0000000..1d4198a --- /dev/null +++ b/stow/.config/sketchybar/plugins/music.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# sketchybar doesn't like it when the line doesn't end with a carriage return +SONG="$(osascript -e 'tell application "Music" to if player state is playing then artist of current track & " - " & name of current track' | head -c 65 && echo '\r')" + +if [[ "$(echo $SONG | wc -w | sed 's/ //g')" != "0" ]]; then + sketchybar --set "$NAME" label="${SONG}" background.drawing=true icon.drawing=true +else + sketchybar --set "$NAME" label="" background.drawing=false icon.drawing=false +fi diff --git a/stow/.config/sketchybar/plugins/wifi.sh b/stow/.config/sketchybar/plugins/wifi.sh new file mode 100755 index 0000000..c886026 --- /dev/null +++ b/stow/.config/sketchybar/plugins/wifi.sh @@ -0,0 +1,8 @@ +#!/bin/sh +ping -c 1 1.1.1.1 &> /dev/null + +if [ "$?" = "0" ]; then + sketchybar --set $NAME icon=󰖩 +else + sketchybar --set $NAME icon=󰖪 +fi diff --git a/stow/.config/sketchybar/sketchybarrc b/stow/.config/sketchybar/sketchybarrc index 2b1366e..48b531f 100755 --- a/stow/.config/sketchybar/sketchybarrc +++ b/stow/.config/sketchybar/sketchybarrc @@ -4,7 +4,7 @@ # For a (much) more advanced configuration example see my dotfiles: # https://github.com/FelixKratz/dotfiles -PLUGIN_DIR="$HOME/.config/sketchybar/plugins" +PLUGIN_DIR="$HOME/dots/stow/.config/sketchybar/plugins" ##### Bar Appearance ##### # Configuring the general appearance of the bar. @@ -13,120 +13,129 @@ PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # If you are looking for other colors, see the color picker: # https://felixkratz.github.io/SketchyBar/config/tricks#color-picker -sketchybar --bar position=top \ - height=32 \ - blur_radius=30 \ - color=0x00000000 \ - padding_right=10 \ - padding_left=10 \ - y_offset=3 +sketchybar --bar position=top height=42 blur_radius=0 color=0x00000000 padding_right=15 padding_left=15 y_offset=0 corner_radius=0 + +source $PLUGIN_DIR/../colours.sh + +##### Changing Defaults ##### +# We now change some default values, which are applied to all further items. +# For a full list of all available item properties see: +# https://felixkratz.github.io/SketchyBar/config/items default=( - icon.font="ComicShannsMono Nerd Font:Regular:11.0" - label.font="ComicShannsMono Nerd Font:Bold:11.0" + icon.font="ComicShannsMono Nerd Font:Regular:16.0" + label.font="ComicShannsMono Nerd Font:Bold:12.0" + background.border_color=0x00000000 + background.border_width=3 + background.height=32 padding_left=1 padding_right=1 - icon.color=$PRIMARY_COLOUR label.color=$PRIMARY_COLOUR + icon.color=$SECONDARY_COLOUR + background.color=$BACKGROUND_COLOUR icon.padding_left=10 icon.padding_right=1 - label.padding_left=5 - label.padding_right=10 - - background.padding_left=2 - background.padding_right=2 - background.corner_radius=10 + label.padding_left=7 + label.padding_right=7 + background.corner_radius=5 ) - sketchybar --default "${default[@]}" -##### Adding Mission Control Space Indicators ##### -# Let's add some mission control spaces: -# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item -# to indicate active and available mission control spaces. +# +# Adding Left Items +# -SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10") -for i in "${!SPACE_ICONS[@]}" -do - sid="$(($i+1))" - space=( - icon.color=$PRIMARY_COLOUR - background.color=$BACKGROUND_COLOUR +# Focused window title +sketchybar --add item front_app left \ + --set front_app icon="󱂬 " \ + script="$PLUGIN_DIR/front_app.sh" \ + --subscribe front_app front_app_switched \ - space="$sid" - icon="${SPACE_ICONS[i]}" - icon.padding_left=12 - icon.padding_right=12 - background.height=32 - background.padding_left=0 - background.padding_right=0 - label.drawing=off - script="$PLUGIN_DIR/space.sh" - click_script="yabai -m space --focus $sid" - ) - sketchybar --add space space."$sid" left --set space."$sid" "${space[@]}" +# Aerospace workspace indicators +sketchybar --add event aerospace_workspace_change +for sid in $(aerospace list-workspaces --all); do + sketchybar --add item space.$sid left \ + --subscribe space.$sid aerospace_workspace_change \ + --set space.$sid \ + background.color=$BACKGROUND_COLOUR \ + background.drawing=true \ + icon.drawing=false \ + background.height=28 \ + background.border_width=0 \ + background.padding_right=0 \ + background.padding_left=0 \ + background.corner_radius=0 \ + label.color=$PRIMARY_COLOUR \ + label="$sid" \ + click_script="aerospace workspace $sid" \ + script="$CONFIG_DIR/plugins/aerospace.sh $sid" done -##### Adding Left Items ##### -# We add some regular items to the left side of the bar, where -# only the properties deviating from the current defaults need to be set +# Currently playing music status (only works for Music.app) +sketchybar --add item music left \ + --set music icon="󰎇 " update_freq=10 \ + script="$PLUGIN_DIR/music.sh" \ + click_script="osascript -e 'tell application \"Music\" to playpause'" \ + background.padding_right=0 \ + background.padding_left=0 \ + background.drawing=false \ + background.color=$PRIMARY_COLOUR \ + icon.color=$BACKGROUND_COLOUR \ + label.color=$BACKGROUND_COLOUR \ + icon.drawing=false -#sketchybar --add item chevron left \ -# --set chevron icon= label.drawing=off \ -# --add item front_app left \ -# --set front_app icon.drawing=off script="$PLUGIN_DIR/front_app.sh" \ -# --subscribe front_app front_app_switched +# +# Adding Right Items +# -sketchybar --add item front_app left \ - --set front_app icon.drawing=off \ - label.color=$PRIMARY_COLOUR \ - padding_left=10 \ - label.padding_left=10 \ - background.color=$BACKGROUND_COLOUR \ - background.height=32 \ - script="$PLUGIN_DIR/front_app.sh" \ - --subscribe front_app front_app_switched \ - - - -##### Adding Right Items ##### - -sketchybar --add item clock right \ - --set clock \ - update_freq=10 \ - icon.color=$PRIMARY_COLOUR \ - label.color=$PRIMARY_COLOUR \ - background.color=$BACKGROUND_COLOUR \ - background.height=32 \ - label.padding_right=20 \ +# Clock +sketchybar --add item clock right \ + --set clock icon=" " \ + update_freq=10 \ + background.padding_right=0 \ + background.padding_left=0 \ + label.padding_right=20 \ script="$PLUGIN_DIR/clock.sh" -sketchybar --add item battery right \ - --set battery update_freq=10 \ - script="$PLUGIN_DIR/battery.sh" \ - icon.color=$SECONDARY_COLOUR \ - label.color=$SECONDARY_COLOUR \ - background.color=$BACKGROUND_COLOUR \ - background.height=32 \ +# Input Method +sketchybar --add item input-method right \ + --set input-method icon="" \ + update_freq=1 \ + background.padding_right=0 \ + background.padding_left=0 \ + script="$PLUGIN_DIR/input-method.sh" -sketchybar --add item backlight right \ - --set backlight icon="" \ - icon.color=$TERTIARY_COLOUR \ - label.color=$TERTIARY_COLOUR \ - background.color=$BACKGROUND_COLOUR \ - background.height=32 \ - script="$PLUGIN_DIR/backlight.sh" \ - --subscribe backlight brightness_change \ +# Battery +sketchybar --add item battery right \ + --set battery update_freq=10 \ + script="$PLUGIN_DIR/battery.sh" \ + background.padding_right=0 \ + background.padding_left=0 \ -sketchybar --add item audio right \ - --set audio icon = "" \ - icon.color=$TERTIARY_COLOUR \ - label.color=$TERTIARY_COLOUR \ - background.color=$BACKGROUND_COLOUR \ - background.height=32 \ - script="$PLUGIN_DIR/volume.sh" \ - --subscribe audio volume_change \ +# Backlight +sketchybar --add item backlight right \ + --set backlight icon="" \ + background.padding_right=0 \ + background.padding_left=0 \ + script="$PLUGIN_DIR/backlight.sh" \ + --subscribe backlight brightness_change \ + +# Volume +sketchybar --add item audio right \ + --set audio \ + background.padding_right=0 \ + background.padding_left=0 \ + script="$PLUGIN_DIR/volume.sh" \ + --subscribe audio volume_change \ + +# Wifi +sketchybar --add item wifi right \ + --set wifi script="$PLUGIN_DIR/wifi.sh" \ + update_freq=60 \ + background.padding_right=0 \ + background.padding_left=0 \ + label.padding_left=0 ##### Force all scripts to run the first time (never do this in a script) ##### sketchybar --update