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

Amiberry insits or creating default directories and theme file even when user-defined paths have been defined #1613

Closed
mrandreastoth opened this issue Jan 26, 2025 · 10 comments
Assignees
Labels

Comments

@mrandreastoth
Copy link

Describe the bug
Amiberry automatically creates the default directories and Default.theme in their default locations completly ignoring the configuration settings in amiberry.conf.

To Reproduce
Steps to reproduce the behavior:

  1. Stop Amiberry

  2. Move ~/.config/amiberry/themes to your Amiberry home directory

  3. Move/rename directories under the Amiberry home directory

  4. Reflect your path changes in the amiberry.conf

  5. Start Amiberry

  6. Observe the ~/.config/amiberry and Amiberry directories as well as the configured paths under the Amiberry GUI

  7. Close Amiberry

  8. Confirm paths in amiberry.conf

Expected behaviour
Amiberry starts up and uses the new directory layout as-is. The GUI reflect the configured paths to be as defined in amiberry.conf. Closing Amiberry keeps the path configurations intact in amiberry.conf.

Actual behaviour
Amiberry starts up and recreates ~/.config/amiberry/themes/Default.theme and all the default Amiberry directories under the Amiberry home directory. The GUI correctly reflect the configured paths and the paths correctly remain intact after closing Amiberry.

Screenshots
User-defined paths...
Image

User-interface using the paths...
Image

Desktop (please complete the following information):

  • OS: EndeavourOS

  • Version: 2024.09.22

Additional context
Amiberry is built from source.

midwan added a commit that referenced this issue Jan 26, 2025
…g the default ones (#1612, #1613)

Change the behavior on startup, regarding the default directories.
Check for the existence of the amiberry.conf file, and if found, load the settings from there, before attempting to create any missing directories.
This should fix the behavior where the default directories were always created, even if you had other paths configured in the conf file.

Also, add the config_path back to the amiberry.conf file, which was removed earlier.
@midwan midwan self-assigned this Jan 26, 2025
@midwan midwan added the bug label Jan 26, 2025
@midwan
Copy link
Collaborator

midwan commented Jan 26, 2025

This should be fixed with the commit above. Please confirm when you get a chance

@mrandreastoth
Copy link
Author

mrandreastoth commented Jan 26, 2025

My workaround is to rename amiberry to amiberry.bin and, in place of the original amiberry, I wrote this executable script called amiberry...

#!/bin/bash

# Use AMIBERRY_HOME_DIR if set, otherwise default to $HOME/Amiberry
AMIBERRY_HOME="${AMIBERRY_HOME_DIR:-$HOME/Amiberry}"

# Remove any trailing slash (if any) for consistency
AMIBERRY_HOME="${AMIBERRY_HOME%/}"

await_and_delete_defaults() {
    while true; do
        # Await until all default directories have been created, including the themes directory
        if [ -d "$AMIBERRY_HOME/cdroms" ] && \
           #[ -d "$AMIBERRY_HOME/conf" ] && \
           #[ -d "$AMIBERRY_HOME/controllers" ] && \
           [ -d "$AMIBERRY_HOME/floppies" ] && \
           [ -d "$AMIBERRY_HOME/harddrives" ] && \
           [ -d "$AMIBERRY_HOME/lha" ] && \
           [ -d "$AMIBERRY_HOME/roms" ] && \
           [ -d "$AMIBERRY_HOME/rp9" ] && \
           [ -d "$AMIBERRY_HOME/savestates" ] && \
           [ -d "$AMIBERRY_HOME/screenshots" ] && \
           [ -d "$XDG_CONFIG_HOME/amiberry/themes" ]; then
            break
        fi

        # Sleep for a short interval before checking again
        sleep 1
    done

    while true; do
        # Await until the Default.theme file appears and is complete
        if [ -f "$XDG_CONFIG_HOME/amiberry/themes/Default.theme" ] && \
           [ $(stat -c %s "$XDG_CONFIG_HOME/amiberry/themes/Default.theme") -eq 216 ]; then
            break
        fi

        # Sleep for a short interval before checking again
        sleep 1
    done

    # Sleep to give any handles time to close
    sleep 1

    # Delete all the default directories, including the themes directory
    rm -rf "$AMIBERRY_HOME/cdroms"
    #rm -rf "$AMIBERRY_HOME/conf"
    #rm -rf "$AMIBERRY_HOME/controllers"
    rm -rf "$AMIBERRY_HOME/floppies"
    rm -rf "$AMIBERRY_HOME/harddrives"
    rm -rf "$AMIBERRY_HOME/lha"
    rm -rf "$AMIBERRY_HOME/roms"
    rm -rf "$AMIBERRY_HOME/rp9"
    rm -rf "$AMIBERRY_HOME/savestates"
    rm -rf "$AMIBERRY_HOME/screenshots"
    rm -rf "$XDG_CONFIG_HOME/amiberry/themes"
}

# Run the cleanup function in the background
await_and_delete_defaults &

# Run the original amiberry binary
/usr/local/bin/amiberry/amiberry.bin "$@"

@mrandreastoth
Copy link
Author

@midwan, please see #1612 (comment).

@giantclambake
Copy link

@midwan

Would it be more correct to place the themes directory under XDG_DATA_HOME? ...ie; ~/.local/share/amiberry/themes

midwan added a commit that referenced this issue Jan 27, 2025
Amiberry/conf was always created on startup, as part of the get_config_directory process.
We should be able to skip that at that step, and only create it if it's missing after loading the amiberry.conf file, since the path might be different there.
@midwan
Copy link
Collaborator

midwan commented Jan 27, 2025

New commit, changes behavior on startup to avoid creating amiberry/conf always. I didn't really test this change much, but hopefully it doesn't break anything :)

