Sugar/Quick screenshot hack: Difference between revisions
(mention the basic Alt-1 technique first. Also reduce heading level per wiki style guide.) |
|||
Line 1: | Line 1: | ||
The [[Keyboard_Shortcuts|keyboard shortcut]] alt + 1 on the XO captures the screen; this advanced procedure makes it easier to deal with multiple screenshots. |
|||
⚫ | |||
⚫ | |||
Cynthia from the learning lab asked me ([[User:DanielDrake|DanielDrake]]) to hack an XO so that taking a substantial number of screenshots and transferring them to her Mac is easy. Right now, it is tedious to copy screenshots one-by-one to a USB stick and then transport the USB stick to another system. |
Cynthia from the learning lab asked me ([[User:DanielDrake|DanielDrake]]) to hack an XO so that taking a substantial number of screenshots and transferring them to her Mac is easy. Right now, it is tedious to copy screenshots one-by-one to a USB stick and then transport the USB stick to another system. |
||
= Requirements = |
== Requirements == |
||
* An internet-connected XO running sugar |
* An internet-connected XO running sugar |
||
Line 11: | Line 13: | ||
The decision was made to store the screenshots on a remote server and access them through the remote server to allow for the XO's IP changing, different XO's being used on different days, etc. It would also be realistic to store the screenshots on the XO and have the target computer access them over SSH, and that would only be a simple modification below. |
The decision was made to store the screenshots on a remote server and access them through the remote server to allow for the XO's IP changing, different XO's being used on different days, etc. It would also be realistic to store the screenshots on the XO and have the target computer access them over SSH, and that would only be a simple modification below. |
||
= Creating SSH key and configuring remote server = |
== Creating SSH key and configuring remote server == |
||
The XO needs to have passwordless access to the remote server. You need to create a ssh key pair. If you want to have multiple XOs set up like this, only one of them needs to create the key, then you can copy it to any more XOs that you want to use in this way. |
The XO needs to have passwordless access to the remote server. You need to create a ssh key pair. If you want to have multiple XOs set up like this, only one of them needs to create the key, then you can copy it to any more XOs that you want to use in this way. |
||
Line 26: | Line 28: | ||
#* <tt>exit</tt> |
#* <tt>exit</tt> |
||
= Setting up the XO = |
== Setting up the XO == |
||
* At the terminal activity, create a local screenshots directory |
* At the terminal activity, create a local screenshots directory |
||
Line 37: | Line 39: | ||
** <tt>chmod a+x /home/olpc/cpscrn</tt> |
** <tt>chmod a+x /home/olpc/cpscrn</tt> |
||
= Modifying sugar = |
== Modifying sugar == |
||
Sugar must be modified to save screenshots to disk, rather than to the journal. |
Sugar must be modified to save screenshots to disk, rather than to the journal. |
||
Line 60: | Line 62: | ||
* Save the file and close the text editor |
* Save the file and close the text editor |
||
= Accessing remote server = |
== Accessing remote server == |
||
* Configure your target computer to have access to the screenshots subdirectory on remote.server.com. |
* Configure your target computer to have access to the screenshots subdirectory on remote.server.com. |
||
** This is system-dependent. |
** This is system-dependent. |
||
= Taking screenshots = |
== Taking screenshots == |
||
* Restart sugar so that your code changes take effect |
* Restart sugar so that your code changes take effect |
Revision as of 05:40, 29 July 2008
The keyboard shortcut alt + 1 on the XO captures the screen; this advanced procedure makes it easier to deal with multiple screenshots.
Background
Cynthia from the learning lab asked me (DanielDrake) to hack an XO so that taking a substantial number of screenshots and transferring them to her Mac is easy. Right now, it is tedious to copy screenshots one-by-one to a USB stick and then transport the USB stick to another system.
Requirements
- An internet-connected XO running sugar
- ssh access to a remote server on the internet, which we'll call remote.server.com (and your username is "user")
- The internet-connected "target" computer
The decision was made to store the screenshots on a remote server and access them through the remote server to allow for the XO's IP changing, different XO's being used on different days, etc. It would also be realistic to store the screenshots on the XO and have the target computer access them over SSH, and that would only be a simple modification below.
Creating SSH key and configuring remote server
The XO needs to have passwordless access to the remote server. You need to create a ssh key pair. If you want to have multiple XOs set up like this, only one of them needs to create the key, then you can copy it to any more XOs that you want to use in this way.
- On the XO, launch a terminal activity
- Generate a SSH key:
- ssh-keygen -t rsa
- Copy the public key to the remote server
- ssh-copy-id -i .ssh/id_rsa.pub user@remote.server.com
- Log into the remote server (confirming that there is no prompt for password/passphrase) and create a screenshots directory
- ssh user@remote.server.com
- mkdir screenshots
- Logout of remote server
- exit
Setting up the XO
- At the terminal activity, create a local screenshots directory
- mkdir screenshots
- Create a script called at /home/olpc/cpscrn with the following contents:
#!/bin/bash scp $1 user@remote.server.com:screenshots
- Be sure to modify this line to reflect your remote server information
- Mark it executable
- chmod a+x /home/olpc/cpscrn
Modifying sugar
Sugar must be modified to save screenshots to disk, rather than to the journal.
- Become root
- sudo -s
- Open /usr/share/sugar/shell/view/Shell.py in a text editor
- nano /usr/share/sugar/shell/view/Shell.py
- Find the take_screenshot function, about 85% of the way through the file
- ctrl + w take_screenshot
- Modify the top of the function so that it looks as follows:
- The bold line is the line that you need to change
def take_screenshot(self): file_path = os.path.join("/home/olpc/screenshots", '%i.png' % time.time()) window = gtk.gdk.get_default_root_window()
- Approximately 10 lines below, add two lines of code
- The bold lines are the lines that you need to add
screenshot.save(file_path, "png") os.system("/home/olpc/cpscrn %s" % file_path) return try:
- Save the file and close the text editor
Accessing remote server
- Configure your target computer to have access to the screenshots subdirectory on remote.server.com.
- This is system-dependent.
Taking screenshots
- Restart sugar so that your code changes take effect
- ctrl + alt + erase (warning: will lose unsaved work!)
- Press alt + 1 to take a screenshot
- The screenshot will be saved locally in /home/olpc/screenshots and also copied to the remote server
- It may take a few seconds for the screenshot to be saved, compressed, and uploaded over the internet
- You can then view the screenshot(s) on your target computer by opening the folder on the remote server