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
siamhie
Global Moderator
Posts: 3214
Joined: Fri Aug 20, 2021 5:45 pm

Re: Sort and improve readability of init

#31 Post by siamhie »

Melber wrote: Tue Feb 25, 2025 6:44 pm yep
Melber wrote: Sun Feb 23, 2025 3:04 pm seems like rootMenu --> Settings --> Configure --> anything results in an init rewrite
I was wondering if a custom version of the file wouldn't get over written as opposed to the stock version but it seems like it does.
This is my Fluxbox . There are many others like it, but this one is mine. My Fluxbox is my best friend. It is my life.
I must master it as I must master my life. Without me, my Fluxbox is useless. Without my Fluxbox, I am useless.

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

Re: Sort and improve readability of init

#32 Post by Jerry3904 »

That's precisely why I suggested a restore script and Melber created it.
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: 1070
Joined: Tue Jun 30, 2015 12:26 am

Re: Sort and improve readability of init

#33 Post by i_ri »

Hello Jerry3904
Your fluxbox menu item calling a script that structures /init into a custom format before viewing, is born. You did it.
Any thing short of that is chat. here is chat.
A sort command that mimics the mechanics where custom format takes the place of sort gives a sorted view that has been saved: short sort:
sort -o ~/.fluxbox/init ~/.fluxbox/init &&xdg-open ~/.fluxbox/init

shorter sort: from a file manager /.fluxbox/init Open With featherpad.
From featherpad menu bar
Edit >Select All
Edit >Sort Lines

gives a sorted view, same as above command, that has not yet been saved.

Half measures but pleasing. just chat. {config_init_restore} is beyond this chat. congratulations.

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

Re: Sort and improve readability of init

#34 Post by i_ri »

Melber. append lines from grep toolbar.button
?
toolbar.tools will grep more than one line when tint2 toggles off systemtray. ? can it grep toggle plus tools to differentiate lines? somehow you will solve duplicate lines.

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

Re: Sort and improve readability of init

#35 Post by i_ri »

Hello Melber
did an addition for toolbar buttons
to your post number 28 script.
toolbar_item_0=$(grep 'toolbar.button' $init_location)
and down in echo
$toolbar_item_0

it printed the four lines for two buttons.
"...#####TOOLBAR#####
session.screen0.toolbar.button.root.label: pop
session.screen0.toolbar.button.root.commands: :ToggleCmd {CustomMenu /home/demo/.fluxbox/submenus/menupop}{HideMenus}
session.screen0.toolbar.button.pad.label: FF
session.screen0.toolbar.button.pad.commands: Exec featherpad
session.screen0.toolbar.tools: button.root, button.pad, systemtray, workspacename, iconbar, clock... "

"...session.screen0.toolbar.button.pad.commands: Exec featherpad
#toggled-off#session.screen0.toolbar.tools: button.root, button.pad, systemtray, workspacename, iconbar, clock
session.screen0.toolbar.tools: button.root, button.pad, workspacename, iconbar, clock
session.screen0.toolbar.visible: false..."

toolbar.tools grep does the same, it prints both lines; regarding tint2. not a problem.
Last edited by i_ri on Wed Feb 26, 2025 6:55 am, edited 1 time in total.

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

Re: Sort and improve readability of init

#36 Post by Jerry3904 »

To wrap this up, here is what I see as the output of this thread:

1) A sorted init of any kind will remain stable as long as all changes are carried out manually using the current MXFB menu items except the [config] entry:

Code: Select all

    [submenu] (Configure)
        [exec] (Apps) {exo-open ~/.fluxbox/apps}
        [exec] (Init) {exo-open ~/.fluxbox/init}
        [exec] (Keys) {exo-open ~/.fluxbox/keys}
        [submenu] (Menus) 
           [exec] (Main) {exo-open ~/.fluxbox/menu-mx}
           [exec] (Appearance) {exo-open ~/.fluxbox/submenus/appearance}
           [exec] (Settings) {exo-open ~/.fluxbox/submenus/settings}
         [exec] (Out of sight) {exo-open ~/.fluxbox/submenus/out-of-sight}
        [end]
        [exec] (Overlay) {exo-open ~/.fluxbox/overlay}
        [exec] (Startup) {featherpad ~/.fluxbox/startup}
        [exec] (Styles) {thunar ~/.fluxbox/styles/}
        [config] (Window) 
        [workspaces] (Workspaces)        
    [end]
2) Anyone wishing to have the sorted init that I started in OP but still use the handy [config] entry can simply add a line to the submenu in 1) to launch Melber's restore script such as the one I posted above .

3) A different sorting pattern would call for a rewrite of the restore script. I mention that b/c I have not had time to return to my initial effort but want to go through the "MISC" category one of these days and add at least a link to an explanation of the individual lines.
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
Melber
Developer
Posts: 1193
Joined: Tue Mar 23, 2021 4:19 pm

Re: Sort and improve readability of init

#37 Post by Melber »

Wrote a hopefully more robust script.
It reads each line of the current init file and sorts into categories according to keywords.
Items with no match end up in the Miscellaneous category.

If you don't want to ovewrite the init file, change

Code: Select all

target_location=$HOME/.fluxbox/init
to another filename or path.

Code: Select all

#!/bin/bash
#script to sort fluxbox init file
#version 2502-3

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 = *window* ]]; then
        window_items+=($item)
    elif [[ $item = *titlebar* ]]; then
        window_items+=($item)
    elif [[ $item = *toolbar* ]]; then
        toolbar_items+=($item)
    elif [[ $item = *time* ]]; then
        toolbar_items+=($item)
    elif [[ $item = *workspace* ]]; then
        workspace_items+=($item)
    elif [[ $item = *slit* ]]; then
        slit_items+=($item)
    elif [[ $item = *tab* ]]; then
        tab_items+=($item)
    elif [[ $item = *iconbar* ]]; then
        iconbar_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 = *###* ]]; 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 "\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

exit 0


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

Re: Sort and improve readability of init

#38 Post by Jerry3904 »

Nice upgrade, thanks; will test this weekend.
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
Jerry3904
Administrator
Posts: 23041
Joined: Wed Jul 19, 2006 6:13 am

Re: Sort and improve readability of init

#39 Post by Jerry3904 »

Did some testing: works fine. Then looked more carefully at the MISC category, and moved items that I thought clearly belonged in a particular category (dashed line separates my additions). Also added a HELP at the top.

Code: Select all

#### HELP: https://fluxboxwiki.github.io/category/howtos/en/Editing_the_init_file.html ####

### WINDOW ###
session.screen0.tabs.intitlebar:	true
session.screen0.window.focus.alpha:	255
session.screen0.window.unfocus.alpha:	255
session.screen0.titlebar.left:	Stick 
session.screen0.titlebar.right:	Minimize Maximize Close 
session.screen0.windowMenu:	~/.fluxbox/submenus/windowmenu
session.screen0.showwindowposition:	false
session.screen0.windowPlacement:	RowMinOverlapPlacement
-----
session.screen0.focusNewWindows:	true
session.screen0.fullMaximization:	false
session.screen0.defaultDeco:	NORMAL
session.screen0.clickRaises:	true
session.screen0.autoRaise:	true
session.autoRaiseDelay:	250

### WORKSPACE ###
session.screen0.workspacewarpingverticaloffset:	1
session.screen0.workspacewarpingvertical:	false
session.screen0.workspaceNames:	W-1,W-2,W-3,
session.screen0.workspacewarping:	true
session.screen0.workspacewarpinghorizontal:	true
session.screen0.workspacewarpinghorizontaloffset:	1
session.screen0.workspaces:	2

### TOOLBAR ###
session.screen0.toolbar.visible:	false
session.screen0.toolbar.height:	30
session.screen0.toolbar.onhead:	1
session.screen0.toolbar.alpha:	252
session.screen0.toolbar.autoHide:	false
session.screen0.toolbar.tools:	workspacename, iconbar, clock
session.screen0.toolbar.widthPercent:	66
session.screen0.toolbar.layer:	Normal
session.screen0.toolbar.maxOver:	false
session.screen0.toolbar.placement:	TopCenter
session.screen0.toolbar.autoRaise:	false
session.screen0.strftimeFormat:	%I:%M  %b %d
-----
session.screen0.systray.pinLeft:	
session.screen0.systray.pinRight:

### SLIT ###
session.screen0.slit.layer:	Desktop
session.screen0.slit.onhead:	0
session.screen0.slit.autoRaise:	true
session.screen0.slit.maxOver:	true
session.screen0.slit.acceptKdeDockapps:	true
session.screen0.slit.alpha:	255
session.screen0.slit.placement:	BottomCenter
session.screen0.slit.autoHide:	false
session.slitlistFile:	~/.fluxbox/slitlist

### TABS ###
session.screen0.tab.placement:	TopLeft
session.screen0.tab.width:	64
session.screen0.tabs.usePixmap:	true
session.screen0.tabs.maxOver:	false
session.screen0.tabFocusModel:	ClickToTabFocus
session.tabsAttachArea:	Window
session.tabPadding:	0

### ICONBAR ###
session.screen0.iconbar.iconWidth:	128
session.screen0.iconbar.mode:	{static groups}
session.screen0.iconbar.iconifiedPattern:	Left
session.screen0.iconbar.iconTextPadding:	10
session.screen0.iconbar.usePixmap:	true
session.screen0.iconbar.alignment:	Relative

### MENU ###
session.screen0.menu.alpha:	255
session.screen0.menuDelay:	200
session.menuFile:	~/.fluxbox/menu-mx
session.menuSearch:	itemstart
-----
session.screen0.clientMenu.usePixmap:	true

### CONFIG FILES ###
session.styleFile:	/home/jb/.fluxbox/styles/MX-ease-Dark
session.keyFile:	~/.fluxbox/keys
session.appsFile:	~/.fluxbox/apps
session.styleOverlay:	~/.fluxbox/overlay

### MISCELLANEOUS ###

session.screen0.struts.1:	0,0,0,0
session.screen0.opaqueMove:	true
session.screen0.maxDisableResize:	false
session.screen0.noFocusWhileTypingDelay:	0
session.screen0.opaqueResize:	false
session.screen0.allowRemoteActions:	true
session.screen0.edgeResizeSnapThreshold:	0
session.screen0.focusSameHead:	false
session.screen0.tooltipDelay:	500
session.screen0.opaqueResizeDelay:	50
session.screen0.maxDisableMove:	false
session.screen0.edgeSnapThreshold:	10
session.screen0.colPlacementDirection:	TopToBottom
session.screen0.rootCommand:	~/.fehbg -l
session.screen0.struts:	0,0,0,0
session.screen0.rowPlacementDirection:	LeftToRight
session.screen0.focusModel:	ClickFocus
session.screen0.maxIgnoreIncrement:	true
session.cacheLife:	5
session.doubleClickInterval:	250
session.configVersion:	13
session.forcePseudoTransparency:	true
session.colorsPerChannel:	4
session.ignoreBorder:	false
session.cacheMax:	200
Not sure how those changes could be handled, maybe using a temporary alias?
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: 1070
Joined: Tue Jun 30, 2015 12:26 am

Re: Sort and improve readability of init

#40 Post by i_ri »

Hello Jerry3904
Something similar to this addition (?)

Code: Select all

    elif [[ $item = *systray.pin* ]]; then
        toolbar_items+=($item)

Post Reply

Return to “MX Fluxbox Official Release”