sketchybar: config sourceFileOrLines
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
abe66194b9
commit
c096c39afc
6 changed files with 125 additions and 40 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
sketchybar = ./sketchybar.nix; # Bash configuration with validation
|
||||
sketchybar-lua-config = ./sketchybar-lua-config.nix; # Lua configuration with validation
|
||||
sketchybar-invalid-lua-config = ./sketchybar-invalid-lua-config.nix; # Tests error on missing sbarLua
|
||||
sketchybar-service-integration = ./sketchybar-service-integration.nix; # Service integration with validation
|
||||
sketchybar = ./sketchybar.nix;
|
||||
sketchybar-directory-config = ./sketchybar-directory-config.nix;
|
||||
sketchybar-invalid-lua-config = ./sketchybar-invalid-lua-config.nix;
|
||||
sketchybar-lua-config = ./sketchybar-lua-config.nix;
|
||||
sketchybar-service-integration = ./sketchybar-service-integration.nix;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
# Create a mock directory structure for testing
|
||||
configDir = pkgs.runCommand "sketchybar-config" { } ''
|
||||
mkdir -p $out/plugins
|
||||
cat > $out/sketchybarrc <<EOF
|
||||
#!/usr/bin/env bash
|
||||
# Main configuration file
|
||||
source "$CONFIG_DIR/plugins/battery.sh"
|
||||
source "$CONFIG_DIR/plugins/clock.sh"
|
||||
|
||||
sketchybar --bar height=32 position=top
|
||||
sketchybar --update
|
||||
EOF
|
||||
chmod +x $out/sketchybarrc
|
||||
|
||||
cat > $out/plugins/battery.sh <<EOF
|
||||
#!/usr/bin/env bash
|
||||
sketchybar --add item battery right \\
|
||||
--set battery script="\$CONFIG_DIR/plugins/battery.sh" \\
|
||||
update_freq=10
|
||||
EOF
|
||||
|
||||
cat > $out/plugins/clock.sh <<EOF
|
||||
#!/usr/bin/env bash
|
||||
sketchybar --add item clock right \\
|
||||
--set clock script="date '+%H:%M'" \\
|
||||
update_freq=60
|
||||
EOF
|
||||
'';
|
||||
in
|
||||
{
|
||||
programs.sketchybar = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage {
|
||||
name = "sketchybar";
|
||||
buildScript = ''
|
||||
mkdir -p $out/bin
|
||||
touch $out/bin/sketchybar
|
||||
chmod 755 $out/bin/sketchybar
|
||||
'';
|
||||
};
|
||||
|
||||
configType = "bash";
|
||||
|
||||
config = {
|
||||
source = configDir;
|
||||
recursive = true;
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/sketchybar/sketchybarrc
|
||||
assertFileExists home-files/.config/sketchybar/plugins/battery.sh
|
||||
assertFileExists home-files/.config/sketchybar/plugins/clock.sh
|
||||
|
||||
# Verify the main config file is executable
|
||||
[[ -x home-files/.config/sketchybar/sketchybarrc ]] || \
|
||||
echo "sketchybarrc should be executable"
|
||||
'';
|
||||
}
|
||||
|
|
@ -64,7 +64,6 @@ in
|
|||
sbar:update()'';
|
||||
};
|
||||
|
||||
# Validate the generated Lua configuration file
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/sketchybar/sketchybarrc \
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<key>ProcessType</key>
|
||||
<string>Interactive</string>
|
||||
<key>Program</key>
|
||||
<string>/@sketchybar@/bin/sketchybar</string>
|
||||
<string>/nix/store/00000000000000000000000000000000-sketchybar/bin/sketchybar</string>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>StandardErrorPath</key>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ in
|
|||
sketchybar --update
|
||||
'';
|
||||
|
||||
# Enable the integrated service
|
||||
service = {
|
||||
enable = true;
|
||||
errorLogFile = "/home/hm-user/Library/Logs/sketchybar/sketchybar.err.log";
|
||||
|
|
@ -46,16 +45,12 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# Change home directory for the test
|
||||
home.homeDirectory = "/home/hm-user";
|
||||
|
||||
# Validate the generated config files
|
||||
nmt.script = ''
|
||||
# Verify config file exists
|
||||
assertFileExists home-files/.config/sketchybar/sketchybarrc
|
||||
|
||||
# Verify service file exists and matches expected content
|
||||
serviceFile=LaunchAgents/org.nix-community.home.sketchybar.plist
|
||||
serviceFile=$(normalizeStorePaths LaunchAgents/org.nix-community.home.sketchybar.plist)
|
||||
assertFileExists "$serviceFile"
|
||||
assertFileContent "$serviceFile" ${./sketchybar-service-expected.plist}
|
||||
'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue