Files
userctx/TODO.md

59 lines
2.7 KiB
Markdown

How this must work.
1. On first launch userctx reads ~/.config/userctx/config and aquires list of apps it should manage
2. userctx backs up whole config directories to ~/.config/userctx so further manipulations are safe
Default name is userctx/original, but user can provide a different name from command line.
example:
userctx backup [--name <name>] [--apps TODO]
default name is "original"
default apps list is read from config. command line overrides config completely, no merging.
Backup algorithm:
- If directory ~/.config/sway does not exist or is empty will do nothing
- if directory exists AND not empty then create directory ~/.config/userctx/original/sway
- copy contents of all files AND direcotries in it to ~/.config/userctx/original/sway
- if any file failed to copy - rollback and remove ~/.config/userctx/original/sway
- remove original files (and directories) from ~/.config/sway
- create symlinks to copied files in ~/.config/sway
3. Swithing algorithm:
User requests theme change with:
userctx apply <theme>
userctx tries to apply configs as follows:
- looks up a list of apps it should manage; if list is empty - return non-zero
- looks up requested theme name in ~/.config/userctx/<name>; if not found - return non-zero
- looks up config dir ~/.config/userctx/<theme>/<app>; if none found - return non-zero
- for each <filename> in ~/.config/userctx/<theme>/<app> userctx does
```
mkdir -p ~/.config/<app> # creates app config directory if it does not exist (else no-op)
rm -f ~/.config/<app>/<filename> # tries to delete the config if it exists (else no-op)
ln -s ~/.config/userctx/<theme>/<app>/<filename> ~/.config/<app>/<filename> # symlinks the file from requested theme user dir
```
- after creating symlinks userctx tries to let the app know that config changed
- if app has hot-reload (niri, alacritty, hyprland) - do nothing
- if app re-reads configs on start (fuzzel, wofi) - do nothing
- if app obeys USR1/URS2 - issue the signal
- if app is a systemd service - exec systemctl --user restart <app>
This way a single copy of config files are kept in ~/.config/userctx.
This way user can choose which files to manage themselves and which userctx
should manage.
4. cli interface
userctx list - returns newline-separated list (suitable for dmenu)
userctx apply $(userctx list | fuzzel -d) - a usable way to select theme with dmenu-like apps
TODO:
0. Update README.md, make app usable for a random person on the internet.
1. implement backup
2. parse cli args in a decent way
3. implement behaviour discussed above
4. Think of config options: configure ability to merge several files; map contents of theme dir to specific files
Wider TODO:
1. Think of this app as a user context switcher, not only theme manager.