Keyboard shortcut question...

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
invex
Level 4
Level 4
Posts: 219
Joined: Sun Aug 14, 2016 12:38 pm

Keyboard shortcut question...

Post by invex »

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
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
kyphi
Level 9
Level 9
Posts: 2735
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter Valley, Australia

Re: Keyboard shortcut question...

Post by kyphi »

That depends on what keyboard you use. On mine, I can invoke the Desktop context menu by pressing FN+Right Ctrl.
Linux Mint 21.3 Cinnamon
User avatar
invex
Level 4
Level 4
Posts: 219
Joined: Sun Aug 14, 2016 12:38 pm

Re: Keyboard shortcut question...

Post by invex »

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 9
Level 9
Posts: 2735
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter Valley, Australia

Re: Keyboard shortcut question...

Post by kyphi »

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 21.3 Cinnamon
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Keyboard shortcut question...

Post by smurphos »

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
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
User avatar
invex
Level 4
Level 4
Posts: 219
Joined: Sun Aug 14, 2016 12:38 pm

Re: Keyboard shortcut question...

Post by invex »

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 4
Level 4
Posts: 219
Joined: Sun Aug 14, 2016 12:38 pm

Re: Keyboard shortcut question...

Post by invex »

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 :)
Locked

Return to “Cinnamon”