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
|
|
@ -45,12 +45,11 @@ in
|
|||
};
|
||||
|
||||
config = mkOption {
|
||||
type = with types; nullOr (either lines path);
|
||||
default = "";
|
||||
type = types.nullOr (lib.hm.types.sourceFileOrLines ".config/sketchybar" "sketchybarrc");
|
||||
default = null;
|
||||
example = literalExpression ''
|
||||
# Bash example
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# String example - inline configuration
|
||||
'''
|
||||
# Define colors
|
||||
export COLOR_BLACK="0xff181926"
|
||||
export COLOR_WHITE="0xffcad3f5"
|
||||
|
|
@ -75,12 +74,28 @@ in
|
|||
|
||||
# Update the bar
|
||||
sketchybar --update
|
||||
'''
|
||||
|
||||
# Or directory example - for complex configurations
|
||||
# {
|
||||
# source = ./path/to/sketchybar-config;
|
||||
# recursive = true;
|
||||
# }
|
||||
'';
|
||||
description = ''
|
||||
The complete sketchybar configuration content.
|
||||
This should be written in the language specified by configType (bash or lua).
|
||||
The sketchybar configuration. Can be specified as:
|
||||
|
||||
The appropriate shebang will be automatically added.
|
||||
1. A string containing the configuration content directly
|
||||
2. An attribute set with 'source' pointing to a directory containing
|
||||
the full configuration, and optionally 'recursive = true' to
|
||||
recursively copy all files
|
||||
3. An attribute set with 'text' containing inline configuration
|
||||
|
||||
When using a string or 'text', the appropriate shebang will be
|
||||
automatically added based on configType (bash or lua).
|
||||
|
||||
When using a directory source, it should contain a file named
|
||||
"sketchybarrc" which serves as the main entry point.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
@ -222,26 +237,6 @@ in
|
|||
|
||||
home.packages = [ cfg.finalPackage ];
|
||||
|
||||
xdg.configFile."sketchybar/sketchybarrc".source = lib.mkIf (cfg.config != "") (
|
||||
pkgs.writeTextFile {
|
||||
name = "sketchybarrc";
|
||||
text =
|
||||
if cfg.configType == "lua" then
|
||||
''
|
||||
#!/usr/bin/env lua
|
||||
-- Generated by home-manager
|
||||
${cfg.config}
|
||||
''
|
||||
else
|
||||
''
|
||||
#!/usr/bin/env bash
|
||||
# Generated by home-manager
|
||||
${cfg.config}
|
||||
'';
|
||||
executable = true;
|
||||
}
|
||||
);
|
||||
|
||||
launchd.agents.sketchybar = {
|
||||
enable = cfg.service.enable;
|
||||
config = {
|
||||
|
|
@ -253,5 +248,38 @@ in
|
|||
StandardOutPath = cfg.service.outLogFile;
|
||||
};
|
||||
};
|
||||
|
||||
xdg.configFile = lib.mkIf (cfg.config != null) (
|
||||
if cfg.config.source != null && cfg.config.recursive then
|
||||
{
|
||||
"sketchybar" = {
|
||||
inherit (cfg.config) source recursive;
|
||||
};
|
||||
}
|
||||
else if cfg.config.source != null then
|
||||
{
|
||||
"sketchybar/sketchybarrc".source = cfg.config.source;
|
||||
}
|
||||
else
|
||||
{
|
||||
"sketchybar/sketchybarrc".source = pkgs.writeTextFile {
|
||||
name = "sketchybarrc";
|
||||
text =
|
||||
if cfg.configType == "lua" then
|
||||
''
|
||||
#!/usr/bin/env lua
|
||||
-- Generated by home-manager
|
||||
${cfg.config.text}
|
||||
''
|
||||
else
|
||||
''
|
||||
#!/usr/bin/env bash
|
||||
# Generated by home-manager
|
||||
${cfg.config.text}
|
||||
'';
|
||||
executable = true;
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue