naelstrof / maim

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.
Other
2.15k stars 78 forks source link

Seg Fault with Awesome-wm #191

Closed edisonhello closed 3 years ago

edisonhello commented 4 years ago

As title. My awesome config about this part:

        -- Screenshot                                                                                                                                         
    awful.key({ }, "Print", function()                                         
                awful.util.spawn("maim '/home/edison/Pictures/Screenshots/" .. os.date("Screenshot %Y-%m-%d %H:%M:%S Fullscreen.png") .. "'") end),
    awful.key({ "Shift" }, "Print", function()                                 
                awful.util.spawn("maim -s '/home/edison/Pictures/Screenshots/" .. os.date("Screenshot %Y-%m-%d %H:%M:%S.png") .. "'") end),
    awful.key({ "Control" }, "Print", function()                                                                                                              
                awful.util.spawn("maim | xclip -selection clipboard -t image/png -i") end),
    awful.key({ "Shift", "Control" }, "Print", function() 
                awful.util.spawn("maim -s | xclip -selection clipboard -t image/png -i") end),

Above two line work while another two always cause seg fault. I tried change the key combination (like modkey + p) but the result still same.

Output of journalctl:

-- Subject: Process 1207492 (maim) dumped core
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: man:core(5)
-- 
-- Process 1207492 (maim) crashed and dumped core.
-- 
-- This usually indicates a programming error in the crashing program and
-- should be reported to its vendor as a bug.
Dec 15 22:22:57 arch-dell systemd-coredump[1207555]: Process 1207553 (maim) of user 1000 dumped core.

                                                     Stack trace of thread 1207553:
                                                     #0  0x00007ff9ce882f25 raise (libc.so.6 + 0x3bf25)
                                                     #1  0x00007ff9ce86c897 abort (libc.so.6 + 0x25897)
                                                     #2  0x00007ff9ceac081d _ZN9__gnu_cxx27__verbose_terminate_handlerEv (libstdc++.so.6 + 0x9681d)
                                                     #3  0x00007ff9ceacd4da _ZN10__cxxabiv111__terminateEPFvvE (libstdc++.so.6 + 0xa34da)
                                                     #4  0x00007ff9ceacd537 _ZSt9terminatev (libstdc++.so.6 + 0xa3537)
                                                     #5  0x00007ff9ceacd78e __cxa_throw (libstdc++.so.6 + 0xa378e)
                                                     #6  0x000055bf9c873099 _ZN7cxxopts7Options5parseERiRPPc (maim + 0x2e099)
                                                     #7  0x000055bf9c867767 _Z3appiPPc (maim + 0x22767)
                                                     #8  0x000055bf9c8602e6 main (maim + 0x1b2e6)
                                                     #9  0x00007ff9ce86e153 __libc_start_main (libc.so.6 + 0x27153)
                                                     #10 0x000055bf9c86032e _start (maim + 0x1b32e)
-- Subject: Process 1207553 (maim) dumped core
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: man:core(5)
-- 
-- Process 1207553 (maim) crashed and dumped core.
-- 
-- This usually indicates a programming error in the crashing program and
-- should be reported to its vendor as a bug.

Also, maim | xclip -selection clipboard -t image/png -i in terminal works fine.

foxpy commented 4 years ago

Something definitely is wrong with pipe. Try wrapping execution in sh -c, like this: awful.util.spawn("sh -c 'maim | xclip -selection clipboard -t image/png -i'") end),

foxpy commented 3 years ago

This issue has nothing to do about Awesome-wm. @naelstrof I think it should be closed.

naelstrof commented 3 years ago

Thanks!

joaopauloalbq commented 3 years ago

I'm using like this:

       awful.key({}, "Print", function () 
            awful.spawn.with_shell("maim ~/Imagens/Screenshots/Screenshot_$(date +%Y%m%d)_$(date +%H%M%S).png", false) end,
            {description = "Print desktop", group = "Screenshot"}),

       awful.key({ modkey }, "Print", function ()
            awful.spawn.with_shell("maim -i $(xdotool getactivewindow) ~/Imagens/Screenshots/Screenshot_$(date +%Y%m%d)_$(date +%H%M%S).png", false) end,
            {description = "Print window", group = "Screenshot"}),

       awful.key({ "Shift" }, "Print", nil, function ()
            awful.spawn.with_shell("maim -s ~/Imagens/Screenshots/Screenshot_$(date +%Y%m%d)_$(date +%H%M%S).png", false) end,
            {description = "Print area", group = "Screenshot"}),

       awful.key({ "Control" }, "Print", nil, function ()
            awful.spawn.with_shell("maim -s | xclip -selection c -t image/png", false) end,
            {description = "Print area to clipboard", group = "Screenshot"}),`
foxpy commented 3 years ago

ye, spawn.with_shell definitely sounds like a cleaner solution.