Shiva wrote: ⤴Wed Dec 13, 2023 6:04 pm
I would guess that the devs have implemented mechanisms to ignore odd settings and probably reset them to something that works if the matrix doesn't fit [...]
Indeed looking at
/usr/share/cinnamon/js/ui/panel.js we see:
const VALID_ICON_SIZE_VALUES = [-1, 0, 16, 22, 24, 32, 48];
somewhere at the top of the file (some values might have been added or changed in newer Mint, I use Mint 19.2).
And down below there is a function called
toStandardIconSize(maxSize)
which normalizes icon size according to nearest lower valid value.
Therefore any odd value entered by the user will automatically fall into one of the standard values established by that script. That is why OP's script wouldn't "take" the values provided within it.
Of course the valid values array can be modified to add whatever other values the user sees fit but the aforementioned function would also have to be modified in order to accomodate those values, and there also is the need to add those extra values to another file, as well as a possible need to alter panel's max height (or width, for vertical panels) in case icon values are higher than current max.
That would be done in
/usr/share/cinnamon/cinnamon-settings/modules/cs_panel.py by modifying the
maxi value in the line looking more or less like this:
widget = PanelRange(dimension_text, "org.cinnamon", "panels-height", self.panel_id, _("Smaller"), _("Larger"), mini=20, maxi=60, show_value=True)
for panel height/width, and by adding similarly formatted value pair arrays in the
options array below it that looks like this:
Code: Select all
options = [
[-1, _("Scale to panel size exactly")],
[0, _("Scale to panel size optimally")],
[16, '16px'],
[22, '22px'],
...
For a practical example here is what I have done in my own Mint 19.2.
/usr/share/cinnamon/js/ui/panel.js
const VALID_ICON_SIZE_VALUES = [-1, 0, 16, 22, 24, 32, 40, 48, 52, 56, 60, 64, 72, 80, 96, 128];
Code: Select all
function toStandardIconSize(maxSize) {
maxSize = Math.floor(maxSize);
if (maxSize < 22) return 16;
else if (maxSize < 24) return 22;
else if (maxSize < 32) return 24;
else if (maxSize < 40) return 32;
else if (maxSize < 48) return 40;
else if (maxSize < 52) return 48;
else if (maxSize < 56) return 52;
else if (maxSize < 60) return 56;
else if (maxSize < 64) return 60;
else if (maxSize < 72) return 64;
else if (maxSize < 80) return 72;
else if (maxSize < 96) return 80;
else if (maxSize < 128) return 96;
// Panel icons reach 128 at most with the largest panel, also on hidpi
global.log("maxSize fell through as %d".format(maxSize));
return 128;
}
/usr/share/cinnamon/cinnamon-settings/modules/cs_panel.py
widget = PanelRange(dimension_text, "org.cinnamon", "panels-height", self.panel_id, _("Smaller"), _("Larger"), mini=20, maxi=270, show_value=True)
Code: Select all
options = [
[-1, _("Scale to panel size exactly")],
[0, _("Scale to panel size optimally")],
[16, '16px'],
[22, '22px'],
[24, '24px'],
[32, '32px'],
[40, '40px'],
[48, '48px'],
[52, '52px'],
[56, '56px'],
[60, '60px'],
[64, '64px'],
[72, '72px'],
[80, '80px'],
[96, '96px'],
[128, '128px']
]
Pay attention to the Python script's indentation method and value! Default Mint files use spaces for tabs, four spaces per tab. Personally I convert all indentation to real tabs to shorten file size and make editing easier; the code above contains real tabs, fix it if you copy paste!!! The Python language is extremely strict with indentation and a single missing or extra space (or other character), or mixing spaces with tabs in indentation
, will render the entire script unusable, thus possibly breaking the entire desktop. Follow the default file's existing indentation to the letter!
And before modifying anything create backup copies of the files.
This is all fine and dandy, but for current Mint any update to Cinnamon - be it bugfixes or new versions or whatever - will revert all of the above changes to default. Therefore either you decline the above changes altogether, keep backup of the modified files and manually reapply the changes after every Cinnamon update, or lock Cinnamon in Update Manager from any further updates.
The latter is definitely not recommended!
One other issue would be that odd icon sizes that have no correspondance in the current icon pack(s) will be automatically resized from nearest size, and that might make icons look blurry. For sharp-looking icons one would have to obtain or build a custom icon pack that contains all icon sizes including the additional ones added to the above files. Adding icons to default packs is not recommended as any subsequent official update to such default packs would remove the additional icons.
All of the above is meant more like a theoretical exercise than a practical approach. It would be fine to apply to older Mint/LMDE versions that no longer benefit from Cinnamon updates but less so for current versions. Programming knowledge is necessary, or at least a sharp mind.
Good luck either way, and Happy Holidays to everyone!