WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Screenshot- Possible to set 'saved to' File-name?  (Read 1841 times)

Offline newtotinycore

  • Newbie
  • *
  • Posts: 37
Screenshot- Possible to set 'saved to' File-name?
« on: March 26, 2012, 07:39:21 PM »
Excuse a simple-minded question.
When taking a screenshot, is there a way to set the file-name the image is saved to at the time the image is made?
I know I can rename the file later; just wondering if I can avoid having to copy and type (correctly) the 10 digit number the  screenshot utility uses.

Thanks in advance.

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Screenshot- Possible to set 'saved to' File-name?
« Reply #1 on: March 26, 2012, 09:35:29 PM »
Well, the menu item 'ScreenShot' calls in the end '/usr/local/bin/screenshot.sh', which is just a wrapper script around a call of 'imlib2_grab FILENAME.EXT' (with EXT something like 'png', 'jpg', 'ppm' or 'bmp'). 

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Screenshot- Possible to set 'saved to' File-name?
« Reply #2 on: March 26, 2012, 09:52:45 PM »
Hi newtotinycore
You could try modifying the  /usr/bin/screenshot.sh  script to look like:
Code: [Select]
#!/bin/sh
[ -z ${DISPLAY} ] && echo "Requires X" &&  exit 1
editor /tmp/savename.txt
filename=`cat /tmp/savename.txt`.png
/bin/sh -c "sleep 1 && /usr/bin/imlib2_grab $filename"                         
exec popup "Screenshot saved to $HOME/$filename"
When you take a screenshot, the editor will open. Type the filename you want, NO extension and NO carriage return.
Click the editors close button, click Save.  You will find  filename.png in your home directory. If you want the change
to survive a reboot, add the line   usr/bin/screenshot.sh   to your   /opt/.filetool.lst   file.

Offline newtotinycore

  • Newbie
  • *
  • Posts: 37
Re: Screenshot- Possible to set 'saved to' File-name?
« Reply #3 on: March 26, 2012, 11:23:58 PM »
Thanks Maro for telling me the complete path : /usr/local/bin/screenshot.sh. It doesn't take much to throw me off course.

And thanks for the complete explanation, Rich; works great!
Looking at the code was very helpful.

In case any other newbies are interested in this change, on my system what works is:
filename=`cat /tmp/savename.txt  "+%d"`.png

Offline newtotinycore

  • Newbie
  • *
  • Posts: 37
Re: Screenshot- Possible to set 'saved to' File-name?
« Reply #4 on: March 27, 2012, 03:10:16 PM »
                 Trying same modification to screenshot.sh in tinycore 4.3 that worked in 4.1.
                 When I try to save changes to screenshot.sh, get message "Error writing to file 'screenshot':
                 Read-only file system."
                 Tried opening file with sudo and using chmod on screenshot.sh and link under /tmp/tcloop..., also tried sudo su and then chown.
                 No luck, still read only file system.
                 Maybe it's not worth trying to change screenshot behavior- but I am curious if I messed up when installing 4.3 to USB.
                 I used ext 2.

                Thanks for any pointers.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Screenshot- Possible to set 'saved to' File-name?
« Reply #5 on: March 27, 2012, 03:41:42 PM »
You have to break the symbolic link.
mv screenshot.sh screenshot.org
cp screenshot.org screenshot.sh

Offline newtotinycore

  • Newbie
  • *
  • Posts: 37
Re: Screenshot- Possible to set 'saved to' File-name?
« Reply #6 on: March 27, 2012, 04:20:26 PM »
Thanks Gerald (and Rich and Maro), works great.