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

[Feature Request] Save and restore jgmenu csv files #4

Open
clemencyworld1 opened this issue Mar 18, 2024 · 7 comments
Open

[Feature Request] Save and restore jgmenu csv files #4

clemencyworld1 opened this issue Mar 18, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@clemencyworld1
Copy link

Thanks for this wonderful tool. I use it a lot.

I will plead that if possible let the script be able to save append.csv and prepend.csv in jgmenu folder to enable complete restoration of jgmenu configuration.

Thanks

@clemencyworld1
Copy link
Author

Also, if there is a way to edit it to add this functionality let me know. I was a bit overwhelmed by the size of the codes.

@johnraff
Copy link
Member

johnraff commented Mar 23, 2024

Hi @clemencyworld1 thank you for your interest in improving BunsenLabs!
I think from your message you might be referring to the "BLOB Theme Manager", which is packaged as bunsen-blob

I am transferring your issue to that repository, so let's continue the discussion there.

@johnraff johnraff transferred this issue from BunsenLabs/bunsen-themes Mar 23, 2024
@johnraff johnraff added the enhancement New feature or request label Mar 23, 2024
@johnraff
Copy link
Member

johnraff commented Apr 5, 2024

Sorry to be so late in returning to this.

The basic concept of BLOB is to be able to save and restore a graphics setup. That includes the jgmenu appearance set in jgmenurc, but not the actual menu content set in prepend.csv and append.csv. If BLOB were to start saving program configurations affecting things other than appearance, then there would be no end to what files could be saved.

But there is a grey area - for example ~/.bashrc can be saved, containing settings other than appearance - so I could imagine people wanting to save different menus for different desktop setups. I'm now not sure if BLOB should go down this road or not, but meanwhile can offer some hints if you want to try extending the script yourself. Agreed, at 3,000 lines it is a bit overwhelming.

Saving/restoring a single, or two, files should be relatively simple. Relatively...

  1. Around line 180, edit the whole JGMENU block to look like this::
JGMENUPATH=".config/jgmenu"
JGMENURC="$JGMENUPATH/jgmenurc" # jgmenu theming, not menu content
JGMENUCONT1="$JGMENUPATH/append.csv" # jgmenu content
JGMENUCONT2="$JGMENUPATH/prepend.csv" # jgmenu content

(now line numbers have shifted by 2)

  1. At line 340, add PICKJGMENUCONT="jgmenu content"

  2. At line 1644, extend the configs array with "$PICKJGMENUCONT"

  3. At line 1674 add this block:

            "$PICKJGMENUCONT")  getJgmenuContent
                            ;;

before the existing "$pickterm" entry, so the line count has gone up by 2 now.

  1. Now we need a new function getJgmenuContent(), it can go anywhere, but just after getJgmenu at line 1470 paste in this:
function getJgmenuContent(){
    local file txt txt2=''
    [[ -r $HOME/$JGMENUCONT1 || -r $HOME/$JGMENUCONT2 ]] || {
        debug "No jgmenu contents files, not saving"
        return 0
    }
    for file in "$JGMENUCONT1" "$JGMENUCONT2"
    do
        filename=${file##*/}
        [[ -r $HOME/$file ]] && {
            txt2+="$filename "
            debug "Saving $HOME/$file"
            saveFiles "$file" || {
                echo "$0: Failed to save jgmenu contents file $file" >&2
                return 1
            }
        }
    done
    txt="jgmenu contents: ~/$JGMENUPATH/ ${txt2}\n"
    debug "\n  Saved $txt"
    echo "[JGMENUCONT] $txt2" >> "$SETTINGS"
    echo -e "$txt" >> "$LISTMSG"
}
  1. Sorry, I'm out of time now, so the restore section will have to wait, but you could have a look starting around 2798 adding something with $PICKJGMENUCONT

Also the above code hasn't been tested at all.
A quick test now suggests that either or both append.csv and prepend.csv are saved correctly.

@clemencyworld1
Copy link
Author

clemencyworld1 commented Apr 6, 2024 via email

@johnraff
Copy link
Member

johnraff commented Apr 6, 2024

Also the above code hasn't been tested at all.

I've tested the "save" function and edited the above code a bit. I think it now saves append.csv and prepend.csv (if they exist) to the BLOB folder, and adds an entry to the settings file. Since we're both a bit busy right now, I'll add the "restore" functionality in a couple of days. If it worked OK for you we could consider adding it to the BunsenLabs package.

@johnraff
Copy link
Member

johnraff commented Apr 9, 2024

To be able to restore saved jgmenu content (prepend.csv and append.csv) from a saved BLOB config, add this code to bl-obthemes:
From line 2679, after the [JGMENU] block, add this:

            "[JGMENUCONT]"      )   labels+=("$PICKJGMENUCONT")
                                values["$PICKJGMENUCONT"]="$VAL"
                                ;;

From line 2808, after the "$PICKJGMENU" block, add this:

            "$PICKJGMENUCONT"   ) [[ -r  "$THEMEPATH/user/$JGMENUCONT1" ]] && {
                                    debug "restoring $THEMEPATH/user/$JGMENUCONT1"
                                    restoreFiles "$JGMENUCONT1"
                                }
                                [[ -r  "$THEMEPATH/user/$JGMENUCONT2" ]] && {
                                    debug "restoring $THEMEPATH/user/$JGMENUCONT2"
                                    restoreFiles "$JGMENUCONT2"
                                }
                                ;;

That should enable you to save and restore the append and prepend files.

@johnraff
Copy link
Member

johnraff commented Apr 9, 2024

I still feel a bit reluctant to add this functionality to the default script, though, because a careless user trying out a different theme style might accidentally wipe out their carefully customized menu contents! We would need to add some more checks and warnings to make sure that didn't happen.

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

No branches or pull requests

2 participants