Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Automated screenshot script.
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
senectus
Guru
Guru


Joined: 17 Jul 2003
Posts: 534

PostPosted: Sun May 09, 2004 10:58 am    Post subject: Automated screenshot script. Reply with quote

I have an idea for a script.. thats way beyond my capabilaties as a scripter.. but would be a nice thing to have :-)

I want a script that runs at say, 3 am every morning and does this (in this order):

turn off screen saver
minimize everything on the desktop
Take a screen shot
Uploads the screen shot up to an ftp site overwriting the last one.

Any chance someone out there is bored enough to make an e-build for this? I't make a nice addition to my sig ;-)

EDIT: Come to think of it.. if it gave you the choice of if you wanted to minimize or not and at what time you wanted the screen shot.. yeah.. lots of variables :-D
_________________
2800+XP A7N8X FX6600GT
www.modmeup.net |
Belief is 9/10 of YOUR reality.
Wise man say: A skilled troll is a master baiter.


Last edited by senectus on Thu May 13, 2004 6:34 am; edited 1 time in total
Back to top
View user's profile Send private message
christer75
n00b
n00b


Joined: 20 Apr 2004
Posts: 64

PostPosted: Sun May 09, 2004 11:05 am    Post subject: Reply with quote

Come on, take this opportunity to learn how to write scripts yourself instead. Its not hard, and its a lot of fun to have achieved something on your own. :)
Back to top
View user's profile Send private message
senectus
Guru
Guru


Joined: 17 Jul 2003
Posts: 534

PostPosted: Sun May 09, 2004 12:34 pm    Post subject: Reply with quote

christer75 wrote:
Come on, take this opportunity to learn how to write scripts yourself instead. Its not hard, and its a lot of fun to have achieved something on your own. :)


I am/do/will, My life is a constant learning curve.. If I aint learning something I get bored...

It was just a suggestion is all :)
_________________
2800+XP A7N8X FX6600GT
www.modmeup.net |
Belief is 9/10 of YOUR reality.
Wise man say: A skilled troll is a master baiter.
Back to top
View user's profile Send private message
lbrtuk
l33t
l33t


Joined: 08 May 2003
Posts: 910

PostPosted: Sun May 09, 2004 4:05 pm    Post subject: Reply with quote

I think it would be better if it randomly took a shot sometime during the day. This way we could catch you looking at lederhosen porn.
Back to top
View user's profile Send private message
senectus
Guru
Guru


Joined: 17 Jul 2003
Posts: 534

PostPosted: Sun May 09, 2004 10:31 pm    Post subject: Reply with quote

lbrtuk wrote:
lederhosen


what is this?
_________________
2800+XP A7N8X FX6600GT
www.modmeup.net |
Belief is 9/10 of YOUR reality.
Wise man say: A skilled troll is a master baiter.
Back to top
View user's profile Send private message
lbrtuk
l33t
l33t


Joined: 08 May 2003
Posts: 910

PostPosted: Sun May 09, 2004 10:39 pm    Post subject: Reply with quote

http://wabashweb.com/germany/week8/mon-lederhosen-large.jpg
http://linguistics.arizona.edu/~carnie/Media/leder.gif
http://travel.canoe.ca/TravelEuropeImages/germany_ski4.jpg
Back to top
View user's profile Send private message
senectus
Guru
Guru


Joined: 17 Jul 2003
Posts: 534

PostPosted: Sun May 09, 2004 11:46 pm    Post subject: Reply with quote

lbrtuk wrote:
http://wabashweb.com/germany/week8/mon-lederhosen-large.jpg
http://linguistics.arizona.edu/~carnie/Media/leder.gif
http://travel.canoe.ca/TravelEuropeImages/germany_ski4.jpg

8O
hoooookay...

Not sure why that might "excite" someone... :?
_________________
2800+XP A7N8X FX6600GT
www.modmeup.net |
Belief is 9/10 of YOUR reality.
Wise man say: A skilled troll is a master baiter.
Back to top
View user's profile Send private message
christer75
n00b
n00b


Joined: 20 Apr 2004
Posts: 64

PostPosted: Mon May 10, 2004 10:06 am    Post subject: Reply with quote

And I would prefer girls instead of men in leather.... maybe thats just me. :)
Back to top
View user's profile Send private message
senectus
Guru
Guru


Joined: 17 Jul 2003
Posts: 534

PostPosted: Mon May 10, 2004 2:20 pm    Post subject: Reply with quote

Can someone point me in the direction of a good scripting howto site??

something for n00bs would be nice..

