SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-02-21 19:32:10

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

[script] crunchooter

crunchooter is a script inspired by cruncbang rc.xml:

    <keybind key="Print">
      <action name="Execute">
        <execute>scrot '%Y-%m-%d--%s_$wx$h_scrot.png' -e 'mv $f ~/images/ &amp; gpicview ~/images/$f'</execute>
      </action>
    </keybind>

I was fed up to open my images with gpicview, cause I don't use gpicview; it's more convenient to use gnome-open instead. Moreover, I was fed up to have my images directory muddled by screenshots… crunchooter uses "~/images/shots/", but in the near future, I think it will use an environment variable, something like:

export SHOTSDIR="$HOME/my/preferred/path/to/save/screenshots"

which it could be more adaptable…

It can use optipng to compress screenshots, on the fly… furthermore, it uses / tmp before moving the image in the folder… while the original command uses the $HOME before moving.

For a behavior similar to the original command line, just use:

crunchooter -o

the image will open in your default program…

add -c option to compress using optipng:

crunchooter -oc

the image is compressed into a sub process started in background and open in your default program… no wait.

# crunchooter --help
Usage: crunchooter [options]

Options:
  --version       show program's version number and exit
  -h, --help      show this help message and exit
  -c, --compress  use optipng to compress image
  -o, --open      open file using gnome-open

Example of commands to install crunchooter in your ~/bin below:

cd ~/bin
wget http://88.174.112.74/share/debian/crunchooter.tar -O crunchooter.tar
tar -xvf crunchooter.tar
rm -v *.tar

Some displays debugging can still be seen in the terminal. It's still fresh ... please disregard. Additional options could happen in the future, like a countdown. If you have ideas and / or suggestions, please.

Last edited by ~HP (2010-02-21 19:34:15)

Offline

Help fund CrunchBang, donate to the project!

#2 2010-02-21 20:00:55

corenominal
WRONG
From: Lincoln, UK
Registered: 2008-11-20
Posts: 5,057
Website

Re: [script] crunchooter

Looks interesting, I will try and give it a try later tonight. smile

Offline

#3 2010-02-21 20:45:42

corenominal
WRONG
From: Lincoln, UK
Registered: 2008-11-20
Posts: 5,057
Website

Re: [script] crunchooter

I came back to this topic so that I could download the script and give it a try, but I cannot find it. Did you post a link to it, or am I just having a moment? hmm

Offline

#4 2010-02-21 21:20:50

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

corenominal wrote:

Did you post a link to it, or am I just having a moment? hmm

~HP wrote:
wget http://88.174.112.74/share/debian/crunchooter.tar -O crunchooter.tar

I was working on adding the sound of the camera… big_smile… like in Mac OS X.

Last edited by ~HP (2010-02-21 21:25:00)

Offline

#5 2010-02-21 21:44:12

corenominal
WRONG
From: Lincoln, UK
Registered: 2008-11-20
Posts: 5,057
Website

Re: [script] crunchooter

Doh! My mistake, sorry. big_smile

Offline

#6 2010-02-21 21:58:29

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,485

Re: [script] crunchooter

Good script big_smile I messed around with it to use internal python functions like gtk.gdk to take the screenshot and PIL to optimize the png because usually that ends up running faster. In this case though using the external commands actually is faster. If you want I can post the code, but if you use gtk.gdk for screens it takes about .3 seconds longer on my machine, can't vouch for the actual memory or cpu usage, but it would be usable on machines without scrot. Using PIL is much slower than optipng, but neither of them actually compressed the image any.

edit: also you can get rid of commands, subprocess also has getstatusoutput


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#7 2010-02-21 22:20:18

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

iggykoopa wrote:

edit: also you can get rid of commands, subprocess also has getstatusoutput

exact… but I use subprocess when I don't want to wait… except with gnome-open.

in the coming days, I will update the script, on my server, with modifications, to use SHOTSDIR, instead of a variable hardcoded. if someone has a good piece of code in python to read wav or mp3, it would be useful to me; at the moment I'm using sox to read a wav! I tried pyglet and pygame with mixed results.

Offline

#8 2010-02-22 22:05:15

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

~HP wrote:

if someone has a good piece of code in python to read wav or mp3 […]

I found an huge piece of code using pygst (Python GStreamer), works well…
crunchooter doesn't use /tmp anymore… now, it saves screenshots directly to the right path!
It could use env SHOTSDIR, and I think to add an option to force another path directly from the command line.

Update could arrive in coming days.

Offline

#9 2010-02-23 13:26:11

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

New version…

Usage: crunchooter [options]

Options:
  --version       show program's version number and exit
  -h, --help      show this help message and exit
  -c, --compress  use optipng to compress image
  -o, --open      open file using gnome-open
  --silent        disable the noise that accompanies taking a screenshot

Uses threading trying to improve performance (may be), uses a maximum total of 4 threads. Play a sound when taking a screenshot… depends on pygst (pthon-pygst). Comments, ideas and / or suggestions welcome.

Last edited by ~HP (2010-02-23 13:28:46)

Offline

#10 2010-02-23 19:39:35

