Keyboard shortcut question...

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon
Post Reply
User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Keyboard shortcut question...

Post by invex » Sat Aug 11, 2018 11:41 am

Is it possible to create a keyboard shortcut which would perform the following action?
Desktop context menu/Desktop/Icon Size/Smaller

If not, is it possible to rearange Desktop context menu?

TIA

User avatar
kyphi
Level 8
Level 8
Posts: 2328
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter, Australia

Re: Keyboard shortcut question...

Post by kyphi » Sat Aug 11, 2018 8:29 pm

That depends on what keyboard you use. On mine, I can invoke the Desktop context menu by pressing FN+Right Ctrl.
Linux Mint 19 Cinnamon - 64bit

User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Re: Keyboard shortcut question...

Post by invex » Sun Aug 12, 2018 12:29 am

Thank you.
I meant to create a shortcut, for example, 'Ctrl Alt 1' to switch desktop icon size to 'Smaller' instead of invoking desktop context menu and clicking Desktop, Iconsize, Smaller.
And 'Ctrl Alt 2' to switch to normal size.

User avatar
kyphi
Level 8
Level 8
Posts: 2328
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter, Australia

Re: Keyboard shortcut question...

Post by kyphi » Sun Aug 12, 2018 1:27 am

You might find a solution here: https://shortcutworld.com/Linux-Mint/li ... _Shortcuts

There is an entry for resizing icons but as far as I can tell this is meant for use in nemo and not the desktop.
Linux Mint 19 Cinnamon - 64bit

User avatar
smurphos
Level 8
Level 8
Posts: 2049
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Keyboard shortcut question...

Post by smurphos » Sun Aug 12, 2018 2:41 am

Yep Ctrl= and Crtl- don't work on the desktop only in nemo itself..

This is not as easy as it really should be.

Unfortunately there is no straightforward cli command to invoke this change, but it is scriptable albeit the method is an ugly hack.

This basic script would work OK if align to grid and autoarrange are off. As written this sets the icon size to small. Save the script somewhere sensible and then set up a custom keyboard shortcut to invoke the script in the Keyboard settings app. You'll normally need to specify the full patch to the script as the command for the custom shortcut.

Code: Select all

#!/bin/bash

#Script to set nemo desktop icon size to small

# Set Working Directory
cd "$HOME/.config/nemo" || exit

# Add current value to var
OLDSIZE=$(grep "^nemo-icon-view-zoom-level=" desktop-metadata)

# Set new value (2 = smaller, 3 = normal, 4 = larger)
NEWSIZE="nemo-icon-view-zoom-level=2"

# Kill nemo-desktop
pkill nemo-desktop

# Update $HOME/.config/nemo/desktop-metadata
sed -i "s|$OLDSIZE|$NEWSIZE|g" desktop-metadata

# Restart nemo-desktop
nemo-desktop
This second version toggles through the sizes - so you could use a single keyboard shortcut to cycle from smaller, normal, larger and back again

Code: Select all

#!/bin/bash

#Script to toghle nemo-desktop icon size

# Set Working Directory
cd "$HOME/.config/nemo" || exit

# Add current value to var
OLDSIZE=$(grep "^nemo-icon-view-zoom-level=" desktop-metadata)

# Set new value (2 = small, 3 = normal, 4 = large)
if [[ $OLDSIZE = "nemo-icon-view-zoom-level=2" ]]; then
	NEWSIZE="nemo-icon-view-zoom-level=3"
elif [[ $OLDSIZE = "nemo-icon-view-zoom-level=3" ]]; then
	NEWSIZE="nemo-icon-view-zoom-level=4"
else
    NEWSIZE="nemo-icon-view-zoom-level=2"
fi
# Kill nemo-desktop
pkill nemo-desktop

# Update $HOME/.config/nemo/desktop-metadata
sed -i "s|$OLDSIZE|$NEWSIZE|g" desktop-metadata

# Restart nemo-desktop
nemo-desktop

User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Re: Keyboard shortcut question...

Post by invex » Mon Aug 13, 2018 9:09 pm

Thank you very much! Awsome.

Both scripts work great.
So the only thing needed would be to disable Autoarrange and Align to Grid and to enable it at the end of the script.
Well beyond my ability :)

The reason why I'd like to control the icon size with a keyboard shortcut is because I use Conky and if I have too many icons they start disappearing behind Conky.

User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Re: Keyboard shortcut question...

Post by invex » Mon Aug 13, 2018 11:32 pm

I misunderstood. The second script doesn't require Autoarrange and Align to be off.
It works perfectly. Thank you again.
I'm jumping with joy :)

Post Reply

Return to “Cinnamon”