Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!