We have moved to a new Sailfish OS Forum. Please start new discussions there.
29

HOWTO: Take a screenshot from the command line

asked 2014-04-17 16:55:32 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2016-03-03 22:31:17 +0200

coderus gravatar image

There are a couple of apps available on the Jolla store that will let you take screenshots via the interface, but occasionally you may want/need to capture the screen from the command line, particularly over SSH. The easiest way to do it is to use dbus to send a message to lipstick, the UX manager. It should work on both SailfishOS and Nemomobile, and on all devices.

Here are ways to do it on the command-line, over SSH or to be included in a shell script:

  1. Using dbus-send

    dbus-send --session --print-reply --dest=org.nemomobile.lipstick /org/nemomobile/lipstick/screenshot org.nemomobile.lipstick.saveScreenshot string:"/home/nemo/Pictures/Screenshot-$(date +%y-%m-%d-%H-%M-%S).png"

  2. Using qdbus (from the qt5-qttools-qdbus package)

    /usr/lib/qt5/bin/qdbus org.nemomobile.lipstick /org/nemomobile/lipstick/screenshot org.nemomobile.lipstick.saveScreenshot "/home/nemo/Pictures/Screenshot-$(date +%y-%m-%d-%H-%M-%S).png"

  3. Using grabscreen

    grabscreen "/home/nemo/Pictures/Screenshot-$(date +%y-%m-%d-%H-%M-%S).png"

The code-snippet below shows how you'd also achieve the same in Qt directly:

QDBusInterface *iface = new QDBusInterface("org.nemomobile.lipstick",
                                           "/org/nemomobile/lipstick/screenshot",
                                           "org.nemomobile.lipstick",
                                           QDBusConnection::sessionBus(),
                                           this);
iface->call(QDBus::NoBlock, "saveScreenshot", QString("/home/nemo/Pictures/Screenshot-%1.png").arg(QDateTime::currentDateTime().toString("yy-MM-dd-hh-mm-ss")));
edit retag flag offensive close delete

Comments

1

You can also try grabscreen --help to see if this command is available on your Jolla. It takes PNG images, which may not display in Gallery but should xdg-open name.png (by default) in your browser.

/usr/bin/grabscreen [/path/to/snapshot.png]

The limits to its versatility may be its independence (or not) of dbus and capturing a PNG whose properties are predefined by the command, apparently not user-tailorable. Correct me, I'm probably assuming too much by obvious appearance and oversimplifying undocumented tooling, or a describing a tool whose documentation I have not seen.

rdmo ( 2015-04-01 08:17:18 +0200 )edit
1

grabscreen tool is part of jolla-developer-mode and can't be used in applications because of that. And it using same dbus method for capturing.

coderus ( 2015-04-01 12:38:04 +0200 )edit

(@coderus: Jolly good. On-device CLI scripts are my interest at this point.)

rdmo ( 2015-04-01 12:59:26 +0200 )edit
1

@rdmo & @coderus

via SSH;

$ sleep 10 && grabscreen

You now have just 10 seconds to get to the screen you want a shot of - grab goes straight to main gallery.

Simpler than all the above, no?, or am I missing something here?

Spam Hunter ( 2016-03-03 14:41:17 +0200 )edit

grabscreen doing same dbus call internally :)

coderus ( 2016-03-03 15:16:02 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2016-05-21 18:32:05 +0200

I have made dbus-send thing on my phone correctly, but I have one question, which buttons should I push to take a screenshot? Sorry, for the bad English.

edit flag offensive delete publish link more

Comments

1

there are no shortcuts to take screenshot on jolla/sailfishos. you can install apps for taking screenshots from jolla store.

coderus ( 2016-05-21 19:16:41 +0200 )edit

OK. Thank you!

Kleino2002 ( 2016-05-22 23:58:53 +0200 )edit

Pressing vol+ and vol- at the same time works for me. Screenshot is made when releasing the buttons.

velox ( 2017-02-02 17:36:28 +0200 )edit
Login/Signup to Answer

Question tools

Follow
6 followers

Stats

Asked: 2014-04-17 16:55:32 +0200

Seen: 3,572 times

Last updated: May 21 '16