You are not logged in.

#1 2023-10-21 13:50:50

scatherinch
Member
Registered: 2023-02-24
Posts: 160

[SOLVED] Xbindkeys: prntscrn

I have a question about xbindkeys. Recently, I made a script to run maim from my shell using the Awesome window manager (For X). I have been wondering if it was possible to use this program to bind this shell script to a specific key so that whenever I press it, it will launch it and I can use the prntscrn button to take a snippet of my screen selection.

My script is very, very simple, but I do not quite understand how I can integrate this into xbindkeys. Is it even possible? My only questioning behind this is because that awhile back, I asked how to bind my volume control key on my mouse to this program in a similar manner.

#!/bin/sh

maim -so ~/Pictures/$(date +%s).jpg

So I want to bind this to that button so that whenever I press meta + r, prntscreen launches the my shell script. For some reason, whenever I run this command directly from awesome, I get the selection box, but it doesn't save anything to the output location.

Last edited by scatherinch (2023-10-21 22:39:53)

Offline

#2 2023-10-21 14:35:47

seth
Member
Registered: 2012-09-03
Posts: 64,547

Re: [SOLVED] Xbindkeys: prntscrn

Yes you can, like any other command.
A common pitfall w/ screenshot tools (and screenlocker) is that they'll often try to grab server and/or input what fails if there's an active shortcut.
A simple workaround that is to briefly "sleep 0.25" to give yourself the chance to release the key that triggers the shortcut before the tool is actually started.

Online

#3 2023-10-21 19:29:09

scatherinch
Member
Registered: 2023-02-24
Posts: 160

Re: [SOLVED] Xbindkeys: prntscrn

Ah, alright. That's good to know!!

In that case,

Here's what I got so far in my .xbindkeysrc file thus far.

# Increase volume
"pactl set-sink-volume @DEFAULT_SINK@ +1%"
   XF86AudioRaiseVolume

# Decrease volume
"pactl set-sink-volume @DEFAULT_SINK@ -1%"
   XF86AudioLowerVolume

How would I go about bindings this key with that maim command? I got this from that xbindkeys, it's the code for that key

I'm getting

Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"(Scheme function)"
    m:0x10 + c:107
    Mod2 + Print

What should I add to to this file get this to activate that maim command?

Last edited by scatherinch (2023-10-21 19:29:51)

Offline

#4 2023-10-21 19:32:21

seth
Member
Registered: 2012-09-03
Posts: 64,547

Re: [SOLVED] Xbindkeys: prntscrn

Exactly what xbindkeys tells you - or you adapt the pattern that's already there.
What exactly have you tried that didn't work?

Online

#5 2023-10-21 20:34:48

scatherinch
Member
Registered: 2023-02-24
Posts: 160

Re: [SOLVED] Xbindkeys: prntscrn

I haven't tried anything yet. I was just asking how I could put this maim command ( maim -so ~/Pictures/$(date +%s).jpg ) from a shell script I have on my PC and bind it into xbindkeys, so that when I hit prntscrn, it runs the command from a shell script I made in my home directory. I do not know what to put into .xbindkeyssrc that would point to such a thing to have the command run when I press prntscrn.

My shell script: 

maimss.sh

#!/bin/sh

maim -so ~/Pictures/$(date +%s).jpg

Offline

#6 2023-10-21 20:37:03

seth
Member
Registered: 2012-09-03
Posts: 64,547

Re: [SOLVED] Xbindkeys: prntscrn

You could also put the maimss.sh there.
If you had to guess, what do you think the entry in .xbindkeysrc should look like?

Online

#7 2023-10-21 21:11:29

scatherinch
Member
Registered: 2023-02-24
Posts: 160

Re: [SOLVED] Xbindkeys: prntscrn

You're right! Hey, thank you!!! The answer was right in front of me!!!

#Maim Shell Script
"maim -so ~/Pictures/$(date +%s).jpg"
	Mod2 + Print

Offline

#8 2023-10-21 21:29:04

seth
Member
Registered: 2012-09-03
Posts: 64,547

Re: [SOLVED] Xbindkeys: prntscrn

\o/
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Online

Board footer

Powered by FluxBB