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

Default to $XDG_CONFIG_HOME/azote/azotebg #165

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

emanuelserpa
Copy link
Contributor

@emanuelserpa emanuelserpa commented Sep 6, 2022

Uses $XDG_CONFIG_HOME/azote/azotebg as the default location (if $HOME/.azotebg isn't present). azotebg is effectively a configuration file that is called by $XDG_CONFIG_HOME/sway/config (or similar).

Resolves #154

@emanuelserpa emanuelserpa changed the title Defaulting as $XDG_CONFIG_HOME/azote/azotebg Default to $XDG_CONFIG_HOME/azote/azotebg Sep 6, 2022
Copy link
Owner

@nwg-piotr nwg-piotr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, shouldn't we just use the XDG_CONFIG_HOME variable?

@emanuelserpa
Copy link
Contributor Author

Done.

@nwg-piotr
Copy link
Owner

nwg-piotr commented Sep 13, 2022

Well, I don't agree with what @TamasBarta said in #154:

Azote at the moment saves its config to $HOME/.azotebg

The config file is azoterc, placed in the proper place.

common.azote_config_home = os.path.join(xdg_config_home, "azote") if xdg_config_home else os.path.join(
        os.getenv("HOME"), ".config/azote")

The .azotebg file is a script. I placed it in ~/, because feh, that we use on X11 places .fehbg here. Actually if not here, it should be located in some dir on $PATH, like ~/bin or ~/.local/bin. We would need to check which of them exists, and there's on $PATH, if we want to move the file there.

[edit] I wouldn't like to do it, however. It would affect all the nwg-shell users' configs.

@emanuelserpa
Copy link
Contributor Author

emanuelserpa commented Sep 14, 2022

azotebg to be in ~/.local/bin makes sense to me.

We would need to check which of them exists, and there's on $PATH, if we want to move the file there.

I don't feel the need to move the file, let people use their current configs and newer people will use the new default ones. Gradually, the people will change to the new location. Moving config files can cause confusion.

@nwg-piotr
Copy link
Owner

Alright, if you really want. But please take into account not only ~/.local/bin. E.g. on my main machine I don't have it at all, and most Arch users will probably have ~/bin. Check $PATH, and what really exists on the users machine.

@emanuelserpa
Copy link
Contributor Author

emanuelserpa commented Sep 14, 2022

What do you think? The advantage now is that people can just put exec azotebg in sway's config.

@nwg-piotr
Copy link
Owner

nwg-piotr commented Sep 14, 2022

Yes, that's basically what I meant. The problem (to me) is that a fresh install of nwg-shell on Arch (w/ the archinstall script) has neither ~/bin nor ~/.local/bin. So I'd have to stick to copying the default .azotebg file to ~/. I need to think about it.

@emanuelserpa
Copy link
Contributor Author

emanuelserpa commented Sep 14, 2022

Yes, that's basically what I meant. The problem (to me) is that a fresh install of nwg-shell on Arch (w/ the archinstall script) has neither ~/bin nor ~/.local/bin. So I'd have to stick to copying the default .azotebg file to ~/. I need to think about it.

Are you sure that it doesn't have ~/.local/bin in the $PATH?

I use Arch and I didn't do anything (I use ~/bin), but I have many executables in ~/.local/bin (mostly Python).

@nwg-piotr
Copy link
Owner

Are you sure that it doesn't have ~/.local/bin in the $PATH?

100%. This is my testing laptop:

$ ls -a
.   .azotebg  .bash_history  .bash_profile  .cache   Dokumenty  .gtkrc-2.0  Muzyka  .pki     Publiczny  Szablony
..  baph      .bash_logout   .bashrc        .config  .gnome     .local      Obrazy  Pobrane  Pulpit     Wideo
[piotr@asus ~]$ ls .local
share  state
[piotr@asus ~]$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

@TamasBarta
Copy link

Hey @nwg-piotr, hey @emanuelserpa,

What do you think about what I originally wrote in #154 ?

I understand the config file is a script, but looking at the code told me it is also used to be read as configuration.

My argument was that as a format, it is a script, but the actual paths of the backgrounds are parsed from the script. If I'm not mistaken, azoterc doesn't store the paths to the background files, but azotebg does. (Sorry, I work from memory, since I don't have a Linux machine available now)

That being said (it may or may not be true, it might even have changed since), $HOME isn't in $PATH either :) I don't think you have to put it in $PATH. User will adjust $PATH if they want to. I'd think about putting it in $XDG_DATA_HOME, if not under $XDG_CONFIG_HOME.

That being said, if it moves from $HOME, then I already appreciate the change, but the $XDG_* variables are a global way to influence the behaviour of apps, so you can for example move everything to another partition or back all configs up in a uniform way, and not using them would break this.

I personally would eliminate azotebg altogether, and have a switch in the main azote command to apply backgrounds (e.g. azote --apply), and paths then can live not in a script but in the config files, but I don't want to overstep the boundaries of this PR, it's just to demonstrate how I think about configuration in general.

What do you think?

@nwg-piotr
Copy link
Owner

nwg-piotr commented Sep 15, 2022

I am reluctant to change anything for several reasons. If we leave .azotebg as is for existing installs, it will be a half-baked solution. If we actually move it, it'll be a breaking change.

I personally would eliminate azotebg altogether, and have a switch in the main azote command to apply backgrounds (e.g. azote --apply)

Azote is a heavy app, and it takes time to launch it. Of course we would need to execute just several lines of code, but I'm sure the external script is faster. And this would be a breaking change as well.

$ time azote -h

Azote wallpaper manager version 1.9.4

[-h] | [--help]			Print help
[-l] | [--lang] <ln_LN> 	Force a locale (de_DE, en_EN, fr_FR, pl_PL)
[-c] | [--clear]		Clear unused thumbnails
[-a] | [--clear-all]		Clear all thumbnails


real	0m0,286s
user	0m0,249s
sys	0m0,037s

$ time ~/.azotebg;

real	0m0,014s
user	0m0,006s
sys	0m0,008s

The app has been packaged for 17 repos, and we must think twice before making breaking changes. What I care most are nwg-shell users. I want them to be able not to edit config files at all, and it means: the project is aimed at users of all skill levels. My nwg-shell updater would have to deal with their main config file, which is a thing I do only if there's no other solution.

Do you understand my point of view?

@emanuelserpa
Copy link
Contributor Author

emanuelserpa commented Sep 15, 2022

@TamasBarta

My argument was that as a format, it is a script, but the actual paths of the backgrounds are parsed from the script. If I'm not mistaken, azoterc doesn't store the paths to the background files, but azotebg does.

Well, I still feel that it is effectively a configuration, but I understand @nwg-piotr's point. For Sway, Azote could actually create a configuration like:

exec swaybg -o 'eDP-1' -i "wallpaper.png" -m fill

then you can call it in sway config using include ~/.config/azote/azotebg. Now it is a configuration.

It would be, definitely, an obligatory breaking change and I think azote changes the wallpaper executing the script it creates.

PS: this configuration file could be easily applied using swaymsg ~/.config/azote/azotebg

@nwg-piotr
Copy link
Owner

nwg-piotr commented Sep 15, 2022

then you can call it in sway config using include ~/.config/azote/azotebg. Now it is a configuration.

Sounds not bad to me, but I think I would merge such a change only when I have another unavoidable change to the main sway config file to do.

@nwg-piotr
Copy link
Owner

PS: this configuration file could be easily applied using swaymsg ~/.config/azote/azotebg

nwg-shell already uses 7 includes. One more makes no special difference.

@TamasBarta
Copy link

@nwg-piotr absolutely, I only wanted to write it to display my logic, I don't want to propose such big changes, and especially not as part of this PR's/issue's scope. As I said, any change is appreciated that allows cleaning up $HOME.

@emanuelserpa
Copy link
Contributor Author

emanuelserpa commented Sep 15, 2022

I think this is the right move, @nwg-piotr.

About the transition, we can use a warning window if people are still using ~/.azotebg with a link informing the changes.

nwg-shell already uses 7 includes. One more makes no special difference.

Then this new include would feel even more elegant.

@nwg-piotr
Copy link
Owner

Alright, this may be done as soon as an opportunity arises, as I mentioned above. For now the idea to include commands is what I like most.

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

Successfully merging this pull request may close these issues.

Support XDG Base Directory specification
3 participants