2025-12-15 23:16:22 +03:00
|
|
|
How this must work.
|
|
|
|
|
|
2025-12-21 15:59:56 +03:00
|
|
|
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.
|
2025-12-15 23:16:22 +03:00
|
|
|
|
|
|
|
|
example:
|
2025-12-21 15:59:56 +03:00
|
|
|
userctx backup [--name <name>] [--apps TODO]
|
2025-12-15 23:16:22 +03:00
|
|
|
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
|
2025-12-21 15:59:56 +03:00
|
|
|
- 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
|
2025-12-15 23:16:22 +03:00
|
|
|
- remove original files (and directories) from ~/.config/sway
|
|
|
|
|
- create symlinks to copied files in ~/.config/sway
|
|
|
|
|
|
|
|
|
|
3. Swithing algorithm:
|
|
|
|
|
User requests theme change with:
|
2025-12-21 15:59:56 +03:00
|
|
|
userctx apply <theme>
|
2025-12-15 23:16:22 +03:00
|
|
|
|
2025-12-21 15:59:56 +03:00
|
|
|
userctx tries to apply configs as follows:
|
2025-12-15 23:16:22 +03:00
|
|
|
- looks up a list of apps it should manage; if list is empty - return non-zero
|
2025-12-21 15:59:56 +03:00
|
|
|
- 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
|
2025-12-15 23:16:22 +03:00
|
|
|
```
|
|
|
|
|
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)
|
2025-12-21 15:59:56 +03:00
|
|
|
ln -s ~/.config/userctx/<theme>/<app>/<filename> ~/.config/<app>/<filename> # symlinks the file from requested theme user dir
|
2025-12-15 23:16:22 +03:00
|
|
|
```
|
2025-12-21 15:59:56 +03:00
|
|
|
- after creating symlinks userctx tries to let the app know that config changed
|
2025-12-15 23:16:22 +03:00
|
|
|
- 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>
|
|
|
|
|
|
2025-12-21 15:59:56 +03:00
|
|
|
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
|
2025-12-15 23:16:22 +03:00
|
|
|
should manage.
|
|
|
|
|
|
|
|
|
|
4. cli interface
|
2025-12-21 15:59:56 +03:00
|
|
|
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
|
2025-12-15 23:16:22 +03:00
|
|
|
|
|
|
|
|
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.
|