Score:0

DWM - Need help setting up hotkeys for screenshots using maim in Suckless DWM

th flag

I'm a newbie to all of this. I installed DWM to Ubuntu server, and want to set up a hotkey for using maim to take screenshots. I want to have two hotkeys:

  • For a screenshot that gets stored on my desktop
  • For a screenshot that gets stored in my clipboard

I have not been able to get this to work. I added a new hotkey to DWM's config.h: Code:

{ MODKEY, XK_o, spawn, {.v = screenshot2 } },

and using this called screenshot2: Code:

static const char *screenshot2[] = {"maim", "-s", "~/Desktop/screenshot.png"};

The hotkey works, letting me take a screenshot, but the screenshot is not saved. Running the same command in the terminal, I find that "Maim failed to open file for writing". It works when I add sudo to run it, but that causes it to no longer show up when using the dwm hotkey.

Separately to this, I also made a batch file which I call with another hotkey via a function: Code:

static const char *screenshot1[] = {"./screenshot.sh", NULL };

The contents of screenshot.sh are: Code:

maim -s | xclip -selection clipboard -t image/png

For storing the screenshot in my clipboard. This does not work either, and maim does not even start.

What am I doing wrong? Is it all about writing permissions?

Thank you very much!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.