mahatman2
#! Die Hard
From: Chattanooga TN
Registered: 2009-09-13
Posts: 550

Re: [script] crunchooter

If anyone's interested, I just made a bash script that gives a time-out before taking the picture. I called it "deskgrab" but it could be anything; it's really just two commands strung together. The only reason why I made one was so I could put it in menu.xml (and I don't code, so I'm proud of it anyway roll ) Basically it's this:

#! /bin/bash
sleep $1 && crunchooter -oc
exit 0

The argument is how long to sleep. I didn't know how to put the "s" after the number so it's just put in the argument for deskgrab. Just thought I'd pass that along...


Punch all your friends.

Offline

#11 2010-02-23 20:08:09

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

mahatman2 wrote:

[…] Basically it's this:

#! /bin/bash
sleep $1 && crunchooter -oc
exit 0

The argument is how long to sleep. I didn't know how to put the "s" […]

#!/usr/bin/env bash
sleep ${1}s && {
    crunchooter -oc 2> /dev/null
    exit $?
}
exit 1

Use a redirection to avoid debugging information (which is printed on stderr), an option to display them will come soon;  they will be hidden by default.
About shebang : http://www.in-ulm.de/~mascheck/various/shebang/
Use an exit code corresponding to the exit code returned by the last "function" $?

Continue to learn bash, it's a good start wink.

Last edited by ~HP (2010-02-23 20:08:50)

Offline

#12 2010-02-23 20:20:46

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

Updated…

# crunchooter --version
crunchooter 1.1a

Better use of threads
Debug option
No more boring output

# crunchooter --help
Usage: crunchooter [options]

Options:
  --version       show program's version number and exit
  -h, --help      show this help message and exit
  -c, --compress  use optipng to compress image
  -o, --open      open file using gnome-open
  --silent        disable the noise that accompanies taking a screenshot
  --debug         print some debugging information
# crunchooter -oc --debug
Wait: 2010-02-23-1266956166_1680x1050_scrot.png (0:00:00.371891)
Wait: 2010-02-23-1266956166_1680x1050_scrot.png (0:00:00.909249)
Execution time: 0:00:01.209342

Most of time seems to pe spent waiting for scrot… almost 1 seconds… 2 waiting time should not be added because it comes from two processes running in parallel,, so I think we should retain only the larger of the two.

Last edited by ~HP (2010-02-23 20:21:15)

Offline

#13 2010-02-23 20:46:06

anonymous
The Mystery Member
From: Arch Linux Forums
Registered: 2008-11-29
Posts: 9,418

Re: [script] crunchooter

Just a suggestion: change -o so it can accept a program. For example -o gimp.

Offline

#14 2010-02-23 20:57:50

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

anonymous wrote:

Just a suggestion: change -o so it can accept a program. For example -o gimp.

Good suggestion! smile
Added to TO-DO list…

Offline

#15 2010-02-23 21:31:51

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

Added with this kind of syntax:

# crunchooter --open-with=gimp

cause I think, simple options like -o and --open are the simplest and the most generic; and if you choose an editor there is no need to compress the image which will be edited.

# crunchooter --help
Usage: crunchooter [options]

Options:
  --version        show program's version number and exit
  -h, --help       show this help message and exit
  -c, --compress   use optipng to compress image
  -o, --open       open using gnome-open
  --open-with=APP  open using application APP
  --debug          print some debugging information
  --silent         disable the noise that accompanies taking a screenshot

Will be released soon.

Offline

#16 2010-02-24 18:22:58

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

Updated on my server…
see first post for instructions.

Offline

#17 2010-02-24 19:00:42

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

New option delay will coming soon:

2010022412670380951680x.th.png

there will be no need for relying on bash script! wink

Last edited by ~HP (2010-02-24 19:02:57)

Offline

#18 2010-02-25 03:46:40

mahatman2
#! Die Hard
From: Chattanooga TN
Registered: 2009-09-13
Posts: 550

Re: [script] crunchooter

^^AH you got me! I'll just slip into oblivion.... tongue lol cool
I hope that chain of smilies worked to show my true emotion.


Punch all your friends.

Offline

#19 2010-02-25 21:17:22

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

mahatman2 wink

New version… new options…
restores the option to select, using mouse, from scrot
implement a stupid option in order to mimic screencapture under Mac OS X, which names screenshot 'Image n+1.png'

Indeed, crunchooter was inspired by CrunchBang one hand and the other by Mac OS X (especially for the sound played).

I use --select option like this, in my rc.xml:

    <keybind key="Print">
      <action name="Execute">
        <execute>crunchooter -oc</execute>
      </action>
    </keybind>
    <keybind key="S-Print">
      <action name="Execute">
        <execute>crunchooter -ocs</execute>
      </action>
    </keybind>
    <keybind key="A-Print">
      <action name="Execute">
        <execute>crunchooter -ocd10</execute>
      </action>
    </keybind>

Offline

#20 2010-03-07 23:38:06

~HP
#! CrunchBanger
From: Elsaß (fr_FR)
Registered: 2010-01-01
Posts: 187
Website

Re: [script] crunchooter

Updated… essentially, some bug-fixs…

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo