Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

242
Visualizações
Bash script with scrot area not working

I created a bash script to use for interactive screen capture and another one for window capture. I'm linking to these with keyboard shortcuts in Linux. The window capture script works without problems:

#!/bin/sh  
scrot -u 'ScreenShot_%Y-%m-%d_at_%I:%M:%S-%p.png' -e 'mv $f ~/Pictures/scrot-screenshots'

But the script for for area capture (user selects area with mouse drag) does not work, even though the command works in terminal:

#!/bin/sh  
scrot -s 'ScreenShot_%Y-%m-%d_at_%I:%M:%S-%p.png' -e 'mv $f ~/Pictures/scrot-screenshots'

What am I doing wrong? Or maybe a better question is what is preventing the script from letting me select an area of the screen?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I manged to get it working by adding a delay to give the giblib resource time (2/10 of a second) to load:

#!/bin/sh
sleep 0.2 ; scrot -s 'ScreenShot_%Y-%m-%d_at_%I:%M:%S-%p.png' -e 'mv $f ~/Pictures/scrot-screenshots'

How I found the solution:
I couldn't figure out how to get errors to output to a file because running my script from terminal didn't produce any errors. Double clicking the script ran properly and script > file 2>&1 in terminal didn't give me any errors because it ran properly from terminal. I only had errors when I tried to use the keyboard shortcuts (keybindings) attached to the second command from my original post. To see the error that finally lead to the above solution, I downloaded:

`apt-get install xbindkeys` && `apt-get install gconf-editor`

I ran gconf-editor and used the Run Action to executed the script the same manner it would be executed if I was using the keybindings...but attached to a terminal output. That gave me the error output I needed to see:

giblib error: couldn't grab pointer:Resource temporarily unavailable

Which lead me to this post: https://bbs.archlinux.org/viewtopic.php?id=86507 for the tip.

over 4 years ago · Santiago Trujillo Relatório

0

For whomever the jtlindsey's answer did not work for solving the problem :

giblib error: couldn't grab pointer:Resource temporarily unavailable

Another solution could be this : just before calling scrot, run the command :

xdotool key XF86Ungrab

This should release the pointer, and the scrot command should work after it. Note : the source claims that before executing previous xdotool command, it would possibly be required to execute :

setxkbmap -option grab:break_actions
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda