Page 1 of 1

Sort and improve readability of init

Posted: Sun Feb 23, 2025 8:30 am
by Jerry3904
Because I'm currently working with a MXFB version that does not have tint2, I've been spending a lot of time with the init file--and am re-experiencing my annoyance at that file's user-unfriendliness. So I've started a project to change that, beginning with a sorted structure: labeling sections and pulling entries together that are often scattered. Here is how far I got early this morning:

Code: Select all

#####WINDOW#####
session.screen0.window.focus.alpha:	255
session.screen0.window.unfocus.alpha:	255
session.screen0.focusNewWindows:	true
session.screen0.windowMenu:	~/.fluxbox/submenus/windowmenu
session.screen0.titlebar.left:	Stick 
session.screen0.titlebar.right:	Minimize Maximize Close 
session.screen0.showwindowposition:	false
session.screen0.windowPlacement:	RowMinOverlapPlacement

#####TOOLBAR#####
session.screen0.toolbar.tools:	button.<menu>, iconbar, systemtray, clock
session.screen0.toolbar.layer:	Normal
session.screen0.toolbar.alpha:	252
session.screen0.toolbar.onhead:	1
session.screen0.toolbar.autoRaise:	false
session.screen0.toolbar.visible:	true
session.screen0.toolbar.height:	16
session.screen0.toolbar.placement:	TopCenter
session.screen0.toolbar.widthPercent:	50
session.screen0.toolbar.maxOver:	false
session.screen0.toolbar.autoHide:	false
session.screen0.strftimeFormat:	%I:%M  %b %d

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

#####TABS#####
session.screen0.tab.placement:	TopLeft
session.screen0.tab.width:	64
session.screen0.struts.1:	0,0,0,0
session.screen0.tabs.usePixmap:	true
session.screen0.tabs.maxOver:	false
session.screen0.tabs.intitlebar:	true

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

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

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

#####CONFIG FILES#####
session.keyFile:	~/.fluxbox/keys
session.appsFile:	~/.fluxbox/apps
session.styleFile:	/usr/share/fluxbox/styles/zimek_darkblue
session.styleOverlay:	~/.fluxbox/overlay

#####MISC#####
session.screen0.colPlacementDirection:	TopToBottom
session.screen0.opaqueMove:	true
session.screen0.allowRemoteActions:	true
session.screen0.struts:	0,0,0,0
session.screen0.fullMaximization:	false
session.screen0.noFocusWhileTypingDelay:	0
session.screen0.opaqueResize:	false
session.screen0.edgeResizeSnapThreshold:	0
session.screen0.maxDisableMove:	false
session.screen0.opaqueResizeDelay:	50
session.screen0.focusSameHead:	false
session.screen0.tabFocusModel:	ClickToTabFocus
session.screen0.rootCommand:	~/.fehbg -l
session.screen0.defaultDeco:	NORMAL
session.screen0.tooltipDelay:	500
session.screen0.edgeSnapThreshold:	10
session.screen0.maxIgnoreIncrement:	true
session.screen0.maxDisableResize:	false
session.screen0.autoRaise:	true
session.screen0.focusModel:	ClickFocus
session.screen0.rowPlacementDirection:	LeftToRight
session.screen0.clickRaises:	true
session.forcePseudoTransparency:	true
session.doubleClickInterval:	250
session.ignoreBorder:	false
session.tabsAttachArea:	Window
session.autoRaiseDelay:	250
session.cacheLife:	5
session.tabPadding:	0
session.colorsPerChannel:	4
session.cacheMax:	200
session.configVersion:	13

Notes
--I just haven't looked yet at the items under MISC carefully
--I haven't tested whether init will actually ignore empty lines

My eventual goal is to provide organization (some items I'm going to have to look up) and figure out how to add help to some of the more obscure items. Any suggestions welcome.

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 9:04 am
by Nokkaelaein
Great initiative. (Pun almost intended!) And argh, if there was a general script that contained definitions for stuff that can be grouped together, then read Fluxbox configuration/theme files, and categorically "beautified" them like this... I'd be super happy. It's something I've been meaning to do myself for the longest time, and just never seem to get around to actually doing it. Argh again.

Yes, my configuration files are aesthetically a mess :P

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 9:28 am
by Jerry3904
Thanks for the encouragement! I'm pretty motivated to work this out for MX-25.

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 10:51 am
by CharlesV
+1 a VERY noble effort!! It is always good to get a little documentation and optimization in files like these. Thank you!

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 11:41 am
by ceeslans
Oh yes, very noble indeed.
But please don't be disappointed when fluxbox overrides this nicely sorted and categorized structure with its own non-structured output. Because it will do so at every [reconfigure] action, or any given configuration setting change in fluxbox configuration... :frown:

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 11:43 am
by Jerry3904
Hmmm, I'll have to check that out, thanks for the warning.

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 12:36 pm
by Jerry3904
Well, I ran a test was on the 32bit Lenovo R500 I'm working with ATM: neither refresh, log out nor reboot changed the sorted init file.

Guess we need to test on other machines--and maybe other inits (I'm on systemd on this machine, you're on devuan?).

EDIT: same result on my personal 64bit laptop.

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 1:21 pm
by ceeslans
Try to execute a [reconfig] command. Or select an other toolbar position from fluxbox's native configuration menu. That screwed up my freshly categorized init file layout in a split second...

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 1:51 pm
by Nokkaelaein
ceeslans wrote: Sun Feb 23, 2025 1:21 pm Try to execute a [reconfig] command. Or select an other toolbar position from fluxbox's native configuration menu. That screwed up my freshly categorized init file layout in a split second...
Cannot reproduce this here, either. Tried it many times, both with an actual [reconfig] command, and also by doing an [exec] (Reconfigure) {fluxbox-remote reconfig} ... Either way, the init file stays grouped, comments intact.

What Fluxbox version are you on? This is the 1.3.7+git20220731-0mx23+1 one, in the MX repo, with all the little improvements and fixes since the more mainstream 2015 version. (One not-so-small aesthetic/usability improvement being, you can do opaque window resizing, which to me is very nice to have in a working environment.) I have configured this version extensively over here, and I've never seen the init file rearrange itself?

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 2:27 pm
by ceeslans
The above screw-up happens on my devuan setup, as well as on my MX23.5-fluxbox and MXFB23.5 setup.
All three are running fluxbox v/1.3.7+git20220731-0mx23+1
Yes, not every 'reconfigure' reaves havoc in the init file --> but as soon as a different toolbar position is selected from fluxbox' native configuration, the above categorized structure is lost.

Can you please try following from the rootMenu:
rootMenu --> Settings --> Configure --> Window --> Toolbar --> Placement --> [select.opposite.position]

fwiw, I can't imagine I'm the only one having this issue...

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 2:39 pm
by Melber
Confirm Cees' toolbar placement rewrites the init file.

Changing the fb-style with mx-tweak also results in an unordered init

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 2:49 pm
by ceeslans
Melber wrote: Sun Feb 23, 2025 2:39 pmConfirm Cees' toolbar placement rewrites the init file.
Changing the fb-style with mx-tweak also results in an unordered init
Thank you (thought I'd gone bonkers)

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 2:52 pm
by Nokkaelaein
Confirmed here as well!

The behavior seems to be: if configuring Fluxbox via the textfiles (i.e. changing the toolbar.placement directly in a text editor) it just never mucks up the init when reloading. Otherwise this would have been evident here as I configure directly via textfiles. Conversely, it seems when configuring it using the menu, it mucks the init up immediately :P when clicking on the menu entry (i.e. a new position for the toolbar), no reloading required.

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 3:04 pm
by Melber
seems like rootMenu --> Settings --> Configure --> anything results in an init rewrite

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 3:05 pm
by Nokkaelaein
Melber wrote: Sun Feb 23, 2025 3:04 pm seems like rootMenu --> Settings --> Configure --> anything results in an init rewrite
Yeah it looks like just blurts out all settings anew into the file, in the predetermined order it's made to do so :-]

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 3:48 pm
by Jerry3904
I have always just used the text files + , so have never seen this problem.

BTW
1) the problem is not in the refresh/reconfigure coding, as I first thought, because if I open the init file and make a change using the menu path, I see that the scramble has already taken place.
2) it also doesn't seem to be a return to fundamental template, as far as I can tell: the init in /etx/X11/Fluxbox is very simple

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 3:49 pm
by Nokkaelaein
Jerry3904 wrote: Sun Feb 23, 2025 3:48 pm I have always just used the text files + , so have never seen this problem.
Yep, same here.

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 4:15 pm
by ceeslans
Changing the fb-style with mx-tweak also results in an unordered init
@Melber's observation should be reason enough to disregard the categorized structure for MX25 - or at least for now, until one can find out how to address this basic fluxbox rewrite process

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 4:20 pm
by Jerry3904
I never had that entire submenu in MXFB until MX-23, and am now thinking of taking it back out--at least for myself.

The entries in our Menu > Settings > Configure (except the last)all bring up the relevant file in the text editor, where changes do not rearrange init that I have seen. Rearrangement only happens if you go through Menu > Settings > Configure > Window, that name being my renaming of the Fluxbox "Configure."

I could imagine a script "config_init_restore" that began by backing up the current init to ~/.restore/fluxbox/ then launched that handy little Window/Configure entry (moved out of the menu to ~/.fluxbix/submenus/) and then finished by restoring the backed up init after using sed to update the changed values. Not sure ATM how that would co-exist with the text editor method.

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 4:45 pm
by siamhie
I prefer going through the root menu as apposed to editing the init file directly.
When setting the opacity of menus, windows and toolbars, it's a simple as scrolling the mouse wheel up and down.


Image

Re: Sort and improve readability of init

Posted: Sun Feb 23, 2025 5:05 pm
by Jerry3904
It is easy, and will not go away.

Re: Sort and improve readability of init

Posted: Mon Feb 24, 2025 4:32 pm
by Melber
@Jerry3904
not particularly elegant, but this script should sort an existing unordered init file and create a copy of the unordered init as ~/.restore/fluxbox/init.bak

+++edit+++
broken script removed, see post 28

Re: Sort and improve readability of init

Posted: Mon Feb 24, 2025 5:46 pm
by Jerry3904
Wow, great beans.! I will give it a spin, thanks.

Re: Sort and improve readability of init

Posted: Tue Feb 25, 2025 9:09 am
by ceeslans
With all due respect (I really do value the work Melber put in this), but what is to be gained from this? Do we restore the backed-up version every time mx-tweak sets another style? Or when a different toolbar position or transparency-level is selected from fluxbox' own configuration menu?
There's nothing wrong with the init line-up that fluxbox creates, is there? Fwiw, whenever manual changes to some hidden setting in ~/fluxbox/init should be made, it's dead easy to open/search/edit in a texteditor...

Re: Sort and improve readability of init

Posted: Tue Feb 25, 2025 9:37 am
by Melber
ceeslans wrote: Tue Feb 25, 2025 9:09 am ...Do we restore the backed-up version every time mx-tweak sets another style? Or when a different toolbar position or transparency-level is selected from fluxbox' own configuration menu?
...
No, agree that would be overkill.
I understood it more as a "Sort init file" option buried somewhere in a fb-submenu, available for those so inclined but equally able to be ignored.

Re: Sort and improve readability of init

Posted: Tue Feb 25, 2025 9:49 am
by Jerry3904
@ceeslans We're exploring a possibility, so it's good that you lay out all the negative arguments.

FWIW: it's something that would be optional in my view. Even if a structured init were ever to become default, it would revert to the Fluxbox default line-up that you like with the first change using the init-shuffling method. Most users would probably never even see it.

I could imagine the possibility of adding a menu entry like this at the bottom of the Window/Config submenu that causes the shuffling;

Code: Select all

[separator]
[exec] (Use structured init) {config_init_restore}
Name may not be ideal...

Re: Sort and improve readability of init

Posted: Tue Feb 25, 2025 1:48 pm
by i_ri
Hello Jerry3904
"whether init will actually ignore empty lines" did You mean blank lines or empty values for a listed Resource?
Undefined Value, for a listed Resource, when the value type is boolean or numerical or text or workspacename or command table exists finite fallback. When the missing value is a path, stylepath, font, pixmapimage, icon, there is dual fallbacks for empty and for incorrect, unresolved entries; time period and outcome can vary when this type of value is missing[empty] in a listed Resource.

Yes sometimes the /init list is in a different order than the last time I saw it. Wish /init list was in an order matching the order of the listing in fluxbox man Resources.
fluxbox reads /init more often than I read /init.
I am content to let fluxbox be the boss of how /init is written.
Thanks Jerry3904, again, your attention to detail keeps mxfluxbox with the best of fluxbox.

Melber. sortinit.
The total count of your Resources is 89.
sleekmason list count is 109 at https://www.linux.com/training-tutorial ... init-file/
My mxfluxbox has Resources count 91 [, without buttons]; System has an alternate /init for comparison of fluxbox defaults, it has Resource count of 19 lines.
Jerry3904's list count is 89, while the toolbar list includes one "button" that has not on the list a corresponding button.name label or commands [91.]
The man has a Resources count of 73. hmmmmmm? Two of those are the button label and button commands which can be of unknown quantity.
tint2 introduces /init .tools toggle off systemtray.
Maybe start script with fluxbox reconfigure, restart or otherwise trigger whatever is found that can change /init? Benefit write this during startup?
tab near window(?) iconbar near toolbar(?)
some misc. could qualify go into tab or window(?)

Re: Sort and improve readability of init

Posted: Tue Feb 25, 2025 6:03 pm
by Melber
@i_ri
Thanks for having a closer look.
You're right, the default generated init has 91 entries. I had just oriented myself on Jerry's list, where these two are missing

Code: Select all

session.screen0.systray.pinLeft:	
session.screen0.systray.pinRight:

I added them to the script and also fixed some fat finger boo-boos which were resulting in missing or multiple entries.
Test at your own risk

Code: Select all

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

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

window_item_1=$(grep 'window.focus.alpha' $init_location)
window_item_2=$(grep 'window.unfocus.alpha' $init_location)
window_item_3=$(grep 'focusNewWindows' $init_location)
window_item_4=$(grep 'windowMenu' $init_location)
window_item_5=$(grep 'titlebar.left' $init_location)
window_item_6=$(grep 'titlebar.right' $init_location)
window_item_7=$(grep 'showwindowposition' $init_location)
window_item_8=$(grep 'windowPlacement' $init_location)

toolbar_item_1=$(grep 'toolbar.tools' $init_location)
toolbar_item_2=$(grep 'toolbar.layer' $init_location)
toolbar_item_3=$(grep 'toolbar.alpha' $init_location)
toolbar_item_4=$(grep 'toolbar.onhead' $init_location)
toolbar_item_5=$(grep 'toolbar.autoRaise' $init_location)
toolbar_item_6=$(grep 'toolbar.visible' $init_location)
toolbar_item_7=$(grep 'toolbar.height' $init_location)
toolbar_item_8=$(grep 'toolbar.placement' $init_location)
toolbar_item_9=$(grep 'toolbar.widthPercent' $init_location)
toolbar_item_10=$(grep 'toolbar.maxOver' $init_location)
toolbar_item_11=$(grep 'toolbar.autoHide' $init_location)
toolbar_item_12=$(grep 'strftimeFormat' $init_location | sed -e 's/%/\%/g')

slit_item_1=$(grep 'slit.acceptKdeDockapps' $init_location)
slit_item_2=$(grep 'slit.layer' $init_location)
slit_item_3=$(grep 'slit.placement' $init_location)
slit_item_4=$(grep 'slit.maxOver' $init_location)
slit_item_5=$(grep 'slit.onhead' $init_location)
slit_item_6=$(grep 'slit.autoRaise' $init_location)
slit_item_7=$(grep 'slit.autoHide' $init_location)
slit_item_8=$(grep 'slit.alpha' $init_location)
slit_item_9=$(grep 'slitlistFile' $init_location)

tab_item_1=$(grep 'tab.placement' $init_location)
tab_item_2=$(grep 'tab.width' $init_location)
tab_item_3=$(grep 'struts:' $init_location)
tab_item_3a=$(grep 'struts.1' $init_location)
tab_item_4=$(grep 'tabs.usePixmap' $init_location)
tab_item_5=$(grep 'tabs.maxOver' $init_location)
tab_item_6=$(grep 'tabs.intitlebar' $init_location)

iconbar_item_1=$(grep 'iconbar.alignment' $init_location)
iconbar_item_2=$(grep 'iconbar.mode' $init_location)
iconbar_item_3=$(grep 'iconbar.usePixmap' $init_location)
iconbar_item_4=$(grep 'iconbar.iconWidth' $init_location)
iconbar_item_5=$(grep 'iconbar.iconifiedPattern' $init_location)
iconbar_item_6=$(grep 'iconbar.iconTextPadding' $init_location)

workspace_item_1=$(grep 'workspaces' $init_location)
workspace_item_2=$(grep 'workspaceNames' $init_location)
workspace_item_3=$(grep 'workspacewarping:' $init_location)
workspace_item_4=$(grep 'workspacewarpinghorizontal:' $init_location)
workspace_item_5=$(grep 'workspacewarpinghorizontaloffset' $init_location)
workspace_item_6=$(grep 'workspacewarpingvertical:' $init_location)
workspace_item_7=$(grep 'workspacewarpingverticaloffset' $init_location)

menu_item_1=$(grep 'clientMenu.usePixmap' $init_location)
menu_item_2=$(grep 'menu.alpha' $init_location)
menu_item_3=$(grep 'menuDelay' $init_location)
menu_item_4=$(grep 'menuFile' $init_location)
menu_item_5=$(grep 'menuSearch' $init_location)

config_item_1=$(grep 'keyFile' $init_location)
config_item_2=$(grep 'appsFile' $init_location)
config_item_3=$(grep 'styleFile' $init_location)
config_item_4=$(grep 'styleOverlay' $init_location)

misc_item_1=$(grep 'colPlacementDirection' $init_location)
misc_item_2=$(grep 'opaqueMove' $init_location)
misc_item_3=$(grep 'allowRemoteActions' $init_location)
misc_item_4=$(grep 'fullMaximization' $init_location)
misc_item_5=$(grep 'noFocusWhileTypingDelay' $init_location)
misc_item_6=$(grep 'opaqueResize:' $init_location)
misc_item_7=$(grep 'edgeResizeSnapThreshold' $init_location)
misc_item_8=$(grep 'maxDisableMove' $init_location)
misc_item_9=$(grep 'opaqueResizeDelay' $init_location)
misc_item_10=$(grep 'focusSameHead' $init_location)
misc_item_11=$(grep 'tabFocusModel' $init_location)
misc_item_12=$(grep 'rootCommand' $init_location)
misc_item_13=$(grep 'defaultDeco' $init_location)
misc_item_14=$(grep 'tooltipDelay' $init_location)
misc_item_15=$(grep 'edgeSnapThreshold' $init_location)
misc_item_16=$(grep 'maxIgnoreIncrement' $init_location)
misc_item_17=$(grep 'maxDisableResize' $init_location)
misc_item_18=$(grep 'session.screen0.autoRaise' $init_location)
misc_item_19=$(grep 'focusModel' $init_location)
misc_item_20=$(grep 'rowPlacementDirection' $init_location)
misc_item_21=$(grep 'clickRaises' $init_location)
misc_item_22=$(grep 'forcePseudoTransparency' $init_location)
misc_item_23=$(grep 'doubleClickInterval' $init_location)
misc_item_24=$(grep 'ignoreBorder' $init_location)
misc_item_25=$(grep 'tabsAttachArea' $init_location)
misc_item_26=$(grep 'autoRaiseDelay' $init_location)
misc_item_27=$(grep 'cacheLife' $init_location)
misc_item_28=$(grep 'tabPadding' $init_location)
misc_item_29=$(grep 'colorsPerChannel' $init_location)
misc_item_30=$(grep 'cacheMax' $init_location)
misc_item_31=$(grep 'configVersion' $init_location)
misc_item_32=$(grep 'systray.pinLeft' $init_location)
misc_item_33=$(grep 'systray.pinRight' $init_location)

#####

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

cp $init_location $backup_location/init.bak


#####

echo "
##### MX-Fluxbox sorted init #####

#####WINDOW#####
$window_item_1
$window_item_2
$window_item_3
$window_item_4
$window_item_5
$window_item_6
$window_item_7
$window_item_8

#####TOOLBAR#####
$toolbar_item_1
$toolbar_item_2
$toolbar_item_3
$toolbar_item_4
$toolbar_item_5
$toolbar_item_6
$toolbar_item_7
$toolbar_item_8
$toolbar_item_9
$toolbar_item_10
$toolbar_item_11
$toolbar_item_12

#####SLIT#####
$slit_item_1
$slit_item_2
$slit_item_3
$slit_item_4
$slit_item_5
$slit_item_6
$slit_item_7
$slit_item_8
$slit_item_9

#####TABS#####
$tab_item_1
$tab_item_2
$tab_item_3
$tab_item_3a
$tab_item_4
$tab_item_5
$tab_item_6

#####ICONBAR#####
$iconbar_item_1
$iconbar_item_2
$iconbar_item_3
$iconbar_item_4
$iconbar_item_5
$iconbar_item_6

#####WORKSPACE#####
$workspace_item_1
$workspace_item_2
$workspace_item_3
$workspace_item_4
$workspace_item_5
$workspace_item_6
$workspace_item_7

#####MENUS#####
$menu_item_1
$menu_item_2
$menu_item_3
$menu_item_4
$menu_item_5

#####CONFIG FILES#####
$config_item_1
$config_item_2
$config_item_3
$config_item_4

#####MISC#####
$misc_item_1
$misc_item_2
$misc_item_3
$misc_item_4
$misc_item_5
$misc_item_6
$misc_item_7
$misc_item_8
$misc_item_9
$misc_item_10
$misc_item_11
$misc_item_12
$misc_item_13
$misc_item_14
$misc_item_15
$misc_item_16
$misc_item_17
$misc_item_18
$misc_item_19
$misc_item_20
$misc_item_21
$misc_item_22
$misc_item_23
$misc_item_24
$misc_item_25
$misc_item_26
$misc_item_27
$misc_item_28
$misc_item_29
$misc_item_30
$misc_item_31
$misc_item_32
$misc_item_33
" > $init_location

exit 0

Re: Sort and improve readability of init

Posted: Tue Feb 25, 2025 6:19 pm
by siamhie
Any changes made from the root menu > settings > configure menu will have the init file rewritten by fluxbox.

Image


I saved Jerry's layout as init2 and restarted fluxbox as so

Code: Select all

fluxbox -rc init2
When I made just one change within that area, Jerry's layout changed back to fluxbox's layout.

Re: Sort and improve readability of init

Posted: Tue Feb 25, 2025 6:44 pm
by Melber
yep
Melber wrote: Sun Feb 23, 2025 3:04 pm seems like rootMenu --> Settings --> Configure --> anything results in an init rewrite

Re: Sort and improve readability of init

Posted: Tue Feb 25, 2025 8:26 pm
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.

Re: Sort and improve readability of init

Posted: Tue Feb 25, 2025 9:52 pm
by Jerry3904
That's precisely why I suggested a restore script and Melber created it.

Re: Sort and improve readability of init

Posted: Wed Feb 26, 2025 12:01 am
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.

Re: Sort and improve readability of init

Posted: Wed Feb 26, 2025 3:03 am
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.

Re: Sort and improve readability of init

Posted: Wed Feb 26, 2025 6:06 am
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.

Re: Sort and improve readability of init

Posted: Wed Feb 26, 2025 6:54 am
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.

Re: Sort and improve readability of init

Posted: Wed Feb 26, 2025 5:54 pm
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


Re: Sort and improve readability of init

Posted: Wed Feb 26, 2025 6:09 pm
by Jerry3904
Nice upgrade, thanks; will test this weekend.

Re: Sort and improve readability of init

Posted: Sun Mar 02, 2025 5:46 pm
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?

Re: Sort and improve readability of init