@giantclambake I see themes files as global settings (related to the GUI), so I placed them in the XDG_CONFIG_HOME (unless you're using portable mode, in which case they default under the config_path you have). XDG_DATA_HOME is meant for "data" files, which to me at least means things like icons, fonts, etc. https://specifications.freedesktop.org/basedir-spec/latest/

@mrandreastoth
Copy link
Author

@midwan I'll test this change next.

@mrandreastoth
Copy link
Author

@midwan, I have both good and bad news, but no ugly ones 😝. The good news is that conf is no longer created. The bad news, and this is a new one that I haven't reported before as I wasn't aware of the directory due to some dyslexia on my part, is that the ~/.local/share/amiberry directory is still created although, in my case, it is not used by any of the configured paths.

config_path=/home/andreas/Amiberry/configurations/
controllers_path=/home/andreas/Amiberry/controllers/
retroarch_config=/home/andreas/.config/amiberry/retroarch.cfg
whdboot_path=/home/andreas/Amiberry/whdboot/
whdload_arch_path=/home/andreas/Amiberry/media/floppy_disks/whdload/
floppy_path=/home/andreas/Amiberry/media/floppy_disks/adf/
harddrive_path=/home/andreas/Amiberry/media/hard_disks/
cdrom_path=/home/andreas/Amiberry/media/optical_discs/
logfile_path=/home/andreas/Amiberry/save/amiberry.log
rom_path=/home/andreas/Amiberry/amiga/roms/
rp9_path=/home/andreas/Amiberry/media/floppy_disks/rp9/
floppy_sounds_dir=/home/andreas/Amiberry/amiga/floppy_sounds/
saveimage_dir=/home/andreas/Amiberry/save/disk_images/
savestate_dir=/home/andreas/Amiberry/save/states/
screenshot_dir=/home/andreas/Amiberry/save/screenshots/
ripper_path=/home/andreas/Amiberry/save/disk_rips/
inputrecordings_dir=/home/andreas/Amiberry/save/input_logs/
nvram_dir=/home/andreas/Amiberry/save/nvram/
plugins_dir=/home/andreas/Amiberry/plugins/
video_dir=/home/andreas/Amiberry/save/videos/
themes_path=/home/andreas/Amiberry/themes/

@midwan
Copy link
Collaborator

midwan commented Jan 28, 2025

@mrandreastoth
That directory should contain the necessary data files, doesn't it?

@mrandreastoth
Copy link
Author

@midwan, yes, if using the defaults, then that would be the case, but I'm using the paths shown above, i.e., these are defined in amiiberry.conf, and, as you can tell, all the data is now self-contained within the Amiberry home directory. As such the ~/.local/share/amiberry directory is never referenced and should hence never be created.

@midwan
Copy link
Collaborator

midwan commented Jan 28, 2025

The data files is not configurable, and contains the GUI elements required, such as icons, font, etc. Don't you have those in there?

@midwan midwan closed this as completed Jan 30, 2025
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

3 participants