Screenshot takes screenshot of itself, needs a delay

I run Droidian 101 on pixel 3a. When I hold the power button and press screenshot, it takes a screenshot of the screenshot menu, not the window/desktop behind it. Seems maybe it needs a delay? Where can I find the command that gets run to add a delay manually? Or is there another/better way to take screenshots?

Also, I imagine that if this was not unique to my phone, someone else would have reported this issue by now (non-functional screenshot) and it would have been fixed for everyone. So I’m wondering why it might be happening only to me? That would be weird.

This happens sometimes, I have seen it as well on other devices randomly (and also has been reported on other community ports).

However, I’m not sure yet on what causes it. It doesn’t look to be something that happens on mainline phones though, so it might be something that is Droidian specific.

grim should work fine though. And there also are Screenshot apps like https://flathub.org/it/apps/org.adishatz.Screenshot that work great.

Happens to me on my VollaPhone 22 all the time as well. I use sleep 5 && grim as a quick fix.

Thanks for the reply. Maybe it’s a stupid question but what command gets run when I long-press on the power button and select “Screenshot”? It feels like the correct solution would be to figure out what command is attached to this action and modify it to include a sleep. I feel like installing another screenshot app when there is seemingly already one that could be tweaked slightly and make things work right… or maybe there’s something I don’t understand about how things are setup.

Ok, well, I still have no idea what command runs when I long-press power and select “Screenshot” but I found a setup I like even more.

  1. The keyboard in Droidian 101 is phosh-osk-stub. I can add additional shortcut keys at the top of the Terminal keyboard using:

gsettings set sm.puri.phosh.osk.Terminal shortcuts "['<ctrl>', '<alt>', 'Home', 'End', 'Left', 'Right']"

  1. I went into Settings → Shortcut → View and Customize Shortcuts, and under “Screenshots” I associated “Take a screenshot” with Alt+s.

Voila! Now if I deploy my keyboard and type the Alt shortcut followed by s, I get the screenshot I want. Not sure how I’d get a screenshot without the keyboard in it, but that doesn’t bother me (so far). Anyways, thought I’d share this info.

I still would like to know what command gets run when a screenshot is taken, if anyone knows. It’d allow for better solutions/options.

Im not sure, but I think its not a command. It is done in the code with wlr-screencopy maybe? Yeah I also have same issue, just never looked into it.

If you know little shell scripting, you could write a script with sleep 5 && grim. Add a desktop file so its in your app drawer, I guess it should work. Never tried.

That’s the info from the old Mobian wiki Tweaks (now only available in the Internet Archive)

Taking screenshots

From the command line

There is no key shortcut to take screenshots, but you can use the command line tool grim (sudo apt install grim).

To make one, just call (can easily be done from SSH so that you can see on your phone display what you are screenshotting)

grim my_screenshot.png

This will save a screenshot in the current directory (if you omit the file name, it will select a unique name automatically).

Unfortunately grim does not support delaying taking a screenshot. In case you want to take a screenshot of something other than the terminal you type grim in - you can run

sleep 10; grim my_screenshot.png

to delay the taking of the screenshot by 10 seconds.

Gnome-screenshot

You can install the gnome-screenshot package. Fullscreen screenshots work! Delay timer works fine too, so you can easily change focus to another app or part of the home screen. The ‘Window’ and ‘Selection’ options currently cause the app to crash.

To install the package:

sudo apt install gnome-screenshot

Out of the box it will not scale properly on the PinePhone (possibly on other devices too?). To fix this:

scale-to-fit gnome-screenshot

Taking screenshots v2 (fancy app)

An even fancier way to take a screenshot using a simple graphical dialog (and initiating it by invoking an “app”) has been described here and works flawlessly on Mobian. It is a good combination between convenience and ease of understanding.

  1. Install the required dependencies: sudo apt install libnotify-bin grim

  2. Place the screenshot script in /home/mobian/bin (or anywhere really). The original script has been adapted to store screenshots in (/home/mobian) rather than /home/purism:

#!/bin/bash 
# this file should be stored as /home/mobian/bin/screenshot 
SCREENSHOT=${HOME}/Pictures/$(date +%Y-%m-%d-%H%M%S).png 
notify-send -t 1000 screenshot "Taking a screenshot in 5 seconds" 
sleep 5 
grim "$SCREENSHOT" 
notify-send screenshot "Screenshot stored at ${SCREENSHOT}"
  1. Make the screenshotter executable as program: chmod 755 /home/mobian/bin/screenshot

  2. Finally create the application icon to easily call it from the homescreen. So create a file in /home/purism/.local/share/applications/screenshot.desktop and put there:

[Desktop Entry] 
Name=Screen Shot 
Type=Application 
Icon=applets-screenshooter 
Exec=/home/mobian/bin/screenshot 
Categories=Utility;

Now all you need to do is clicking on the screenshot icon in your app overview. Or issue “screenshot” in the terminal (it might take a relogin to make ~/bin automatically be picked up as PATH).

Taking screenshots v3

(an improved fancy app with correct display in the local language)

Nothing is so good that it can’t be even better, in three steps to screenshots in the local language, see there:

  1. Install the required dependencies: sudo apt install grim libnotify-bin yad

  2. The script –> /usr/local/bin or another folder in the $PATH variable. Don’t forget to adjust the execution permissions, e.g.: chmod 755 /usr/local/bin/screenshot2app

  3. The *.desktop –> /usr/share/applications

#PP_german:matrix.org hopes you have fun creating a screenshot.

Screen recording

If you want to record the screen, you can use the package wf-recorder (sudo apt install wf-recorder).

If you want to make a video grabbing screen and microphone just call (can be done from SSH)

wf-recorder --file=recording_with_audio.mp4 --audio

Screen recording v2 (fancy app)

Using the above application wf-recorder in combination with yad and a simple bash-script, one can create a cool GUI for screen recordings (with and without audio recording):

Put this script into /home/mobian/bin/screenrecorder.sh or any similar location:

#!/usr/bin/env bash 

SCREENCAST="${HOME}/Videos/$(date +%Y-%m-%d-%H%M%S).mp4"

CHOICE=$(yad --title="Screen Recorder" \
    --text="${SCREENCAST}" \
    --window-icon=mpv \
    --button=gtk-ok \
    --form \
    --field="Audio:CHK")

if [[ $? == 0 ]]; then

    AUDIO=$(echo "$CHOICE" | cut -d "|" -f1)

    if [[ "$AUDIO" == "TRUE" ]]; then
        AUDIO_ARG="--audio"
    fi

    wf-recorder $AUDIO_ARG --file="${SCREENCAST}" &
    RECORDER_PID=$!

    yad --title="Screen Recorder" \
        --text="Stop Recording" \
        --button=gtk-cancel

    kill -INT 888 $RECORDER_PID

    notify-send "Screencast" "${SCREENCAST}"
fi

You also need a launcher icon for the script, so put following into /home/mobian/.local/share/applications/screenrecorder.desktop:

[Desktop Entry] 
Type=Application 
Name=Screenrecorder 
Icon=preferences-desktop-screensaver 
Exec=/home/mobian/bin/screenrecorder.sh 
Terminal=false

Change the path in the Exec= line, if the script has a different location.

1 Like