feat: v0.1.0 #1

Merged
dmitry merged 12 commits from dev into main 2025-12-27 12:05:30 +03:00
2 changed files with 42 additions and 49 deletions
Showing only changes of commit 27c7677100 - Show all commits

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
__pycache__

View File

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