oh and no more sites with fat germans please ;-)
_________________
2800+XP A7N8X FX6600GT
www.modmeup.net |
Belief is 9/10 of YOUR reality.
Wise man say: A skilled troll is a master baiter.
Back to top
View user's profile Send private message
spb
Retired Dev
Retired Dev


Joined: 02 Jan 2004
Posts: 2135
Location: Cambridge, UK

PostPosted: Mon May 10, 2004 2:47 pm    Post subject: Reply with quote

senectus wrote:
Can someone point me in the direction of a good scripting howto site??

Try the Advanced Bash-Scripting Guide.

Quote:
something for n00bs would be nice..

Try the ABS, but if you want something more beginner-oriented, have a look at the Bash Beginners' Guide

Quote:
oh and no more sites with fat germans please ;-)

I don't think there are any there...;)
Back to top
View user's profile Send private message
lbrtuk
l33t
l33t


Joined: 08 May 2003
Posts: 910

PostPosted: Mon May 10, 2004 3:57 pm    Post subject: Reply with quote

In all seriousness, this is quite easy.

Assuming you're using xscreensaver.

All you would have to do is point your crontab to do a script during the night.

That script would only contain a few commands.

1. deactivate screensaver.
2. sleep for a couple of seconds. (to give the screensaver a chance)
3. take a screenshot.
4. upload it.

Now the way I suggest doing it is something along the lines of:

Code:
#!/bin/bash

#this is for xscreensaver - dont know what to do if you're using kde or something else
xscreensaver-command --deactivate

#simple enough
sleep 4

#or somewhere better to put it
import -window root -quality 90 /tmp/screenshot.png

#ftp from a script is a complete pain in the arse. or use scp or whatever floats your boat.
USER='yourid'
PASSWD='yourpw'

ftp -pn your.server.name <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
binary
put /tmp/screenshot.png
quit
END_SCRIPT

exit 0


On the last line I have put the password in the script: you will have to store it somewhere. Which is a security hazard. But all security is a compromise between convenience and... er.. security.

Possibly putting the password on the command line is just as insecure as anything else.
Back to top
View user's profile Send private message
Jeremy_Z
l33t
l33t


Joined: 05 Apr 2004
Posts: 671
Location: Shanghai

PostPosted: Mon May 10, 2004 4:43 pm    Post subject: Reply with quote

can you store the passwd crypted maybe ?
but in order to have it secure you can also configure your ftp server in order to restrict this user to uploading screenshots. (if you have admin control on it obviously)
Back to top
View user's profile Send private message
BlackEdder
Advocate
Advocate


Joined: 26 Apr 2004
Posts: 2588
Location: Dutch enclave in Egham, UK

PostPosted: Mon May 10, 2004 5:03 pm    Post subject: Reply with quote

To use ftp in a script I use:
ftp <<**
open your.server.nl
cd /screenshot
send screenshot.jpg
bye
**

then you make a .netrc thats only readable by the user self (else ftp won't accept it)
-rw------- 1 user group 61 Jul 9 2003 .netrc
with:
machine your.server.nl
login yourlogin
password yourpassword

because the .netrc is only readable by the user self it's a bit secure :)
Back to top
View user's profile Send private message
christer75
n00b
n00b


Joined: 20 Apr 2004
Posts: 64

PostPosted: Mon May 10, 2004 6:29 pm    Post subject: Reply with quote

Hmm interesting. Would it be possible to encrypt the password with the same algorithm linux uses to encrypt login passwords?
Back to top
View user's profile Send private message
BlackEdder
Advocate
Advocate


Joined: 26 Apr 2004
Posts: 2588
Location: Dutch enclave in Egham, UK

PostPosted: Mon May 10, 2004 6:33 pm    Post subject: Reply with quote

Anyone knows if ftp passwords are sen encrypted over the network? or just plain text?
Back to top
View user's profile Send private message
christer75
n00b
n00b


Joined: 20 Apr 2004
Posts: 64

PostPosted: Mon May 10, 2004 6:38 pm    Post subject: Reply with quote

Plain text. Use SSH if you dont trust people on your LAN.

Emerge tcpdump and try a telnet session. Its fun and you'll see what I mean. :)
Back to top
View user's profile Send private message
BlackEdder
Advocate
Advocate


Joined: 26 Apr 2004
Posts: 2588
Location: Dutch enclave in Egham, UK

PostPosted: Mon May 10, 2004 6:47 pm    Post subject: Reply with quote

Well if it's plain text then I don't really see the point in encrypting .netrc :)
Back to top
View user's profile Send private message
christer75
n00b
n00b


Joined: 20 Apr 2004
Posts: 64

PostPosted: Mon May 10, 2004 7:20 pm    Post subject: Reply with quote

Its good if someone gets access to your computer. =)
Back to top
View user's profile Send private message
lbrtuk
l33t
l33t


Joined: 08 May 2003
Posts: 910

PostPosted: Mon May 10, 2004 10:22 pm    Post subject: Reply with quote

Just though about this it might be nice to emerge optipng (like pngcrush only better) to be nice to the people downloading the image.

So basically what I would end up doing is this:

(yes I know I'm putting the password in the script, but it's just for simplicity. Anyway, what's to say you can't make the script only readable by the user running it? In this case the security would be the same as use of .netrc)

Before anything emerge optipng.

Code:
#!/bin/bash

#this is for xscreensaver - dont know what to do if you're using kde or something else
xscreensaver-command --deactivate

#simple enough
sleep 4

#or somewhere better to put it
import -window root -quality 90 /tmp/screenshot.png

#highly compress png for politeness to dialup users
optipng -o5 /tmp/screenshot.png

#ftp from a script is a complete pain in the arse. or use scp or whatever floats your boat.
USER='yourid'
PASSWD='yourpw'

ftp -pn your.server.name <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
binary
put /tmp/screenshot.png
quit
END_SCRIPT

exit 0
Back to top
View user's profile Send private message
Rainmaker
Veteran
Veteran


Joined: 12 Feb 2004
Posts: 1650
Location: /home/NL/ehv/

PostPosted: Mon May 10, 2004 11:15 pm    Post subject: Reply with quote

Just chmod 0700 the file, and than add it to your personal cron (otherwise cron won't be able to run it)

crontab
0 3 * * * /home/myname/thenameofmyfantasticftpuploadscreenshotscript

This script will then run at 3 am every night
_________________
If you can't dazzle them with brilliance, baffle them with bullshit.
Back to top
View user's profile Send private message
lbrtuk
l33t
l33t


Joined: 08 May 2003
Posts: 910

PostPosted: Tue May 11, 2004 12:53 am    Post subject: Reply with quote

Just for the record, if you want to deactivate a kde screensaver from the command line, you just have to make a simple dcop call.

Code:
dcop kdesktop KScreensaverIface quit


will do it.
Back to top
View user's profile Send private message
sapphirecat
Guru
Guru


Joined: 15 Jan 2003
Posts: 376

PostPosted: Tue May 11, 2004 6:34 pm    Post subject: Reply with quote

The truly paranoid will reactivate the screensaver afterwards.
Code:
# The old-school xlock/xautolock way! This is 1337.
pkill -9 xlock
sleep 4
import blahblahblah
xautolock -locknow # Close door behind us

Remember not to be working on the console at 3:00 AM or you'll find yourself with a garbage screenshot.

EDIT: Incidentally, import takes 16-bit/channel PNGs by default, so you should override it with '-depth 8' (since your source is 8-bit/channel anyway). optipng can take care of this, but if you can make imagemagick do it in the first place, why not?
_________________
Former Gentoo user; switched to Kubuntu 7.04 when I got sick of waiting on gcc. Chance of thread necro if you reply now approaching 100%...
Back to top
View user's profile Send private message
lbrtuk
l33t
l33t


Joined: 08 May 2003
Posts: 910

PostPosted: Tue May 11, 2004 8:40 pm    Post subject: Reply with quote

The way you were stopping the screensaver is actually killing the screensaver daemon. The previous two methods I mentioned don't actually kill the screensaver, they just activate hooks in the screensaver that make it think a mouse has been moved or a key pressed. So they don't need to be restarted.

Re the png thing: didn't know that. interesting. Still, optipng can crush the png smaller than imagemagick ever could.
Back to top
View user's profile Send private message
sapphirecat
Guru
Guru


Joined: 15 Jan 2003
Posts: 376

PostPosted: Wed May 12, 2004 9:09 pm    Post subject: Reply with quote

lbrtuk wrote:
The way you were stopping the screensaver is actually killing the screensaver daemon.

xautolock is the daemon, xlock is just the subprocess it ran to lock the screen. Since they're not integrated, killing xlock merely unlocks the screen again. Then "xautolock -locknow" contacts the still-running daemon and asks it to lock the screen again, which it does by spawning another instance of xlock.

I know this works because I tested it before posting.
_________________
Former Gentoo user; switched to Kubuntu 7.04 when I got sick of waiting on gcc. Chance of thread necro if you reply now approaching 100%...
Back to top
View user's profile Send private message
lbrtuk
l33t
l33t


Joined: 08 May 2003
Posts: 910

PostPosted: Wed May 12, 2004 10:06 pm    Post subject: Reply with quote

Ah, I see. Different design.

Anyone know how screensavers work in gnome? We could make this comprehensive while we're at it.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum