You are not logged in.
Hi, I made this yesterday because I was annoyed that my PrintScrn button didn't do anything.
All it does is that it generates a filename, and then runs scrot to save the screenshot in a directory.
The filename is generated to contain the following:
DD-MM-YYYY_HH-mm-ss-(random number)
Example: 31-07-2009_17-27-19-660
The random number is a number between 1 and 10000 just to ensure that screenshots are not overwriting because you spam the script :-)
And now for the actual script:
file: screenshot
#!/usr/bin/python
# coding=UTF-8
# Filename : screenshot.py
'''
This program was made by Paaskehare <Ole Bergmann>
- www.paaskehare.dk
- www.w0lf.biz
Feel free to redistribute/edit/delete/burn/treat this program as you please.
'''
from os import system
from datetime import datetime
from random import randint
today = datetime.now()
number = str(randint(1,10000))
filename = today.strftime('%Y-%m-%d_%H-%M-%S-')+number+'.png'
filename = 'scrot /home/paaskehare/pic/screenshots/'+filename
try:
system(filename)
except:
print 'could not save screenshot.'
Just save it anywhere on your computer and give it executable permissions.
Remember to change the "/home/paaskehare/pic/screenshots/" to a directory of your choice.
You can now make the program work within any desktop environment, remember python and scrot are required.
How I got my PrintScrn button binded
I personally use openbox (3.4), so this one was an easy one for me, I just edited the rc.xml file to contain the following:
file: rc.xml
...
<!-- Keybinding for print screen -->
<keybind key="Print">
<action name="Execute">
<command>/home/paaskehare/Documents/python/screenshot</command>
</action>
</keybind>
...
Just change the directory to where you put the script and restart X
Last edited by Paaskehare (2009-08-05 12:17:37)
→ im.ole
Offline
Since this is very related, here is my version, using xbindkeys
"scrot /home/hashbox/screenshots/`date +%d%m%y`.png"
Sys_Req
Offline
Offline