Coder Social home page Coder Social logo

naelstrof / maim Goto Github PK

View Code? Open in Web Editor NEW
2.1K 25.0 78.0 567 KB

maim (make image) takes screenshots of your desktop. It has options to take only a region, and relies on slop to query for regions. maim is supposed to be an improved scrot.

License: Other

C++ 84.13% CMake 9.82% Roff 6.05%
takes-screenshots scrot c-plus-plus imagemagick

maim's Introduction

maim

maim (Make Image) is an utility that takes screenshots of your desktop. It's meant to overcome shortcomings of scrot and performs better in several ways.

Features

  • Takes screenshots of your desktop, and saves it in png, jpg, or bmp format.
  • Takes screenshots of predetermined regions or windows, useful for automation.
  • Allows a user to select a region, or window, before taking a screenshot on the fly.

screenshot with selection

  • Blends the system cursor to the screenshot. screenshot with cursor
  • Masks off-screen pixels to be transparent or black.

screenshot with masked pixels

  • Maim cleanly pipes screenshots directly to standard output (unless otherwise specified), allowing for command chaining.
  • Maim supports anything slop does, even selection shaders!

slop animation

Installation

Install using your Package Manager (Preferred)

Install using CMake (Requires CMake, git, libXrender, libXfixes, libGLM, libxcomposite, libxrandr, libxext, GLEW)

git clone https://github.com/naelstrof/slop.git
cd slop
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/usr" ./
make && sudo make install
cd ..
git clone https://github.com/naelstrof/maim.git
cd maim
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/usr" ./
make && sudo make install

Examples

Maim allows for a lot of unique and interesting functionalities. Here's an example of a few interactions.

  • This command will allow you to select an area on your screen, then copy the selection to your clipboard. This can be used to easily post images in mumble, discord, gimp-- or any other image supporting application.
$ maim -s | xclip -selection clipboard -t image/png
  • This messy command forces a user to select a window to screenshot, then applies a shadow effect using imagemagick, then saves it to shadow.png. It looks really nice on windows that support an alpha channel.
$ maim -st 9999999 | convert - \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage shadow.png
  • This command is a particular favorite of mine, invented by a friend. It simply prints the RGB values of the selected pixel. A basic color picker that has the additional ability to average out the pixel values of an area. If used cleverly with the geometry and window flag, the return color might warn you of a found counter-strike match...
$ maim -st 0 | convert - -resize 1x1\! -format '%[pixel:p{0,0}]' info:-
  • This is a basic, but useful command that simply screenshots the current active window.
$ maim -i $(xdotool getactivewindow) ~/mypicture.jpg
  • This is another basic command, but I find it necessary to describe the usefulness of date. This particular command creates a full screenshot, and names it as the number of seconds that passed since 1970. Guaranteed unique, already sorted, and easily read.
$ maim ~/Pictures/$(date +%s).png
  • This one overlays a still of your desktop, then allows you to crop it. Doesn't play well with multiple monitors, but I'm sure if it did it wouldn't look this pretty and simple.
$  maim -u | feh -F - & maim -s -k cropped.png && kill $!
$ maim -s /tmp/screenshot.png; imgur.sh /tmp/screenshot.png | xclip -selection clipboard
  • The following command can be used to select a QR code (or click into a window where a QR code is present), decode it, print the text to the console and copy the text into the clipboard for further usage.
$ maim -qs | zbarimg -q --raw - | xclip -selection clipboard -f
  • Shortcut for i3 window manager:
    • Enable light on the Thinkpad T430 laptop
    • Wait 5 seconds
    • Screenshot all displays
    • Save file like ~/screenshots/2022-dec-21--12-56-08_maim.png
    • Disable light
    • Show i3 notification for 3 seconds:
bindsym $mod+Shift+x exec "\
    echo 1 > /sys/class/leds/platform\:\:micmute/brightness; \
    sleep 5; \
    maim --hidecursor ~/screenshots/$(date +%Y-%b-%d--%H-%M-%S_maim | tr A-Z a-z).png; \
    echo 0 > /sys/class/leds/platform\:\:micmute/brightness; \
    i3-nagbar --message 'Screenshot created' --type warning & \
    sleep 3; pkill i3-nagbar"

maim's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maim's Issues

Cant install maim on Linux Mint

Hello,

Earlier today I tried to install maim on Linux Mint. I got this error and it didn't install:
[ 25%] Building CXX object CMakeFiles/maim.dir/src/im.cpp.o
/home/sebastiaan/maim/src/im.cpp: In member function ‘int maim::IMEngine::blendCursor(Window, int, int)’:
/home/sebastiaan/maim/src/im.cpp:135:39: error: variable-sized object ‘pixels’ may not be initialized
DATA32 pixels [ size_px ] = { 0x0 };
^
make[2]: *** [CMakeFiles/maim.dir/src/im.cpp.o] Error 1
make[1]: *** [CMakeFiles/maim.dir/all] Error 2
make: *** [all] Error 2

I've installed all of the required tools and programs.

Ubuntu?

How do you install this on Ubuntu? Couldn't find it in the repositories

jpeg quality choice

can not find how to set quality of output image in jpg format output file

--gracetime isn't passed along to slop properly

As gcc pointed out:

main.cpp:140:53: warning: format ‘%i’ expects argument of type ‘int’, but argument 7 has type ‘char*’ [-Wformat]

This has the effect of passing the pointer's numeric value to slop, resulting in an invocation like slop -b 5 -p 0 -t 2 -g 32358608 -c 0.5,0.5,0.5,1 --min=0 --max=0

I tried to address this in #5 but that approach introduces other issues, so I'm not sure what the preferred fix would be.

Broken tag/archive for v2.3.39

It is v3.3.39 instead, so downloading via link:

--2014-11-30 17:41:33--  https://github.com/naelstrof/maim/archive/v2.3.39/maim-2.3.39.tar.gz
Resolving github.com (github.com)... 192.30.252.129
Connecting to github.com (github.com)|192.30.252.129|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/naelstrof/maim/tar.gz/v2.3.39/maim-2.3.39 [following]
--2014-11-30 17:41:33--  https://codeload.github.com/naelstrof/maim/tar.gz/v2.3.39/maim-2.3.39
Resolving codeload.github.com (codeload.github.com)... 192.30.252.147
Connecting to codeload.github.com (codeload.github.com)|192.30.252.147|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2014-11-30 17:41:34 ERROR 404: Not Found.

fails.

Invalid coordinates when using window IDs

I'm was trying to capture a single window using maim -s, but while the screenshot seem to be of the correct size, it's actually black after a certain position.

The coordinates reported by slop though seem correct. In fact, running maim -g $(slop -f%g) works perfectly.

It seems that using window IDs instead is broken in maim itself. maim -i $(slop -f%i) has the same issue as maim -s when just selecting a window.

Visual countdown

scrot has a way to visually show the countdown, like so:
image

You can see so in the manpage that the -c option provides this, and you need to use this with the -d option; scrot -cd 5

       -c, --count
            Display a countdown when used with delay.

       -d, --delay NUM
            Wait NUM seconds before taking a shot.

