It’s a Dog’s Breakfast

It is what it is. Unless it ain’t.

Adjusting Cinnamon Window Shadows

Quite a while ago, I posted on G+ about how I loved the Cinnamon desktop except for the fact that you couldn’t adjust the window shadows. At that time I boasted er… wrote about how I downloaded the Muffin source code (Muffin is the window manager used in Cinnamon), adjusted the hardcoded values and recompiled it. I also said I would someday write a post about it. Well ta-dahh.. here it is.

First of all, let me start with caveats and warnings. Don’t blame me if you bork something doing this. This is really a fairly simple tweak, but as with anything, there is plenty that could go wrong. Proceed at your own risk. I did this on Linux Mint 18.1 and while it may be applicable to other versions, that’s not guaranteed.

Much of this is based on the instructions found here: https://community.linuxmint.com/tutorial/view/955

I simply wanted to increase the stock shadow radius of windows in Cinnamon. I wanted to see this sort of change:

From this:

StockShadows

to this:

ModifiedShadows

So here’s how I did it:

Step 1: Open up Software Sources from the Mint menu and hit the checkbox to ‘Enable source code repositories’ and then click the ‘Update the Cache’ button.

Step 2: Open a terminal window and enter the following:

apt install dpkg-dev
apt build-dep muffin

Step 3: Create a source directory and change to that directory:

mkdir ~/src
cd ~/src

Step 4: Clone the muffin source code repository from github to download the current source code:

git clone git://github.com/linuxmint/muffin.git

This will create a ‘muffin’ directory within the ‘src’ directory you just made.

Step 5: Navigate to the proper folder, make a backup copy and bring up the meta-shadow-factory.c file in your favourite text editor:

cd ~/src/muffin/src/compositor
cp meta-shadow-factory.c meta-shadow-factory.c.bak //a backup copy just in case you mess things up//
xed meta-shadow-factory.c

Step 6: Find the part of the file where you see the following:

static MetaShadowClassInfo default_shadow_classes[] = {
  { "normal",       { 6, -1, 0, 3, 255 }, { 3, -1, 0, 3, 128 } },
  { "dialog",       { 6, -1, 0, 3, 255 }, { 3, -1, 0, 3, 128 } },
  { "modal_dialog", { 6, -1, 0, 1, 255 }, { 3, -1, 0, 3, 128 } },
  { "utility",      { 3, -1, 0, 1, 255 }, { 3, -1, 0, 1, 128 } },
  { "border",       { 6, -1, 0, 3, 255 }, { 3, -1, 0, 3, 128 } },
  { "menu",         { 6, -1, 0, 3, 255 }, { 3, -1, 0, 0, 128 } },

  { "popup-menu",    { 1, -1, 0, 1, 128 }, { 1, -1, 0, 1, 128 } },

  { "dropdown-menu", { 1, 10, 0, 1, 128 }, { 1, 10, 0, 1, 128 } },
  { "attached",      { 6, -1, 0, 1, 255 }, { 3, -1, 0, 3, 128 } }
};

Step 7: The values are sets of 5 numbers. The important ones for me were the 1st number (shadow radius), 4th number (vertical offset - meaning how far to shift the shadow vertically downward), and 5th number (the opacity of the shadow - 255 being darkest and 0 being transparent). So I wanted larger radii (increase the first value in each set.. I multiplied them by 3), slightly shifted downward (increase the 4th value in each set.. multiplied them by 3 as well) and less opacity (cut it from 255 down to 200). So I changed the aforementioned values to the following and saved the file:

static MetaShadowClassInfo default_shadow_classes[] = {
  { "normal",       { 18, -1, 0, 9, 200 }, { 9, -1, 0, 3, 128 } },
  { "dialog",       { 18, -1, 0, 9, 200 }, { 9, -1, 0, 3, 128 } },
  { "modal_dialog", { 18, -1, 0, 3, 200 }, { 9, -1, 0, 3, 128 } },
  { "utility",      { 9, -1, 0, 3, 200 }, { 9, -1, 0, 1, 128 } },
  { "border",       { 18, -1, 0, 9, 200 }, { 9, -1, 0, 3, 128 } },
  { "menu",         { 18, -1, 0, 9, 200 }, { 9, -1, 0, 0, 128 } },

  { "popup-menu",    { 3, -1, 0, 3, 128 }, { 1, -1, 0, 1, 128 } },

  { "dropdown-menu", { 3, 10, 0, 3, 128 }, { 1, 10, 0, 1, 128 } },
  { "attached",      { 18, -1, 0, 3, 200 }, { 3, -1, 0, 3, 128 } }
};

Step 8: Back in the terminal, get yourself into the muffin directory and build the required packages:

cd ~/src/muffin
dpkg-buildpackage

This may take a few minutes. Once the build is done, there will be a set of deb files (among other things) now sitting in your ~/src directory.

Step 9: Get into the src directory and install the deb packages that you just created:

cd ~/src
sudo dpkg -i *.deb

Step 10: And Voila! If everything went according to plan, you should be able to restart Cinnamon (logout and back in again, or right-click the status bar and choose Troubleshoot->Restart Cinnamon) and you should see the nicer, larger shadows.

Step 11: If you’re not happy with the results or want to make adjustments, just re-edit the meta-shadow-factory.c file and then rinse and repeat (from step 8).

It would be lovely if Cinnamon offered this adjustment as a setting, but for now it’s hardcoded so if you really want different window shadows but want to stick with Cinnamon, this may be your only option.

Note: I’m not normally a tutorial author, so apologies for the brevity and please let me know if you spot any mistakes I’ve made.

Note Also: If the muffin library gets updated through normal system updates over time, your shadows may revert back to normal and you may have to repeat this procedure.