Posted: Sun Mar 02, 2025 9:03 pm
by i_ri
Hello Jerry3904
Something similar to this addition (?)

Code: Select all

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

Re: Sort and improve readability of init

Posted: Mon Mar 03, 2025 9:06 am
by Melber
Jerry3904 wrote: Sun Mar 02, 2025 5:46 pm 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.
...
Not sure how those changes could be handled, maybe using a temporary alias?
This should produce an init matching your layout and sorting, including help line at top.

Code: Select all

#!/bin/bash
#script to sort fluxbox init file
#version 2503-1

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 = *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 = *toolbar* ]]; then
        toolbar_items+=($item)
    elif [[ $item = *systray* ]]; 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 = *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 "\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

Re: Sort and improve readability of init

Posted: Mon Mar 03, 2025 10:18 am
by Jerry3904
Great, can test later today.

Re: Sort and improve readability of init

Posted: Mon Mar 03, 2025 6:26 pm
by Jerry3904
@Melber It works like a charm!

Now we have to figure out how to use it, exactly. And how it should be represented in the rootMenj.

More on this later...busy week for me.

Re: Sort and improve readability of init

Posted: Mon Mar 03, 2025 8:16 pm
by i_ri
Hello Jerry3904 and Melber
arrangewindows
arrangewindowshorizontal
arrangewindowsstackbottom
arrangewindowsstackleft
arrangewindowsstackright
arrangewindowsstacktop
arrangewindowsvertical
closeallwindows
nextwindow
prevwindow
windowmenu

Achilles says, the appearance of any of those commands containing the word window when used on the toolbar.tools,

A search for window prior to search for toolbar will place the toolbar.tools entry into the window category.

nextwindow and prevwindow are common on toolbar.tools.
NextWindow and PrevWindow can prevent this, but the lowercase by a user, accepted by fluxbox, cannot be prevented nor guaranteed uppercase.

Search for toolbar prior to search for window.

the toggledecor Uppercase
ToggleDecor
can put toolbar.tools on the window group,
so place Deco search after toolbar search.
Or alter the search to Deco: or defaultDeco or co:

Re: Sort and improve readability of init

Posted: Tue Mar 04, 2025 4:38 am
by Melber
@i_ri

Is this better for you?

Code: Select all

#!/bin/bash
#script to sort fluxbox init file
#version 2503-2

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 = *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 = *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 = *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 "\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

Re: Sort and improve readability of init

Posted: Tue Mar 04, 2025 6:10 am
by Jerry3904
Before my day starts, made a possible restructuring of the Settings submenu


Image

Re: Sort and improve readability of init

Posted: Tue Mar 04, 2025 9:35 am
by siamhie
Jerry3904 wrote: Tue Mar 04, 2025 6:10 am Before my day starts, made a possible restructuring of the Settings submenu (the "toolbar" entry is not there)
So Window has been renamed "Quick config"? and is under the Init submenu?

Re: Sort and improve readability of init

Posted: Tue Mar 04, 2025 10:31 am
by Jerry3904
Yup, along with the new "restore" entry. The combination of bringing it up a level, creating a name closer to the default Fluxbox one and locating it under "init" should IMO make it more visible and less obscure to the user.

True Confession: I did not fully appreciate the value of that entry in the past, so was grateful for the posts by you and @ceeslans about it.

Re: Sort and improve readability of init

Posted: Tue Mar 04, 2025 11:09 am
by siamhie
Jerry3904 wrote: Tue Mar 04, 2025 10:31 am Yup, along with the new "restore" entry. The combination of bringing it up a level, creating a name closer to the default Fluxbox one and locating it under "init" should IMO make it more visible and less obscure to the user.

True Confession: I did not fully appreciate the value of that entry in the past, so was grateful for the posts by you and @ceeslans about it.
OK. I'm only asking because I will have to undo 20 years of muscle memory of where everything is located to configure. I don't edit init by hand (all that much) and prefer to use the menus.
I actually added Workspaces back to my root menu (default setup) as that is what I remember seeing. I usually just middle click to bring up it's menu.

Re: Sort and improve readability of init

Posted: Tue Mar 04, 2025 11:16 am
by Jerry3904
You can keep your menu as it is, right? Any change here will only affect new users. When we go to Trixie, you would just save your existing menu, then after installation paste it back in.

Re: Sort and improve readability of init

Posted: Tue Mar 04, 2025 4:38 pm
by siamhie
Jerry3904 wrote: Tue Mar 04, 2025 11:16 am You can keep your menu as it is, right? Any change here will only affect new users. When we go to Trixie, you would just save your existing menu, then after installation paste it back in.
I backup my HOME directory to another drive every 6 months or so. I add/remove a lot of styles/backgrounds/fonts/icons/etc. and like to keep the most recent version available at all times for new installs.

Re: Sort and improve readability of init

Posted: Tue Mar 04, 2025 8:24 pm
by i_ri
search iconbar before search workspace

Make it known to avoid using the case sensitive search keyword sequences in comments, toolbar.button names and labels, workspace names.

Melber Your script is fantastic. You have remained on track to provide Jerry3904's model.
I selfishly have shared my own model ideas both here and in another topic.
If You have Your own model we will like to see it.

Re: Sort and improve readability of init

Posted: Wed Mar 05, 2025 1:28 am
by i_ri
Hello Jerry3904
Got one into a category:

elif [[ $item = *tooltipDelay:* ]]; then
iconbar_items+=($item)

Re: Sort and improve readability of init

Posted: Wed Mar 05, 2025 6:06 am
by Jerry3904
Thanks.

Re: Sort and improve readability of init

Posted: Wed Mar 05, 2025 10:34 pm
by i_ri
Hello Jerry3904 and Melber
session.screen0.tabs.intitlebar:
Reason to search tab before search titlebar?

Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 10:30 am
by i_ri
Hello Jerry3904 and Everyone
Another category has evidenced itself.
The "do not edit" Category.

Observing two lines that report a value not for editing.
session.configVersion:
session.screen0.slit.direction:

Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 10:45 am
by Jerry3904
I appreciate your ongoing attention here, but I'm done with structure and am now trying to finish out implementation.

BTW: I'm sorry but I don't understand the point of your question about sort order--maybe @Melber does. And I'm not interested in a category with only 2 entries.

Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 11:12 am
by Melber
i_ri wrote: Wed Mar 05, 2025 10:34 pm Hello Jerry3904 and Melber
session.screen0.tabs.intitlebar:
Reason to search tab before search titlebar?
Jerry3904 wrote: Thu Mar 06, 2025 10:45 am BTW: I'm sorry but I don't understand the point of your question about sort order--maybe @Melber does.
i_ri means that session.screen0.tabs.intitlebar gets sorted into the titlebar category rather than the tabs category.

This version searches for "tab" before "titlebar", so that line gets sorted into "tabs".
It also sorts session.screen0.tooltipDelay into the iconbar category as per i_ri's Post #53.

Code: Select all

#!/bin/bash
#script to sort fluxbox init file
#version 2503-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 = *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 = *workspace* ]]; then
        workspace_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 = *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 "\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

Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 11:18 am
by Jerry3904
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)?

Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 11:22 am
by i_ri
showing Reason to search iconbar before search workspace.
session.screen0.iconbar.mode: {static groups} (workspace)

Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 11:52 am
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.

Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 12:02 pm
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?

Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 12:35 pm
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)

Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 4:53 pm
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


Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 5:47 pm
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.)

Re: Sort and improve readability of init

Posted: Thu Mar 06, 2025 6:13 pm
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!

Re: Sort and improve readability of init

Posted: Fri Mar 07, 2025 3:31 am
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.

Re: Sort and improve readability of init

Posted: Fri Mar 07, 2025 4:10 pm
by Melber
Jerry3904 wrote: Thu Mar 06, 2025 6:13 pm Up it goes!
PR made to MX-Linux/mxfb-accessories

Re: Sort and improve readability of init

Posted: Sat Mar 08, 2025 4:15 am
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.

Re: Sort and improve readability of init

Posted: Sat Mar 08, 2025 4:51 am
by Jerry3904
This development is ended for now, thanks


@Melber I'm on the road, will merge next week. Thanks for the good work.