Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] add flag to remember the latest used editor configuration #34

Open
marcosnils opened this issue Dec 19, 2023 · 9 comments
Open

Comments

@marcosnils
Copy link

I generally find myself changing the default color and size very often and I really wish if satty could just remember the latest setting used. I guess the most straight forward approach to do this would be to persist the editor config somewhere and then read it every time satty is called.

For backwards compatibility purposes I was thinking about adding a new flag for this like --persist-editor-cfg.

WDYT? would a PR be useful?

@gabm
Copy link
Owner

gabm commented Dec 19, 2023

great idea! have you seen #30? We should add default colour and default size there!

would this already solve your use case?

Currently there is no such notion as "state". Satty is basically stateless as all config is passed to it at startup. The configuration file in #30 would be a way to not only describe the initial state but - when writable - also to persist state. Imho that might be the best approach.

We should avoid unpredictable options, i.e. specifying A but getting B...

@marcosnils
Copy link
Author

would this already solve your use case?

not entirely since what I'd really like is for the editor to remember the last setting used. This is something that other tools like flameshot do.

Having a config file to set the color and size would partially help, but it won't be a nice UX since it'd be very painful having to go to that file each time I want to change them.

@gabm
Copy link
Owner

gabm commented Dec 25, 2023

I think the way forward will be to implement the configuration file as a way of persisting state and then use one of the toml editor crates to edit that file when the remember last state option is set

@marcosnils
Copy link
Author

I think the way forward will be to implement the configuration file as a way of persisting state and then use one of the toml editor crates to edit that file when the remember last state option is set

yes sure, this makes sense. How do you prefer to move forward about this? Can I help #30 to move forward somehow?

@gabm
Copy link
Owner

gabm commented Dec 26, 2023

I thought about this again and had some specific doubts about us touching the users config file and also systems where the configuration file is immutable. So I asked the NixOS community over at Reddit [0] and the answers are very useful .. let me summarise

  • we should never touch the users config file - that's sacred userland
  • we should follow the xdg standards, there is a place for application state
  • it would be easier for NixOS if the user config would be immutable to the program, but if it's not that wouldn't be deal breaker either

For us that boils down to:

  • config and state are two different things - contrary to what i said above

  • we can implement state without worrying about the config file and even before implementing Configuration #30

  • the state for should reside in it's appropriate folder and can be anything - probably json

  • [0] https://www.reddit.com/r/NixOS/s/sak64v9wmD

@marcosnils
Copy link
Author

Awesome, great. I can start with a draft PR and we can continue iterating there.

@gabm
Copy link
Owner

gabm commented Dec 26, 2023

I would prefer the following behaviour/spec

  • we introduce a flag that enables satty to remember it's last state. if the flag is not specified, it shall behave as it does until now
  • If the flag is specified we do:
    • try to open a json file from the xdg specified folder
    • load the state from there
    • use the last selected tool from there
    • update the file on every change of state
    • the state includes: selected tool, selected colour, custom colour and selected size

@gabm
Copy link
Owner

gabm commented Dec 26, 2023

Awesome, great. I can start with a draft PR and we can continue iterating there.

great, looking forward!

@gabm
Copy link
Owner

gabm commented Dec 28, 2023

I implemented config file handling in #38. It pushes the config into a global variable called APP_STATE that is a relm4 SHARED_STATE. I do think that this might also be a good approach for tracking the app state (selected tools, colors, sizes etc)

@gabm gabm mentioned this issue Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants