Bash commands for editing date format and menu icon

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
Chris Tinacan
Level 1
Level 1
Posts: 4
Joined: Sat Mar 13, 2021 5:53 am
Location: Ireland

Bash commands for editing date format and menu icon

Post by Chris Tinacan »

I'm using Mint 20.1 Cinnamon and I'm trying to create a script that'll set the appearance of new installations automatically. However, I'm having difficulty finding bash commands to make the following changes:
  1. Set a custom date format for the panel's clock e.g. %a %e %b %H:%M
  2. Show week numbers in calendar
  3. Change the menu icon
Would love any suggestions. Thanks!
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Bash commands for editing date format and menu icon

Post by xenopeek »

One way to somewhat easily find where these are stored is the following:
  1. Create a test file/update its modified time with command touch a (or use whatever name you want in place of 'a')
  2. Then change a single setting
  3. And on the command line run find ~ -newer a which will find any file in your home directory that was modified more recently than the test file from step 1
This works pretty reliably.

For the first two on my system that shows the setting is stored in file ~/.cinnamon/configs/calendar@cinnamon.org/13.json and for the third in ~/.cinnamon/configs/menu@cinnamon.org/0.json. So you'll need a tool to modify JSON files. That's not installed by default. One option is to use jq (apt install jq) which is a command line tool to run queries on JSON files. You can also modify values with it.

As an example let's change the menu icon. First see if you also have the file ~/.cinnamon/configs/menu@cinnamon.org/0.json on your system (in Nemo press Ctrl+H to toggle showing hidden files so you can see the .cinnamon directory in your home directory). Then let's change the menu icon to the Cinnamon logo which this command would do:

Code: Select all

jq '."menu-icon"."value" = "cinnamon-symbolic"' ~/.cinnamon/configs/menu@cinnamon.org/0.json > tmp && mv tmp ~/.cinnamon/configs/menu@cinnamon.org/0.json
It looks like a long command but that's because of the long paths. Let's break it down:
  • jq '."menu-icon"."value" = "cinnamon-symbolic"' this says to find the object "menu-icon" in the JSON root, and the object "value" in that and change it to "cinnamon-symbolic". If you open the ~/.cinnamon/configs/menu@cinnamon.org/0.json file I think you can follow along with that.
  • ~/.cinnamon/configs/menu@cinnamon.org/0.json > tmp && mv tmp ~/.cinnamon/configs/menu@cinnamon.org/0.json is the rest of command and that just says which JSON file to work on, to output the result to the file tmp and if the jq succeeds to move that tmp file back to overwrite the JSON file.
That last bit is a bit convoluted but unfortunately jq right now doesn't support modifying files in place. So the result needs to be written to a temporary file and then moved to overwrite the original file. In a proper script you would use something like mktemp to get a safe name for a temporary file and use that instead of tmp.

Oh and to change the menu icon back to the default replace "cinnamon-symbolic" in the command with "linuxmint-logo-ring-symbolic".

For the changes to the calender, your number 1 and 2, use the same command but replace the filename with ~/.cinnamon/configs/calendar@cinnamon.org/13.json (and check your system has that file!). Then replace the query '."menu-icon"."value" = "cinnamon-symbolic"' with:
  1. '."custom-format"."value" = "%a %e %b %H:%M"' (and you'll want use-custom-format set to true)
  2. '."show-week-numbers"."value" = true'
Or, you know, configure the menu and the calendar exactly as you want then take a copy of the files I mentioned and just copy those onto other systems where you want to use those settings :wink: Mind that these files can change with future versions.
Image
Locked

Return to “Cinnamon”