You are not logged in.

#1 2017-11-25 13:23:30

JUSHJUSH
Member
Registered: 2017-11-25
Posts: 5

[SOLVED] xbindkeys and custrom script

Hello.
I'm trying to bind my custom script to key via xbindkeys.
My script is located in /usr/local/bin/screen.sh

 #!/bin/bash

name="$HOME/SS/SS"
if [[ -e $name.png ]] ; then
	i=0
	while [[ -e $name$i.png ]] ; do
		let i++
	done
	name=$name$i
fi

scrot -s $name.png
xclip -selection clipboard -t image/png -i $name.png

and is working fine when i'm starting it from terminal ($ screen.sh ).

But when i try to bind it to key, noone of this works:

"/usr/local/bin/screen.sh"
	m:0x0 + c:115

"screen.sh"
	m:0x0 + c:116

When I press binded keys nothing happens. Ofcourse I reloaded xbindkeys, other binds to "standard" applications are working for me.
What am I doing wrong?

Last edited by JUSHJUSH (2017-11-25 14:56:51)

Offline

#2 2017-11-25 14:06:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: [SOLVED] xbindkeys and custrom script

Have you tried binding other commands to the same keys (e.g., have you verified that that key is detected)?

Also, I assume the space before the shebang in your script is just on the forums, right (otherwise it wouldn't work at all unless you source it rather than run it)?

On a different note, you could simplify that script a fair bit:

name="$HOME/SS/SS"
unset i
while [[ -e "${name}${i}.png" ]]; do
   let i++
done
scrot -s "${name}${i}.png"
xclip ...

Last edited by Trilby (2017-11-25 14:07:33)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2017-11-25 14:23:49

JUSHJUSH
Member
Registered: 2017-11-25
Posts: 5

Re: [SOLVED] xbindkeys and custrom script

Yeah, key is detected.
I added space accidently while pasting it here.

Last edited by JUSHJUSH (2017-11-25 14:42:24)

Offline

#4 2017-11-25 14:50:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,868

Re: [SOLVED] xbindkeys and custrom script

prepend a "sleep 0.25"  or so to allow a key release, also redirect the scripts outputs somewhere you can inspect it like " >> /tmp/wtf.log 2>&1" or so.

Offline

#5 2017-11-25 14:55:48

JUSHJUSH
Member
Registered: 2017-11-25
Posts: 5

Re: [SOLVED] xbindkeys and custrom script

Thank you, sleep do the job smile

Offline

Board footer

Powered by FluxBB