You are not logged in.

#1 2017-03-16 02:48:43

dxxvi
Member
Registered: 2011-07-23
Posts: 122

Possible to take a screenshot via ssh?

Hi All,

Is it possible to take a screenshot when somebody is logging in and using openbox (suppose that I have the root access of that machine)?

If it's impossible, is there any way to regularly take screenshots when somebody logs in with user, for example user1, and uses openbox? This is what I tried, but it didn't work correctly: I have something like

( /home/user1/h.sh ) &

in /home/user1/.bashrc. In h.sh, I make an infinite loop of this code:

TITLE=$(xprop -id $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) _NET_WM_NAME)
if [[ $TITLE == *"Minecraft"* ]] || [[ $TITLE == *"Firefox"* ]] || [[ $TITLE == *"Chrome"* ]] ; then
	X=$(date --iso-8601=seconds)
	X=${X:0:19}
	X=${X//:/-}
	gnome-screenshot --remove-border --file=/dev/shm/${X}.png
fi

It seems to work after a reboot and user1 is logged in and openbox is started. But if I ssh using user1, then it doesn't work anymore.
Thanks.

Offline

#2 2017-03-16 02:51:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Possible to take a screenshot via ssh?

Are you using some form of X11 forwarding?  Please describe that if you are.

If you aren't, then I'm missing a big part of your logic: you want screenshots of users1's openbox session, but it doesn work when you shell in.  But when you shell in you are not running a gui let alone openbox.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2017-03-16 03:07:54

dxxvi
Member
Registered: 2011-07-23
Posts: 122

Re: Possible to take a screenshot via ssh?

Trilby wrote:

Are you using some form of X11 forwarding?  Please describe that if you are.

No, I don't use X11 forwarding

Trilby wrote:

If you aren't, then I'm missing a big part of your logic: you want screenshots of users1's openbox session, but it doesn work when you shell in.  But when you shell in you are not running a gui let alone openbox.

Yes, I want screenshots of user1's openbox session. It seems to work if user1 logs in and starts openbox before anybody text-ssh to that machine with the user1 account.
I thought and googled about this for a couple of days but couldn't find the answer. But only 5 minutes after I posted my question here, I googled again and voila, the answer is

gnome-screenshot --display :0.0

Now I'm so happy :-)I was happy too soon.
Now I can shell in and run gnome-screenshot --display :0.0 but my infinite loop stops (still don't know why) after I shell in.

2nd edit: when user1 logs in and starts an openbox session, that infinite loop, which is started in .bashrc in the background, starts. When I shell in using user1 account, that infinite loop stops and a new infinite loop starts and it will stop when I exit this text ssh session. Now my question is: why does a script, which contains an infinite loop, in .bashrc (and is started in the background, i.e.

script-containing-infinite-loop &

) stop when somebody text-ssh in?

Last edited by dxxvi (2017-03-16 03:39:50)

Offline

#4 2017-03-16 05:20:02

HiImTye
Member
From: Halifax, NS, Canada
Registered: 2012-05-09
Posts: 1,072

Re: Possible to take a screenshot via ssh?

you're loading .bashrc again when you ssh in, so that would start a new script (and close it when you logout of ssh). why not just use a user cron job run every minute or however often you want to take a screenshot, instead of an infinite loop?

also, if you're going to be working with a graphical session from a shell, it's better to just export the DISPLAY variable

export DISPLAY=":0"

unless you plan on x forwarding

Last edited by HiImTye (2017-03-16 05:24:16)

Offline

#5 2017-03-16 10:49:14

dxxvi
Member
Registered: 2011-07-23
Posts: 122

Re: Possible to take a screenshot via ssh?

HiImTye wrote:

you're loading .bashrc again when you ssh in, so that would start a new script (and close it when you logout of ssh). why not just use a user cron job run every minute or however often you want to take a screenshot, instead of an infinite loop?

also, if you're going to be working with a graphical session from a shell, it's better to just export the DISPLAY variable

export DISPLAY=":0"

unless you plan on x forwarding

Thank you. I'll try with a cron job.

Offline

Board footer

Powered by FluxBB