Prayag2 / konsave

A command line program written in Python to let you backup your dotfiles and switch to other ones in an instant. Works out-of-the box on KDE Plasma!
GNU General Public License v3.0
945 stars 34 forks source link

Importing settings in chroot user enviorment during Arch installation breaks export and/or save #95

Closed Martan404 closed 9 months ago

Martan404 commented 1 year ago

Describe the bug I am in the process of making an Arch install script and I am trying to import and apply all the KDE plasma customization inside chroot before first boot. Importing and applying the settings works but if I try to use konsave -s, konsave -e after my first boot then konsave will return empty export and save folders with only a conf.yaml file

At first I got this error when trying to import. This results in only part of the settings being imported

Konsave: Importing profile. It might take a minute or two...
Konsave: Importing "plasma"...
Konsave: [Errno 2] No such file or directory: '/home/martin/.local/share/plasma'
Please check the log at /home/martin/.cache/konsave_log.txt for more details.
Konsave: Importing "kwin"...
Konsave: Importing "konsole"...
Konsave: [Errno 2] No such file or directory: '/home/martin/.local/share/konsole'
Please check the log at /home/martin/.cache/konsave_log.txt for more details.
Konsave: Importing "fonts"...
Konsave: Importing "color-schemes"...
Konsave: Importing "aurorae"...
Konsave: Importing "icons"...
Konsave: Importing "wallpapers"...
Konsave: Importing ".fonts"...
Konsave: Importing ".themes"...
Konsave: Importing ".icons"...
Konsave: Profile successfully imported!
Konsave: copying files...
Konsave: [Errno 2] No such file or directory: '/home/martin/.local/share/kxmlgui5'
Please check the log at /home/martin/.cache/konsave_log.txt for more details.
Konsave: Profile applied successfully! Please log-out and log-in to see the changes completely!

Here's the konsave log

[03/09/2023 21:48:56]
Traceback (most recent call last):
  File "/home/martin/.local/pipx/venvs/konsave/lib/python3.11/site-packages/konsave/funcs.py", line 40, in in>
    function = func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/.local/pipx/venvs/konsave/lib/python3.11/site-packages/konsave/funcs.py", line 103, in c>
    os.mkdir(dest)
FileNotFoundError: [Errno 2] No such file or directory: '/home/martin/.local/share/plasma'

[03/09/2023 21:48:56]
Traceback (most recent call last):
  File "/home/martin/.local/pipx/venvs/konsave/lib/python3.11/site-packages/konsave/funcs.py", line 40, in in>
    function = func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/.local/pipx/venvs/konsave/lib/python3.11/site-packages/konsave/funcs.py", line 103, in c>
    os.mkdir(dest)
FileNotFoundError: [Errno 2] No such file or directory: '/home/martin/.local/share/konsole'

[03/09/2023 21:48:57]
Traceback (most recent call last):
  File "/home/martin/.local/pipx/venvs/konsave/lib/python3.11/site-packages/konsave/funcs.py", line 40, in in>
    function = func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/.local/pipx/venvs/konsave/lib/python3.11/site-packages/konsave/funcs.py", line 103, in c>
    os.mkdir(dest)
FileNotFoundError: [Errno 2] No such file or directory: '/home/martin/.local/share/kxmlgui5'

If I instead create the folders before importing the settings, like this

mkdir -p /home/$user/.local/share/plasma && chmod 744 /home/$user/.local/share/plasma
mkdir -p /home/$user/.local/share/konsole && chmod 744 /home/$user/.local/share/konsole
mkdir -p /home/$user/.local/share/kxmlgui5 && chmod 744 /home/$user/.local/share/kxmlgui5

then I get no error, all the settings import properly but I can still not use the konsave -s, konsave -e commands. I also tried creating the folders inside my script and then using konsave normaly after first boot with no problems so I am pretty sure that is not the issue.

My script works fine until sudo -u $user konsave -i /home/$user/kde-settings.knsv.

To reproduce Install Arch completely. Inside chroot before first boot run the command konsave -i

Expected behavior I expect the konsave -s and konsave -e command to work after using konsave -i inside chroot

System information

Additional context Here's the script I am working on https://github.com/Martan404/Archer/blob/944360399ff6ff7c5e412622466eafe14d947d90/archer.sh#L966 The konsave -i command is run on line 966

Martan404 commented 1 year ago

I guess running in chroot is probably a bad idea since KDE hasn't generated any files when you try to run it during an Arch install. I got the inspiration from Chris' ArchTitus script. Maybe Konsave could throw an error if it's ran in chroot?

I managed to work around it by creating a shell script at $HOME/.config/plasma-workspace/env

This is how I went about it

# Install konsave
sudo -u $user pipx install konsave

# Download settings.knsv
sudo -u $user curl -L https://github.com/Martan404/Archer/raw/main/quiver/archer.knsv > /home/$user/archer.knsv

# Create folder and script as user 
sudo -u $user mkdir -p /home/$user/.config/plasma-workspace/env
sudo -u $user touch /home/$user/.config/plasma-workspace/env/archer_setup.sh

# Write script
cat <<-END >> /home/$user/.config/plasma-workspace/env/archer_setup.sh
#!/usr/bin/env bash

sudo -u $user konsave -i /home/$user/archer.knsv
read -t 1
sudo -u $user konsave -a archer

rm -f /home/$user/archer.knsv
rm -f /home/$user/.config/plasma-workspace/env/archer_setup.sh

END
chmod a+x /home/$user/.config/plasma-workspace/env/archer_setup.sh
Prayag2 commented 9 months ago

This issue is a duplicate of https://github.com/Prayag2/konsave/issues/89. I'll fix this as soon as possible!