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

Make the config editor symlink friendly #740

Closed
bonecountysheriff opened this issue Apr 23, 2021 · 8 comments
Closed

Make the config editor symlink friendly #740

bonecountysheriff opened this issue Apr 23, 2021 · 8 comments
Labels

Comments

@bonecountysheriff
Copy link

When you change a setting, lxqt-config seems to delete any existing config, then make a new one, rather than editing the existing config file in place. Even if the file is a symlink, the editor replaces the symlink rather than following it and replacing the file.

I am using a symlink manager (GNU stow) in order to sync my desktop configuration across the devices I use. So the above behavior is a problem.

❯ lxqt-config --version
lxqt-config 0.16.1
liblxqt   0.16.0
Qt        5.15.1

I am testing this on archlinux.

Expected Behavior

Follow the symlink, replace the actual file with the new config file.
Both the initial and the final structure must look like this.

~/.config/lxqt/lxqt.conf -> ~/.dotfiles/.config/lxqt/lxqt.conf (symlink)
~/.dotfiles/.config/lxqt/lxqt.conf (actual file)
Current Behavior

The symlink is being replaced instead.
This is how it looks after the replacement.

~/.config/lxqt/lxqt.conf (new config file)
~/.dotfiles/.config/lxqt/lxqt.conf (old config file)
Possible Solution

Follow the symlink chain, then replace the actual file (either in-place or by replacing).

Steps to Reproduce (for bugs)
  1. Change a setting in lxqt-config and save.
Context

Using dotfiles to sync config across linux machines.

System Information
  • Distribution & Version: Archlinux, rolling
  • Kernel: 5.11.11
  • Qt Version: 5.15.1
  • liblxqt Version: 0.16.0
  • lxqt-build-tools Version: 0.8.0
  • Package version: 0.16.1
@palinek
Copy link
Contributor

palinek commented Apr 23, 2021

Well, this should probably be reported upstream as we don't manipulate config files directly but using the Qt's QSettings...

@tsujan
Copy link
Member

tsujan commented Apr 23, 2021

lxqt-config seems to delete any existing config, then make a new one

lxqt-config or LXQt doesn't; QSettings does.

@tsujan
Copy link
Member

tsujan commented Apr 23, 2021

As far as I remember, when writing to a config file, QSettings uses QSaveFile, which guarantees not losing data if writing fails (that's especially important on quitting). QSaveFile writes to a temporary file and then moves that file to the original file; hence the removal of symlinks.

@bonecountysheriff
Copy link
Author

bonecountysheriff commented Apr 24, 2021

Alright, thanks for giving me a start.

@tsujan, I just want to confirm.
Is this the file?
https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/io/qsavefile.cpp

@tsujan
Copy link
Member

tsujan commented Apr 24, 2021

Is this the file?

Yes.

What I said was in my memory; didn't check Qt's source. If you want to know exactly what happens, you'll need to read Qt → src/corelib/io/qsettings.cpp and its related files.

Anyway, LXQt doesn't reinvent the wheel. In most places, it uses QSettings, whether directly or indirectly. In a few places — especially in libfm-qt — it uses GLib's GKeyFile, which does the same thing, more or less.

@bonecountysheriff
Copy link
Author

Too bad they decided not to go with it.
https://bugreports.qt.io/browse/QTBUG-93085

@tsujan
Copy link
Member

tsujan commented Apr 26, 2021

I think config files are too important to depend on arbitrary files (symlinks). Although I've seen that Qt devs have sometime made bad decisions, IMO, this isn't one of them: it's the best way of handling config files.

@QiangF
Copy link

QiangF commented Dec 18, 2022

symlinks seem to work for me now. I am using Arch linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants