Sort and improve readability of init

Help for MX Fluxbox
When asking for help, use Quick System Info from MX Tools. It will be properly formatted using the following steps.
1. Click on Quick System Info in MX Tools
2. Right click in your post and paste.
Message
Author
User avatar
Melber
Developer
Posts: 1330
Joined: Tue Mar 23, 2021 4:19 pm

Re: Sort and improve readability of init

#61 Post by Melber »

Jerry3904 wrote: Thu Mar 06, 2025 11:18 am Are you ready to upload it to mxfb-accessories? And if yes, how do you want to name it (I have a provisional mxfb-sortinit)?
mxfb-sortinit sounds fine to me. Will upload later.

User avatar
Jerry3904
Administrator
Posts: 23278
Joined: Wed Jul 19, 2006 6:13 am

Re: Sort and improve readability of init

#62 Post by Jerry3904 »

Do we need a little yad of explanation at the beginning? For instance:
This will save your current init file to ~/.restore/fluxbox, sort it into categories and paste it back into ~/.fluxbox.
Ok to proceed?
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
i_ri
Posts: 1106
Joined: Tue Jun 30, 2015 12:26 am

Re: Sort and improve readability of init

#63 Post by i_ri »

Code: Select all

rofi -e " fluxbox /init Saved and prepared for viewing"
messages come with the cost of translation(?)

maybe the command ends with xdg-open /init and the message is
/init backup copy Saved.

it really does not prepare init for viewing later, init might change. it is optimized for viewing Now, so does it get opened Now?
open init from inside the script?
open init additional; mxfb-sortinit && xdg-open /init
?
So your yad might state that a backup Will be created,
and the question is did you wish to open the file.

save without sorting.
sort without saving.
sort and save.
Open file yes or no.
Want choices?
(save meaning backup to .restore)

User avatar
Melber
Developer
Posts: 1330
Joined: Tue Mar 23, 2021 4:19 pm

Re: Sort and improve readability of init

#64 Post by Melber »

Jerry3904 wrote: Thu Mar 06, 2025 12:02 pm Do we need a little yad of explanation at the beginning? For instance:
This will save your current init file to ~/.restore/fluxbox, sort it into categories and paste it back into ~/.fluxbox.
Ok to proceed?
Seems a bit OTT to me.
I edited the script to add the following after the ### Help ### line at the top of the sorted init file instead

Code: Select all

### A backup copy of the current init file has been saved in $backup_location/init.bak  ###
-----
i_ri wrote: Thu Mar 06, 2025 12:35 pm ...it really does not prepare init for viewing later, init might change. it is optimized for viewing Now, so does it get opened Now?
open init from inside the script?
You're right, the script is really only useful if the init file is opened directly after running it.
I added the exo-open command at the end of the script, so the init file is opened directly after sorting.

-----

Rather than creating a new submenu item for sortinit, it makes more sense to me to change the current menu>settings>configure>init from

Code: Select all

[exec] (Init) {exo-open ~/.fluxbox/init}
to

Code: Select all

[exec] (Init) {mxfb-sortinit}
and just have the sorted init file open from there.


Last version with above changes before I upload to github

Code: Select all

#!/bin/bash
#mxfb-sortinit - script to sort fluxbox init file by Melber and i_ri
#version 2503-4

init_location=$HOME/.fluxbox/init
backup_location=$HOME/.restore/fluxbox
target_location=$HOME/.fluxbox/init

OLDIFS=$IFS
IFS="|"

while read -r item; do

    if [[ $item = *toolbar* ]]; then
        toolbar_items+=($item)
    elif [[ $item = *systray* ]]; then
        toolbar_items+=($item)
    elif [[ $item = *time* ]]; then
        toolbar_items+=($item)
    elif [[ $item = *tab* ]]; then
        tab_items+=($item)
    elif [[ $item = *window* ]]; then
        window_items+=($item)
    elif [[ $item = *NewWindows* ]]; then
        window_items+=($item)
    elif [[ $item = *Maximization* ]]; then
        window_items+=($item)
    elif [[ $item = *Deco* ]]; then
        window_items+=($item)
    elif [[ $item = *titlebar* ]]; then
        window_items+=($item)
    elif [[ $item = *slit* ]]; then
        slit_items+=($item)
    elif [[ $item = *iconbar* ]]; then
        iconbar_items+=($item)
    elif [[ $item = *tooltipDelay* ]]; then
        iconbar_items+=($item)
    elif [[ $item = *workspace* ]]; then
        workspace_items+=($item)
    elif [[ $item = *menu* ]]; then
        menu_items+=($item)
    elif [[ $item = *Menu* ]]; then
        menu_items+=($item)
    elif [[ $item = *File* ]]; then
        config_items+=($item)
    elif [[ $item = *Overlay* ]]; then
        config_items+=($item)
    elif [[ $item = *Raise* ]]; then
        window_items+=($item)
    elif [[ $item = *##* ]]; then
        trash_items+=($item)
    else
        misc_items+=($item)
    fi

done < $init_location

#####

if [ ! -d $backup_location ]; then
    mkdir -p $backup_location
fi

cp $init_location $backup_location/init.bak


#####
printf '### HELP: https://fluxboxwiki.github.io/category/howtos/en/Editing_the_init_file.html ###\n' > $target_location
printf "### A backup copy of the current init file has been saved in $backup_location/init.bak  ###\n" >> $target_location
printf "\n### WINDOW ###\n" >> $target_location
printf '%s\n' "${window_items[@]}" >> $target_location
printf "\n### WORKSPACE ###\n" >> $target_location
printf '%s\n' "${workspace_items[@]}" >> $target_location
printf "\n### TOOLBAR ###\n" >> $target_location
printf '%s\n' "${toolbar_items[@]}" >> $target_location
printf "\n### SLIT ###\n" >> $target_location
printf '%s\n' "${slit_items[@]}" >> $target_location
printf "\n### TABS ###\n" >> $target_location
printf '%s\n' "${tab_items[@]}" >> $target_location
printf "\n### ICONBAR ###\n" >> $target_location
printf '%s\n' "${iconbar_items[@]}" >> $target_location
printf "\n### MENU ###\n" >> $target_location
printf '%s\n' "${menu_items[@]}" >> $target_location
printf "\n### CONFIG FILES ###\n" >> $target_location
printf '%s\n' "${config_items[@]}" >> $target_location
printf "\n### MISCELLANEOUS ###\n" >> $target_location
printf '%s\n' "${misc_items[@]}" >> $target_location


IFS=$OLDIFS

exo-open $target_location

exit 0


User avatar
i_ri
Posts: 1106
Joined: Tue Jun 30, 2015 12:26 am

Re: Sort and improve readability of init

#65 Post by i_ri »

Hello
Melber wrote it. I did testing. I did not write any bit of it.
The Open file being the messenger is a good thought Melber.
Sorted file looks different when alphabetized (<sort>) before sortinit.
(different is bad choice of word. It looks more the same every time when alphabetized before sortinit.)

User avatar
Jerry3904
Administrator
Posts: 23278
Joined: Wed Jul 19, 2006 6:13 am

Re: Sort and improve readability of init

#66 Post by Jerry3904 »

@Melber Looks good. I like launching the file at the end b/c now the help and info are immediately visible.

Up it goes!
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
i_ri
Posts: 1106
Joined: Tue Jun 30, 2015 12:26 am

Re: Sort and improve readability of init

#67 Post by i_ri »

Hello Jerry3904 and Melber
You together have finished many great features.
Over time, Melber007 fits in there somewhere.
This one is Melbersortinit007

congratulations.

User avatar
Melber
Developer
Posts: 1330
Joined: Tue Mar 23, 2021 4:19 pm

Re: Sort and improve readability of init

#68 Post by Melber »

Jerry3904 wrote: Thu Mar 06, 2025 6:13 pm Up it goes!
PR made to MX-Linux/mxfb-accessories

User avatar
i_ri
Posts: 1106
Joined: Tue Jun 30, 2015 12:26 am

Re: Sort and improve readability of init

#69 Post by i_ri »

toggletint2 interacts with /.restore
BACKDIR="$HOME/.restore/fluxbox"
INITBAK="$BACKDIR/init.$(date +%Y%m%d_%H%M%S).bak"
STRTBAK="$BACKDIR/startup.$(date +%Y%m%d_%H%M%S).bak"

Does sortinit want to have the same naming sequence? based on date +%Y%m%d_%H%M%S

/init.$(date +%Y%m%d_%H%M%S).bak

(?)
I do like the /init.bak simplicity there now; fitting into existing is a ponder.

User avatar
Jerry3904
Administrator
Posts: 23278
Joined: Wed Jul 19, 2006 6:13 am

Re: Sort and improve readability of init

#70 Post by Jerry3904 »

This development is ended for now, thanks


@Melber I'm on the road, will merge next week. Thanks for the good work.
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

Post Reply

Return to “MX Fluxbox Official Release”