maim does only have the delay option. My feature request, I guess, is to add an option to do visual countdown. The -c option is used with slop though I think so maybe it's necessary to find another option to use. -c would be convenient since it's the same for scrot, though.

  -d, --delay=FLOAT             Set the amount of time to wait before taking an
                                  image.  (default=`0.0')

Remote quotes for maim example

$ maim "~/Pictures/$(date +%F-%T).png"
Failed to save image /Pictures/2014-10-20-00:19:11.png: path component is non-existant ( isn't expanded inside quotes!)
Failed to take screenshot.

Whereas,
$ maim ~/Pictures/$(date +%F-%T).png
Works fine. Shouldn't we remove the quotes from the example then?

blank screenshot

I don't know if it's slop or maim issue.

I'm using i3wm, when i "click" in a window with maim -s screenshot is in right size... but completely empty.

Selecting by mouse sliding works perfectly.

alt

Invalid MIT-MAGIC-COOKIE-1

When i run maim, it shows this error message:

Invalid MIT-MAGIC-COOKIE-1 keyError: Failed to open X display :0
Failed to grab X display!

Installed from the repos on Arch Linux.

Not working in Dota2

When i launch maim with a hotkey in a dota2 game (in the menu it works fine) nothing happens, slop's selection isnt even popping up.

I'm fairly sure this is caused by Dota already grabbing the pointer so slop cant do it.

Short form of --windowid is -i and not -id

There is a small misinformation in examples: the README.md and the help suggest that the command to take a screenshot of the active window is maim -id $(xdotool getactivewindow) when it should be maim -i $(xdotool getactivewindow).

--windowid produces odd results

When using --windowid instead of specifying the geometry manually, maim seems to not take the position of the specified window into account. The resulting images are partially cut-off and filled with transparency.

config file to set destination directory to something other than $HOME

my use case for maim at the moment using using it w/ i3 to exec maim -s and take a screenshot, then fetching the file from my home directory.

I'd love to be able to set a destination directory for the resulting images that isn't my home directory. I looked through the man page and didn't see anything to this effect.

maim with slop leaves grey overlay on screenshots

I use sxhkd to bind ctrl + Print to 'maim -s ~/screenshots/$(date +%F-%T).png'.
This works, but the resulting screenshots have a dark tint, apparently because maim takes a screenshot while the grey overlay of slop is still visible.
This does not happen when I use maim without slop to capture a fullscreen screenshot.
Example screenshot:
2015-09-23-23 25 45

Using maim to take full screenshots produces blank pictures in tiling window managers

Hello. I've done the test in my three desktop environments at Linux Mint 17.1
imlib2 version is 1.4.6-2 from repository

I'm using most tiling WMs since my Cinnamon started to act weird (only in 3D acceleration though, so I could test it using software rendering). Mostly BSPWM but I have StumpWM as well so I tested it into both. I've noted that my screenshots (I usually use Poomf script for uploading them in a puu.sh-style) were being uploaded as blanks. So I started testing what was up.

Running maim --hidecursor or maim produced blanks. However using coordinates (-h -w -x -y) or using slop mode with -s just worked fine. To complete this I've tried taking a shot with ImageMagick (import -window root ) and it just worked fine. Then I re-installed imlib2 and tried all again. So I went from BSPWM from Cinnamon and tried maim --hidecursor and maim and well, it worked too. So I decided to try StumpWM and... curiously I've got the same problem as BSPWM.

So I think it's something specially ocurring with tiling WMs (maybe because they use a tree approach to rooting windows and tiling them instead of a root workspace with grips and floating windows with no parental relationship. Dunno, only my guess). Please let me know if I can contribute with any additional information.

Problematic Default Filename

The default filename format includes :, which is problematic for certain unfortunately popular filesystems. Perhaps these could be removed (so it's just %H%M%S)? I think the format is still pretty clear without them.

select error

When I try to run maim -s and mouse is over any window and I select it maim gives an error:

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  73 (X_GetImage)
  Serial number of failed request:  25  
  Current serial number in output stream:  25  

Problem doesn't appear when mouse is over lemonbar and then I select the window I'd like to print (bspwm@arch).
video

[feature request]Allow resizing of region before taking a snapshot?

How about allowing resizing of region before taking the snapshot? At the moment, it is near impossible to take a snapshot of a selected region if the region is big enough that moving your pointer from one corner of the trackpad to the opposite is not enough to cover this region. Since it's not yet possible to resize the region before taking the screenshot by releasing the mouse button, this is a problem.

Partial screenshots look strange.

screenshot

This is using maim -s ~/screenshot.png.

I don't get any problems when selecting a whole window, or when screenshotting the whole screen.

'Could NOT find OpenGL' error.

$cmake ./                                                                                    
-- Regenerating cmdline.in
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
  Could NOT find OpenGL (missing: OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-2.8/Modules/FindOpenGL.cmake:161 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:109 (find_package)
$cmake --version    
cmake version 2.8.12.2

I'm using Linux Mint. How can i fix it?

Command sed not found.

Warning: Command gengetopt or sed not found! Won't regenerate command line code. 
...
$which sed
/bin/sed

i'm using Ubuntu based Linux MInt.

maim+slop+`--windowid` not working (OSX)

The only way maim works for me on OSX is by specifying --windowid, otherwise I'm getting empty black images, with just the cursor visible. However combining with slop, -s, I always get black shots with just the cursor visible.

$ maim -i $(xdotool getactivewindow) test_maim.png  # Works!

$ maim -s -i $(xdotool getactivewindow) test_slop.png  # Black image with cursor only
$ maim -s --localize -i $(xdotool getactivewindow) test_slop.png  # Black image with cursor only

notify user of delay

i love the maim and slop combination. unfortunately, I had to create this ugly hack to implement a delay instead of just using --delayoption because i want feedback to the user that the screenshot is about to be taken...

eval $(slop --nodecorations)
notify-send --expire-time=1000 "taking screenshot in 3 secs"; sleep 1
notify-send --expire-time=1000 "taking screenshot in 2 secs"; sleep 1
notify-send --expire-time=900 "taking screenshot in 1 secs"; sleep 1
maim -g $G "$snapsdir/$snap"

i'd prefer to use maim --select --delay 3, but then there's no visual indication that the screenshot is about to be taken...

could we have some sort of "CHEEEEEEEESE" visual output before actually taking the screenshot with --delay?

thanks!

how can i change the maim default folder

everytime when i take a screenshot, it will create image file at ~/your-png-file
but i want it create image file at ~/my-specified-folder/your-png-file by default

is there anyway to do it??

README inaccurate wrt screenshots incl. mouse pointer

The README says:

maim can actually take screenshots with your cursor included in them! It does this using the XFixes extension. I don't think there's any other screenshooters that do this.

KSnapshot 0.8.1, KDE's screenshot tool, has an option "Include mouse pointer" which acts as expected.
Therefore, you might want to change above sentence to "To my knowledge, no other commandline screenshot tool does this." or something similar. (While KSnapshot has a few commandline options, the pointer option can only be changed in the GUI).

Make --hidecursor the default or give it a short option.

This is a suggestion to bring maim more in inline with scrot. At least
personally and all the people I've spoken to, the default of showing the mouse
pointer only seems to only get in the way of the content (troubleshooting). It
would be nice if either --hidecursor was made the default operation or a more
convenient shortopt was provided.

A workaround for now is to use aliases or wrapper scripts.

Segfault on Arch Linux

maim foobar.png consistently segfaults for me. I don't know why. I'm running recently updated Arch with bspwm for windows manager. I tried stracing the command, but it's mostly gibberish to me. It keeps repeating this error:

recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"\1\1!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(3, 0x7fff612954e0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, 0x7fff612954e0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{"\214\24\3\0O\0\0\0\\W\0\0", 12}, {NULL, 0}, {"", 0}], 3) = 12
poll([{fd=3, events=POLLIN}], 1, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"\1\0\"\0\3\0\0\0\\W\0\0\0\0\0\0\0\5\0\4T\0\0\0\1\0?\0\1\0\2\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 44
recvmsg(3, 0x7fff61295db0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, 0x7fff61295db0, 0)           = -1 EAGAIN (Resource temporarily unavailable)

and then the segfault happens. maim version is 3.4.43. I suspect that the issue might be in my setup, since this version was out for a long time and somebody would have noticed by now that it doesn't work on archlinux.

How can I help?

Inconsistency detected by ld.so

I run maim on Arch Linux and got this error:
"Inconsistency detected by ld.so: dl-version.c: 224: _dl_check_map_versions: Assertion `needed != ((void *)0)' failed!"

Screenshot with compositor's shadows

Hey,

I've been using maim for a while but I never asked myself if it could take compton's shadows with a selected window.
If it is possible I'd love to have this feature made available.

If you don't what I mean here's an example:
screenshot from 2017-01-12 22-27-58

But now with shadows.
screenshot from 2017-01-12 22-27-58-shadows

black image on gnome wayland

maim used to work fine on my system. I use arch linux. I updated my system and now have gnome 3.22. gnome 3.22 uses wayland by default. Since that update maim produces black images. the images have the same resolution as my screen. 1280x800.

Please confirm whether this is a problem with wayland or just a problem on my system.

$ maim --version
maim v3.4.47

Copyright (C) 2014 Dalton Nell, Maim Contributors
(https://github.com/naelstrof/maim/graphs/contributors)
$ uname -a
Linux lestop 4.8.4-1-ARCH #1 SMP PREEMPT Sat Oct 22 18:26:57 CEST 2016 x86_64 GNU/Linux
$ gnome-shell --version
GNOME Shell 3.22.1

Please tell me what more information do you need.

Invoking from DWM source

 static const char *stopbg[]     = { "systemctl", "--user", "stop", "feh-wallpaper.timer", NULL };
-static const char *scrot[]      = { "scrot", NULL };
+static const char *maim[]       = { "maim", NULL };
 static const char *termcmd[]    = { "st", "-c", "st-256color", "-e", "dvtm", "-M", NULL };
 static const char *trans[]      = { "trans-exempt.sh", NULL };

I tried to switch from scrot to maim for my screenshot tool, but maim doesn't seem to like the way in which dwm is invoking it. Scrot works fine under this setup, nothing happens with maim.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.