You are not logged in.

#1 2018-08-10 14:54:00

cherkie
Member
Registered: 2018-08-09
Posts: 64

(solved) Adding program to run with parameters to tint2

Hi there,

Is anyone able to help me solve something? I would like to create a shortcut on tint that would automatically run below (via terminal?):

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

to allow me a quick screen selection to clipboard grab. Ideally I would want this bound to a keyboard shortcut but I have no idea if this is possible at all.

Many thanks

Last edited by cherkie (2018-08-12 09:36:50)

Offline

#2 2018-08-10 15:44:10

malm
jgmenu developer
Registered: 2016-10-13
Posts: 228
Website

Re: (solved) Adding program to run with parameters to tint2

Add a button (P) or execp (P) in your tint2 config file. There are examples in the tint2 man page.

Set a keyboard shortcut in ~/.config/openbox/rc.xml
Then run

openbox —reconfigure

Last edited by malm (2018-08-10 15:44:49)

Offline

#3 2018-08-10 16:45:26

cherkie
Member
Registered: 2018-08-09
Posts: 64

Re: (solved) Adding program to run with parameters to tint2

malm wrote:

Add a button (P) or execp (P) in your tint2 config file. There are examples in the tint2 man page.

Set a keyboard shortcut in ~/.config/openbox/rc.xml
Then run

openbox —reconfigure

Thanks, I have brutally taken ownership of the 'I will tell you a secret...' default executor and I have pasted my maim code, tinkered with it and...

It works! However when I try to paste the prt scr to imgur for a quick upload nothing happens. Would it be because I do not have flash/java installed?


I haven't gone to the shortcut route yet, but I am glad you have given me limited info and forced me to tinker on my own. smile

edit.

Well it turns out for some reason what maim is not an image (pasting into gimp says clipboard does not contain image data). I will have to look into that.

Last edited by cherkie (2018-08-10 17:00:56)

Offline

#4 2018-08-11 09:29:30

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,595

Re: (solved) Adding program to run with parameters to tint2

It doesn't seem that maim has any concept of stdout (But I could be wrong), also it goes into background so that xclip pipe thing is hit prematurely. Something ugly (tmp file) like this is working thought;

maim -s /tmp/woot.png && xclip -selection clipboard -t image/png /tmp/woot.png && rm /tmp/woot.png

Last edited by brontosaurusrex (2018-08-12 09:29:29)

Offline

#5 2018-08-12 06:11:05

ohnonot
...again
Registered: 2015-09-29
Posts: 3,197
Website

Re: (solved) Adding program to run with parameters to tint2

brontosaurusrex wrote:

It doesn't seem that maim has any concept of stdout (But I could be wrong)

i thought so too, but the command is taken straight from maim's man page.

Offline

#6 2018-08-12 07:15:05

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,595

Re: (solved) Adding program to run with parameters to tint2

Certainly not working here.

Offline

#7 2018-08-12 08:47:27

cherkie
Member
Registered: 2018-08-09
Posts: 64

Re: (solved) Adding program to run with parameters to tint2

brontosaurusrex wrote:

It doesn't seem that maim has any concept of stdout (But I could be wrong), also it goes into background so that xclip pipe thing is hit prematurely. Something ugly (tmp file) like this is working thought;

maim -s /tmp/woot.png && xclip -verbose -selection clipboard -t image/png /tmp/woot.png && rm /tmp/woot.png

Well, your command works, and the clipboard contains image data however if ran in terminal it seems to be stuck in a loop

edit... which in case of an executor in tint2 does not happen. Now to bind it to a shortcut and this is solved.

thanks

edit: solved, I have created a simple bash script with

maim -s /tmp/woot.png && xclip -verbose -selection clipboard -t image/png /tmp/woot.png && rm /tmp/woot.png

which I have then bound to prtscr button.

thank you all. This community is really helpful.

Last edited by cherkie (2018-08-12 09:33:25)

Offline

#8 2018-08-12 09:27:47

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,595

Re: (solved) Adding program to run with parameters to tint2

I can't see any way this would stuck in a loop in terminal (perhaps you have a weird/loopy alias set?).

Edit: Actually maybe that -verbose thing is doing something funny (not exiting), so I'd go with

maim -s /tmp/woot.png && xclip -selection clipboard -t image/png /tmp/woot.png && rm /tmp/woot.png

I'am getting sloppy ...

Last edited by brontosaurusrex (2018-08-12 09:34:14)

Offline

#9 2018-08-12 09:36:31

cherkie
Member
Registered: 2018-08-09
Posts: 64

Re: (solved) Adding program to run with parameters to tint2

brontosaurusrex wrote:

I can't see any way this would stuck in a loop in terminal (perhaps you have a weird/loopy alias set?).

Edit: Actually maybe that -verbose thing is doing something funny (not exiting), so I'd go with

maim -s /tmp/woot.png && xclip -selection clipboard -t image/png /tmp/woot.png && rm /tmp/woot.png

I'am getting sloppy ...

You are helpful, thanks! see above, I have managed to do everything I need.

klA5PWb.png

Offline

#10 2018-08-12 10:09:30

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,595

Re: (solved) Adding program to run with parameters to tint2

Well great, btw you can setup the openbox environment
http://openbox.org/wiki/Help:Autostart
in a way that you will not have to reference scripts with full path.

Something like

export PATH=$HOME/scripts:$PATH

Offline

#11 2018-08-13 04:51:31

ohnonot
...again
Registered: 2015-09-29
Posts: 3,197
Website

Re: (solved) Adding program to run with parameters to tint2

cherkie wrote:
maim -s | xclip -selection clipboard -t image/png

i just tested this on my archlinux machine:

1. fired up gimp
2. executed the command as above
3. pasted the image straight into gimp with ctrl-v

so that worked.

then i tried the same on bunsenlabs helium vm (had to install xclip, slop and maim first), and gimp says there is no image data to paste!

Offline

#12 2018-08-13 05:03:31

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,595

Re: (solved) Adding program to run with parameters to tint2

Older xclip in Debian? Guessing.

Offline

#13 2018-08-13 05:19:20

ohnonot
...again
Registered: 2015-09-29
Posts: 3,197
Website

Re: (solved) Adding program to run with parameters to tint2

no, older maim!
the command from post #1 is NOT in stretch's man page.
using it on bunsenlabs results in images being saved to $HOME, and not stdout, despite the pipe.

i actually remember that maim's behavior has changed there some time ago.
it's under heavy development and stretch's version might differ a lot from the newest version (and it is unlikely to get updated any time soon).
for now, bronto's workaround is the best solution.

cherkie, lesson learned: always post your sources (where you got an idea from)!

Offline

#14 2018-08-13 07:08:44

cherkie
Member
Registered: 2018-08-09
Posts: 64

Re: (solved) Adding program to run with parameters to tint2

ohnonot wrote:

no, older maim!
the command from post #1 is NOT in stretch's man page.
using it on bunsenlabs results in images being saved to $HOME, and not stdout, despite the pipe.

i actually remember that maim's behavior has changed there some time ago.
it's under heavy development and stretch's version might differ a lot from the newest version (and it is unlikely to get updated any time soon).
for now, bronto's workaround is the best solution.

cherkie, lesson learned: always post your sources (where you got an idea from)!


from here!

thanks for further investigation. smile

Offline

#15 2018-08-14 05:12:04

ohnonot
...again
Registered: 2015-09-29
Posts: 3,197
Website

Re: (solved) Adding program to run with parameters to tint2

cherkie wrote:

from here!

that's weird, since it specifically says "for debian 9", but my investigations clearly showed that the last example with xclip will not work on stretch's (or at least bunsenlabs') maim version.
not cool, Hitesh Jethva!

Offline

#16 2018-08-14 09:02:38

cherkie
Member
Registered: 2018-08-09
Posts: 64

Re: (solved) Adding program to run with parameters to tint2

ohnonot wrote:
cherkie wrote:

from here!

that's weird, since it specifically says "for debian 9", but my investigations clearly showed that the last example with xclip will not work on stretch's (or at least bunsenlabs') maim version.
not cool, Hitesh Jethva!

yeah I wouldn't get it from dodgy source especially that everywhere says debian has got to use debian repos otherwise it's gonna break. :^)

Offline

Board footer

Powered by FluxBB