waycrate / swhkd

Sxhkd clone for Wayland (works on TTY and X11 too)
https://git.sr.ht/~shinyzenith/swhkd
BSD 2-Clause "Simplified" License
666 stars 47 forks source link

[refactor] environment variable initialization #243

Closed newtoallofthis123 closed 4 months ago

newtoallofthis123 commented 4 months ago

This PR implements the following changes, these changes have been limited to swhks for feedback and review, but they can be extended into the actual swhkd as well.

1. Env Struct

The env struct is used to centrally handle all the environment related queries and initializations. It is opened as a thread safe OnceLock variable and hence is ideal for servers

2. Better Error Handling

Error handling related to env is now centrally handled in the Env struct itself using typecasted enumerations

3. PathBuf implementations

Paths are now handled with pathbufs instead of format strings

This PR lays the ground work in centralizing the Environment variable queries that would help abstract away all the individual queries. This could especially be helpful when we modify the privilege model since we would now need to do changes in only a few places

Additionally, this has been tested individually and cargo linted as well

Feedback and any changes required are appreciated 😄

newtoallofthis123 commented 4 months ago

@Shinyzenith I am tagging you as you asked :)

Shinyzenith commented 4 months ago

Hi @newtoallofthis123 from a preliminary view, things look great as we discussed. Can we expand this for swhkd too? If you'd like to impl that in a separate pr then let me know!

newtoallofthis123 commented 4 months ago

Yes. This PR mostly aims to refactor the swhks code. I was planning on opening a similar PR for swhkd once this got approved, however, if need be I can combine it with this. However, a separate PR would be ideal I feel.

Thanks for the review 😊

Shinyzenith commented 4 months ago

Cool, we can do that separately, let me just get zubairs opinion on this too before I merge.

CC: @zubairmh

Shinyzenith commented 4 months ago

Hi it seems you also need to format your code make check.

newtoallofthis123 commented 4 months ago

Done! Just ran make check

Hopefully that resolves the workflows 😄 and I also removed the .gitignore commit