Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setup Plasma Custom Shortcuts for macOS like Screenshots

Introduction

After moving to Linux and KDE Plasma from macOS, I only missed one thing that I used all the time: The Screenshot tool. The Shortcuts on macOS have been engraved in my head after probably thausand of uses so I figured I'd give replicating them a try.

Creating new Shortcuts was surprisingly easy so here is a rundown of it

Setup

You will need

  • A directory to store screenshots in (I use ~/pictures/screenshots)
  • An install of maim
  • An install of either xclip or copyq (I will go into this in the next secion)

xclip vs. copyq

At first I just used the example from the maim readme to put screenshots into the clipboard, meaning xlip. Sadly this was giving me issues (similar to this) so I decided to switch to copyq.

As I only use copyq for screenshots I set the following config values

autostart true
maxitems 1

I also unchecked every option in Clipboard Manipulation in the config menu and hid its tray icon

If xclip does not have issues on your system it is surely a more lightwight solution, I will include command for both tools down below

Adding Custom Shortcuts

As I already said this is surprisingly easy.

Open System Settings, then go to Shortcuts > Custom Shortcuts. Here I created a group called "Screenshot" so that its all tidy.

I added the following:

  • Area
    Comment: Makes a screenshot of an selected area and saves it to a file
    Trigger: Shift + Command + 4
    Action: maim -su ~/pictures/screenshots/$(date --iso-8601=seconds).png

  • Area Clipboard
    Comment: Makes a screenshot of an selected area and copies it to the clipboard
    Trigger: Shift + Control + Command + 4
    Action: maim -su | copyq write image/png - && copyq select 0 or maim -su | xclip -selection clipboard -t image/png

  • Full
    Comment: Makes a screenshot of all screens and saves it to a file
    Trigger: Shift + Command + 3
    Action: maim -u ~/pictures/screenshots/$(date --iso-8601=seconds).png

  • Full Clipboard
    Comment: Makes a screenshot of all screens and copies it to the clipboard
    Trigger: Shift + Control + Command + 3
    Action: maim -u | copyq write image/png - && copyq select 0 or maim -u | xclip -selection clipboard -t image/png

Flags

Of course you can also set your own flags for maim, there is a lot to choose from! I'm just using -u everywhere, which hides the cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment