[UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
User avatar
Burkhardt
Level 2
Level 2
Posts: 75
Joined: Mon Aug 15, 2022 3:26 am
Location: South Africa

[UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by Burkhardt »

I swap computers and laptops a lot. It normally takes me 2-3 hours every time to setup my machine again exactly the way I want it.
(Having to remember exactly where every setting is to open in the GUI and making sure it is set correctly and then installing all of my programs again takes a lot of time that I didn't mind in the beginning but now becomes a chore that I'd rather have automated with scripts.

I have a problem with the one for dconf changes to my panels that does not want to work with LMDE5 (Elsie) Cinnamon.
Parts of it such as panel height and intelligently hide works fine...but the icon sizes does not want to work at all...
What am I doing wrong? Might it be that "dconf WRITE" cannot be used for this?

Here follows the script:

Code: Select all

#!/bin/bash

# Set the panel visibility to intelligently hide
dconf write /org/cinnamon/panels-autohide "['1:0', '1:0']"

# Set the panel height to 55
dconf write /org/cinnamon/panels-height "['1:55']"

# Set the panel-zone-icon-sizes for the right zone to 32
dconf write /org/cinnamon/panel-zone-icon-sizes '[{"panelId": 1, "left": 0, "center": 0, "right": 32}]'

# Set the panel-zone-symbolic-icon-sizes for the right zone to 30
dconf write /org/cinnamon/panel-zone-symbolic-icon-sizes '[{"panelId": 1, "left": 28, "center": 28, "right": 30}]'
Last edited by LockBot on Sat Apr 20, 2024 10:00 pm, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
"Please be not greedy.
Share some of thy knowledge freely.
Truly thee might well receive
a trove of help when needy!"
- Burkhardt
User avatar
Burkhardt
Level 2
Level 2
Posts: 75
Joined: Mon Aug 15, 2022 3:26 am
Location: South Africa

Re: Cinnamon Panel Auto Setups (dconf) with bash script

Post by Burkhardt »

For some more context: This is my script to activate "Hot Corners" with dconf the way I like it and it works perfectly for me:

Code: Select all

#!/bin/bash

# Update the hot corner layout
new_layout="['expo:true:0', 'scale:true:0', 'scale:false:0', 'desktop:true:0']"
dconf write /org/cinnamon/hotcorner-layout "$new_layout"

echo "Hot corner layout updated to: $new_layout"
"Please be not greedy.
Share some of thy knowledge freely.
Truly thee might well receive
a trove of help when needy!"
- Burkhardt
vimes666
Level 6
Level 6
Posts: 1241
Joined: Tue Jan 19, 2016 6:08 pm

Re: Cinnamon Panel Auto Setups (dconf) with bash script

Post by vimes666 »

I think you have to use quotes around it:

Code: Select all

dconf write /org/cinnamon/panel-zone-icon-sizes "'[{"panelId": 1, "left": 0, "center": 0, "right": 32}]'"
If you think the issue is solved, edit your original post and add the word solved to the title.
User avatar
Burkhardt
Level 2
Level 2
Posts: 75
Joined: Mon Aug 15, 2022 3:26 am
Location: South Africa

Re: Cinnamon Panel Auto Setups (dconf) with bash script

Post by Burkhardt »

Thanks for your interest.

For some reason, it still does not work.
I even installed dconf editor (GUI to see dconf binaries...) and tried to use the exact same code as given but to no avail...

If you have any other suggestions, I would be very thankful.
"Please be not greedy.
Share some of thy knowledge freely.
Truly thee might well receive
a trove of help when needy!"
- Burkhardt
vimes666
Level 6
Level 6
Posts: 1241
Joined: Tue Jan 19, 2016 6:08 pm

Re: Cinnamon Panel Auto Setups (dconf) with bash script

Post by vimes666 »

Strange, I just executed the line that I pasted while I had dconf-editor open on org/cinnamon/panel-zone-icon-sizes and it surely gave me a message that the values had been changed and after reloading it showed the values from the command. Maybe you have to logout/login for the change to have effect in your theme.
If you think the issue is solved, edit your original post and add the word solved to the title.
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Cinnamon Panel Auto Setups (dconf) with bash script

Post by Koentje »

Maybe restart cinnamon after the changes? cinnamon --replace &
vimes666
Level 6
Level 6
Posts: 1241
Joined: Tue Jan 19, 2016 6:08 pm

Re: Cinnamon Panel Auto Setups (dconf) with bash script

Post by vimes666 »

Sorry, I made a mistake. I forgot I was using the mate-desktop when I tried it. I retried it under the cinnamon desktop and indeed it does not work.
Can you post the result of

Code: Select all

tail .xsession-errors -n10
after you run those dconf commands?
If you think the issue is solved, edit your original post and add the word solved to the title.
User avatar
Burkhardt
Level 2
Level 2
Posts: 75
Joined: Mon Aug 15, 2022 3:26 am
Location: South Africa

Re: Cinnamon Panel Auto Setups (dconf) with bash script

Post by Burkhardt »

Sorry for my delay in response!

I would have liked to post these above but had to do a fresh install and also started using LMDE 6 Faye that causes a host of problems with scripts that used to work on the previous OS version...

Thanks for your help but I will have to mark this one as complete an carry on. I will still continue this pet project of mine for LMDE 6 Faye and give future feedback...
"Please be not greedy.
Share some of thy knowledge freely.
Truly thee might well receive
a trove of help when needy!"
- Burkhardt
jero
Level 1
Level 1
Posts: 26
Joined: Mon Sep 27, 2021 7:47 am

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by jero »

Burkhardt wrote: Fri Oct 20, 2023 7:06 am I have a problem with the one for dconf changes to my panels that does not want to work with LMDE5 (Elsie) Cinnamon.
Instead of using commands for every individual setting, you could also try to create a backup of everything at once and restore that. E.g. dconf dump /org/cinnamon/ >cinnamon_dconf and dconf load /org/cinnamon/ <cinnamon_dconf.
User avatar
Burkhardt
Level 2
Level 2
Posts: 75
Joined: Mon Aug 15, 2022 3:26 am
Location: South Africa

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by Burkhardt »

Wow... I didn't know that this was possible!
Thanks...will definitely try!
B
"Please be not greedy.
Share some of thy knowledge freely.
Truly thee might well receive
a trove of help when needy!"
- Burkhardt
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by AndyMH »

Burkhardt wrote: Fri Oct 20, 2023 7:06 am I swap computers and laptops a lot. It normally takes me 2-3 hours every time to setup my machine again exactly the way I want it.
Have you thought about cloning to a new machine from one you have setup how you want?
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
Burkhardt
Level 2
Level 2
Posts: 75
Joined: Mon Aug 15, 2022 3:26 am
Location: South Africa

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by Burkhardt »

Honesly. I have tried an easy way of cloning in the past but it was when I first started a few years ago and when I knew a lot less...of terminal commands, bash etc. It was daunting to say the least and I could not manage...

It has been a great learning experience with bash to do the scripts...but alas! I'm not a developer (yet)! My remaining working scripts after LMDE6 upgrade, gets my system about 40% set up the way I want everything...

Cloning will be MUCH EASIER than installation and setup evertime. I use MegaSync for quick restoring of my needed files so the cloned drive can be a small fresh install! Preferably on an 8Gig USB drive if possible?

WHAT WOULD YOU USE AND SUGGEST?

B.
"Please be not greedy.
Share some of thy knowledge freely.
Truly thee might well receive
a trove of help when needy!"
- Burkhardt
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by AndyMH »

https://foxclone.org/
As simple as I could make it, point and click. I'm the dev so obviously biased. Read the section in the user guide on cloning.

EDIT

For multiple PCs probably the simplest is to take a full image backup of the PC you have setup, save the backup to an external drive and then "clone from file" to the new PC.

The new PC will be identical in all respects - same user same hostname. user is not an issue for me, that's what I want, hostname is a problem if you have them all on the same local network. Easy to change:
viewtopic.php?p=1808033#p1808033
Keep them short, I have four thinkpad T430, hostname for the first is T430, next is T431 and so on.

At some point you will have to do a fresh install. I do a fresh install on a major version change, e.g. LM20 to LM21. There are things you can do to reduce the pain:
  • have a separate home partition - that way you get to keep the configs for all the applications you have installed and all the tweaks you made to the desktop. You also keep all your data files, but you should still have a backup.
  • use the mint backup tool, it's not much good for anything else. You can save your "software selection". It will then restore it on the new install. Limited to stuff in mint's repositories, no foreign packages (I have a lot of those).
  • keep a log - I have a launcher on the desktop pointing at a text file on my backup drive. Every time I make a change I make a note of it - what I installed and how.
  • write a script - I have a script that takes a vanilla install and sets it up the way I want. It's over 1,000 lines long, a lot of comments, a lot of repitition, eg. sudo apt install packageX many times. Originally written for LM19 to LM20, minor tweaks for LM20 to LM21.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
Burkhardt
Level 2
Level 2
Posts: 75
Joined: Mon Aug 15, 2022 3:26 am
Location: South Africa

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by Burkhardt »

Awsome! Thanks - much respect for your Dev work...
You are allowed to be biased! Haha...
---------------------
I'm now forced to try this as my laptop JUST THIS MORNING gave this "File system mofified" error on "fsck..." root disk check and refuses to boot. I can unencrypt the disk but obviously cannot boot!

Kindly see this post if interested:
viewtopic.php?t=407455
---------------------

PERSONAL NOTE:
I now believe this to be the most robust way to get a machine up and running again fast with almost all of the custom settings one requires in place! Hostnames are easy enough to change with a custom script or terminal.

I'll also be sure to keep my "fresh install clones" up to date between OS versions as you mentioned... It will save me A LOT OF TIME...Having a separate home partition is something I have not yet attempted. My home partition is also always encrypted and my drive as well...so things might get complicated...

I'm just now scratching the surface of what is possible with coding and scripting but having a solid cloning tool will make much more sense!

What made you code this? The lack of a Cloner that worked the way you wanted with a GUI?

Thanks A LOT in any case.
B
"Please be not greedy.
Share some of thy knowledge freely.
Truly thee might well receive
a trove of help when needy!"
- Burkhardt
User avatar
Burkhardt
Level 2
Level 2
Posts: 75
Joined: Mon Aug 15, 2022 3:26 am
Location: South Africa

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by Burkhardt »

Awsome! Thanks - much respect for your Dev work...
You are allowed to be biased! Haha...
---------------------
I'm now forced to try this as my laptop JUST THIS MORNING gave this "File system mofified" error on "fsck..." root disk check and refuses to boot. I can unencrypt the disk but obviously cannot boot!

Kindly see this post if interested:
viewtopic.php?t=407455
---------------------

PERSONAL NOTE:
I now believe this to be the most robust way to get a machine up and running again fast with almost all of the custom settings one requires in place! Hostnames are easy enough to change with a custom script or terminal.

I'll also be sure to keep my "fresh install clones" up to date between OS versions as you mentioned... It will save me A LOT OF TIME...Having a separate home partition is something I have not yet attempted. My home partition is also always encrypted and my drive as well...so things might get complicated...

I'm just now scratching the surface of what is possible with coding and scripting but having a solid cloning tool will make much more sense!

What made you code this? The lack of a Cloner that worked the way you wanted with a GUI?

Thanks A LOT in any case.
B
"Please be not greedy.
Share some of thy knowledge freely.
Truly thee might well receive
a trove of help when needy!"
- Burkhardt
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by AndyMH »

Burkhardt wrote: Thu Nov 16, 2023 5:39 am What made you code this? The lack of a Cloner that worked the way you wanted with a GUI?
viewtopic.php?p=2302809#p2302809

LUKS encryption - none of the image backup utilities understand LUKS*, they will backup LUKS partitions but because the don't understand the filesystem they do a byte-by-byte copy of the whole partition. This will take longer and the image file will be larger. For known filesystems, they only copy used blocks which is quicker and uses less disk space.

I don't use LUKS, for stuff I consider sensitive I use veracrypt containers (until mounted it is just another file). The rest of the system is open and easier to fix if I do something stupid.


* clonezilla might, it is the most capable of all the utilities, it is also the least user friendly.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Shiva
Level 3
Level 3
Posts: 141
Joined: Thu Jul 07, 2022 11:25 am

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by Shiva »

jero wrote: Tue Nov 14, 2023 1:18 pm
Instead of using commands for every individual setting, you could also try to create a backup of everything at once and restore that. E.g. dconf dump /org/cinnamon/ >cinnamon_dconf and dconf load /org/cinnamon/ <cinnamon_dconf.
This could be dangerous if not used as a backup/restore for the same user. An example may better illustrate what I've in mind.

Let's start from a little script that opens some links to the Mint Blog and Forum in Firefox.

Code: Select all

#!/bin/bash
Links=("-new-tab https://forums.linuxmint.com/viewforum.php?f=244"
"-new-tab https://forums.linuxmint.com/viewforum.php?f=213"
"-new-tab https://forums.linuxmint.com/viewforum.php?f=208"
"-new-tab https://blog.linuxmint.com/")
for Link in "${Links[@]}"; { firefox $Link; }
Now we save it, let's say LMF.sh and make it executable.

Like most of the lazy people, we will quickly use the keyboard feature of the LM Menu and create a shortcut to launch that script, let's say Alt-f.
In the cinnamond.dconf file of a user named bob who saved LMF.sh in his .local/bin/Scripts/ folder, you will find something like this :

Code: Select all

[desktop/keybindings/custom-keybindings/custom1]
binding=['<Alt>f']
command='/home/bob/.local/bin/Scripts/LMF.sh'
name='Linux Mint Forum'
That binding won't work for users joe or sam and a dconf write command could really mess up things for joe and sam (unfortunately, relative path beginning with ~ is not supported) ... unless you pass your cinnamon.dconf file through a stream editor (sed seems a primary choice here) and replace all the /bob/ with /joe/ or /sam/ and tell joe and sam to put the LMF.sh in the same relative path as bob.

The harm done in this example is not very big : joe and sam will just be deprived of the Alt-f binding to the LMF.sh script. But dconf has a lot of very sensible values ; that's why the dconf-editor tool displays a warning to be cautious because bad settings can damage apps.

About the icon size issue, it is not a progressive value : icons are displayed according matrixes (8x8, 16x16, 24x24...), see /usr/share/icons folders. 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 (e.g. 64x64 in a 52px panel) or round them to the most logical values of an existing matrix. It would be very poor development if anyone could crash his system by entering an odd value from a bad typo.
jero
Level 1
Level 1
Posts: 26
Joined: Mon Sep 27, 2021 7:47 am

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by jero »

Shiva wrote: Wed Dec 13, 2023 6:04 pm
jero wrote: Tue Nov 14, 2023 1:18 pm
Instead of using commands for every individual setting, you could also try to create a backup of everything at once and restore that. E.g. dconf dump /org/cinnamon/ >cinnamon_dconf and dconf load /org/cinnamon/ <cinnamon_dconf.
This could be dangerous if not used as a backup/restore for the same user. An example may better illustrate what I've in mind.
Thanks for this addition, you are absolutely right.
I actually used this method to transfer my settings to a new, fresh system and it worked very well, except some stuff like shortcuts is indeed broken because I used a different username.
Shiva
Level 3
Level 3
Posts: 141
Joined: Thu Jul 07, 2022 11:25 am

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by Shiva »

jero wrote: Tue Dec 19, 2023 4:35 am I actually used this method to transfer my settings to a new, fresh system and it worked very well, except some stuff like shortcuts is indeed broken because I used a different username.
If your settings file is cinnamon.dconf as you suggested above, and if you want to replace all the /bob/ with /sam/, this command will do :

Code: Select all

sed -i "s|/bob/|/sam/|g" cinnamon.dconf
PS : you need to run it from the cinnamon.dconf folder or enter the full path to the cinnamon.dconf file and of course to replace bob by the username of the config you backed up and sam by the username of the config you're restoring to and "sam" will recover his lost shortcuts.

Explanation of the syntax of the sed command :
- we don't search bob, but /bob/ (bob as a path element) to avoid unwanted replacements in strings containing bobby, bobsleigh, be-bop...
- as we use / in the search and replace pattern, we will use another delimiter in the sed expression. I chose the pipe (|) but I know people using commas, exclamation marks...
- the final g means all occurrences will be treated.
User avatar
Drugwash
Level 5
Level 5
Posts: 734
Joined: Fri Jun 07, 2019 6:40 am
Location: Ploieşti, RO
Contact:

Re: [UNSOLVED] Cinnamon Panel Auto Setups (dconf) with bash script

Post by Drugwash »

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! :wink: :wink:
Locked

Return to “Scripts & Bash”