GunnarMonell / fbgrab

fbgrab linux framebuffer screenshot utility.
GNU General Public License v2.0
146 stars 28 forks source link

Using option "-c" or "-C" without sudo gives "Couldn't open /dev/console" #13

Open m040601 opened 2 years ago

m040601 commented 2 years ago

First of all just like to thank you for this tool and keeping it maintained, updated and alive. It's so usefull. And it's a rarity these days to find people with interest and working tools (not abandonware) for the linux framebuffer.

I'm on Archlinux.

I use the officially released package for fbgrab, https://archlinux.org/packages/community/x86_64/fbgrab/. Currently is at version 1.5-2. I'm a member of the "wheel" group. So if, and only if, it is needed, I can "sudo someapp". I'm a member of the "video" group.

I dont use a desktop environment. I dont use a window manager. I dont even start X.

I just watch videos, or images or pdfs in separate console (tty) from the one I'm working. I dont need to use sudo. I just type "mpv somevideo.mp4". Example.

All this works perfectly together. I can change back and forth between the different consoles (using Alt and left/right arrow keys) and to my stuff. All the apps running at the same time. And all this time I only see a "/dev/fb0" "special device" on my system. And a "/dev/console"

Now what I want to do ?

I want to take a screenshot, for example of whatever video is running on tty2. Now, and this is important, because there is no concept of "windows", that video fills the entire screen. Of course. So, I cant type in the console, while the video is playing. I have to go to another console to type "fbgrab ..." to make the screenshot.

I must have read and reread this a thousand times, but I still cant get what I want. Maybe I am miss interpreting something here

On the man page,

-c console specifies which console (or virtual terminal - like other people call this feature) to grab. Sometimes this changing is faster then the framebuffer is refreshed (especially when grabbing framebuffer apps). If so, you should use -C console ... This waits some time before grabbing. You can't use -s in this case.

Using "fbgrab -h"

-C n grab from console n, for slower framebuffers -c n grab from console n

I go to tty1. I tried countless variations using both "-c" and "-C" of:

fbgrab -c 2 screenshot.png
fbgrab -c tty2 screenshot.png
fbgrab -c /dev/tty2 screenshot.png

Always get the damned message

Couldn't open /dev/console

So, maybe using sudo ?

sudo fbgrab -c 2 screenshot.png

Ahhh. It works ! But, ... why ? Why do I need to use "sudo" ? I didnt need sudo to start mpv, or a picture viewer etc. All those tty's are already open, belong to me, and have programs running. I also dont need sudo, for example, to go somewhere else, tty6 (ALT-F6), and "chvt 2". That moves me automatically to tty2 where the video is playing

Am I trying something not possible ? Or is this the way it is supposed to work ? Why cant the membership in video group be "enough" for fbgrab ?

After all, if I am at my own tty1, and want a screenshot of tty1, I dont need root.

Why do I need to be root to just make a screenshot in a different tty than the one I'm currently at ?

The only related info I found was this,

This option might require root privileges (or CAP_SYS_TTY_CONFIG capability).

It's on the man page of "fbcat", https://github.com/jwilk/fbcat/blob/master/doc/fbgrab.xml. Which I think is a fork of your fbgrab.

Framebuffer/console/drm/xyz rights, permissions and modern mechanisms might all be "obvious" for a Linux developer. But this is all giberish for us end users. A little bit like rocket science. And nowadays, even we, linux console end users, are a tiny minority of the minority. Very difficult to find updated information on the Internet. Maybe you could add a word or two to the man page or README, helping to better grasp this issue for an end user.

Thanks in advance.

PS1: I should also maybe inform that I have this on "/etc/systemd/journald.conf",

Storage=volatile
ForwardToConsole=yes
TTYPath=/dev/tty13

I have this because I dont need/want systemd filling my systemd with gigabytes of logs. But if I want to watch them "live" I just go to console tty13. By default it is mapped to "AltGr-F1". Very convenient. When the system shuts down, all of those logs stored in RAM vanish of course.

GunnarMonell commented 2 years ago

Hi!

Sorry for not responding earlier - I thought I already had!

I'm not sure why membership in the video group is not sufficient. I did some tinkering to see if there was a way around it, but it appears not. An alternative approach could be to set the setuid bit on fbgrab.

Regards, Gunnar