WIP on config

This commit is contained in:
2025-12-18 00:19:36 +03:00
parent 43882ede49
commit 27c7677100
2 changed files with 42 additions and 49 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
__pycache__

View File

@@ -6,7 +6,8 @@
dry_run = true
# "apps" array tells userctx what to do (which apps
# should be actually managed)
# should be actually managed). If it is empty or not
# set, then userctx will do nothing.
apps = [
"sway",
"gtk",
@@ -20,46 +21,48 @@ apps = [
# are located
# defaults to $XDG_CONFIG_HOME if specifically set
# or ~/.config if $XGD_CONFIG_HOME is not set
managed_path = "~/.config"
target_path = "~/.config"
# directory where contexts are stored
# default is "~/.config/userctx"
contexts_path = "~/.config/userctx"
source_path = "~/.config/userctx"
[apps]
helix.symlink."*" = "themes/theme.toml"
helix.code = "pkill -USR1 hx"
helix.exec = "pkill -USR1 hx"
example2.scripts = ["s1", "s2"]
[apps.example]
symlink."this.file" = "that.file"
code = 'echo "this simulates reload command"'
symlink."*" = "theme.conf" # TODO: handle any file to particular name
exec = 'echo "this simulates reload command"'
[apps.niri]
code = "this simulates code for niri restart"
exec = "this simulates code for niri restart"
[apps.niri.symlink]
"another.file" = "another.link"
# This section of config is intended to document
# what userctx can do. Assume we are
# building a config for app "example"
# section that demonstrates all the available
# features of userctx
[apps.example]
# The default source path would be
# ~/.config/userctx/<context_name>/example
# it can be overriden with "contexts_path" from
# section general.
# Path to appliaction configs is read from
# general.soucre_path. The default source path is
# ~/.config/userctx/<context_name>/example for this
# app.
# Individual path for app can be provided via
# "source_path". Then userctx will try to lookup
# "source_path" for particular app. Then userctx will try to lookup
# app settings in /source_path/<context_name>
source_path = "~/some/path"
# Default is general.source_path/<context_name>/<app_name>.
# For this example it will expand to
# ~/.config/userctx/<context_name/example.
# TODO: do we really need this?
source_path = "~/tmp/contexts"
# The default path to apply your context to is
# ~/.config/example (for app name "example")
# or if you provided a "managed path" in "general" section above,
# then it will be /your/path/example for "exmaple" app.
# if not overridden with general.target_path.
# Setting "target_path" overrides this.
# $CONTEXT_DST env will hold the actual destination path.
# symlinks will be created relative to this specified
@@ -68,35 +71,29 @@ target_path = "~/.config/example/configs"
# "symlink" map defines
# which files will be symlinked to users home
# directory. If "symlinks" key is present in
# "actions" above but this "symlinks" array is omitted
# then userctx treats all files in the context directory as
# files that must be symlinked to users home.
# Names of files in these mapping are relative to
# directory.
# Names of files in thes mapping are relative to
# context directory and target directory
# by default source is ~/.config/userctx/<context_name>/example for
# task (app) named "example"
# default target directory is ~/.config/example for
# task (app) named "example"
# by default source is ~/.config/userctx/<context_name>/example
# and target directory is ~/.config/example
# for app named "example"
#
# this will link file from context dir to destination dir
# $CONTEXT_SRC/context_file.conf -> $CONTEXT_DST/symlink_to_context_file.conf
symlink."context_file.conf" = "symlink_to_context_file.conf"
# this will link file to subdirectory inside destination dir
# directory must be created beforehand
# Note that destination subdir must be created beforehand.
# $CONTEXT_SRC/other_file.conf -> $CONTEXT_DST/subdir/other_file.conf
symlink."other_file.conf" = "subdir/other_file.conf"
# also possible option
symlink."subdir/yet_another_file.conf" = "yet_another_file.conf"
# "code" object let's you write
# a custom script that will apply contents of
# your context. Note that string is a multiline string
# strating and ending with three double-qoutes.
# This string will be passed as is to $SHELL -c <string>
# "exec" let's you write a reload command or
# even a bigger custom script that will apply contents of
# your context. Note the triple double-qoutes for multiline
# strings (see TOML spec).
# This string will be passed as is to $SHELL for execution.
exec = """
# this is a normal shell script which will
# be executed by user's $SHELL or 'bash' binary
@@ -124,10 +121,6 @@ scripts = [
"script2.sh",
]
# reload command (if set) will be executed after
# all actions
reload = 'echo "this is my reload command"'
#########################
settings for some
commonly used apps
@@ -149,7 +142,7 @@ actions = [
# ~/.config/niri/configs, which then get concatenated.
# For niri since 25.11 you can just put your includes
# into the context dir and omit [apps.niri] altogether.
code = """
exec = """
cat ~/.config/niri/configs/* > ~/.config/niri/config.kdl
"""
@@ -159,14 +152,13 @@ actions = [
"code",
]
# context must contain file named "helix.toml" which describes a theme.
symlinks = [
# $CONTEXT_SRC/helix.toml -> $CONTEXT_DST/themes/current_theme.toml
{"helix.toml" = "themes/current_theme.toml"}
]
code = """
symlink."helix.toml" = "themes/current_theme.toml"
exec = """
sed -i -E 's/^theme = (.+)/theme = "current_theme"/' ~/.config/helix/config.toml
pkill -USR1 hx
"""
reload = ['pkill', '-USR1', 'hx']
[apps.gtk]
# To setup the look of GTK you may put a simple shell script
@@ -177,16 +169,16 @@ reload = ['pkill', '-USR1', 'hx']
actions = ["scripts"]
[apps.mako]
reload = ["makoctl", "reload"]
exec = "makoctl reload"
[apps.sway]
reload = ["swaymsg", "reload"]
exec = "swaymsg reload"
[apps.kitty]
reload = ['pkill', '-USR1', 'kitty']
exec = 'pkill -USR1 kitty'
[apps.waybar]
reload = ['pkill', '-USR2', 'waybar']
exec = 'pkill -USR2 waybar'
[apps.swaybg]
# This config is for swaybg setup as s systemd service.