# How does one make console screenshots?



## fonz (Feb 1, 2013)

As the title suggests, I'm wondering how one can make screenshots of the console. I have of course searched the Forums and also "DuckDuckWent", but didn't find anything. As an example, the screenshots in the installation chapters of the Handbook look quite nice. Does anyone know how those were made?


----------



## pbd (Feb 1, 2013)

One option is to take screenshots of a console of a _virtual machine_.


----------



## wblock@ (Feb 1, 2013)

pbd said:
			
		

> One option is to take screenshots of a console of a _virtual machine_.



That works and the fonts look nice.  It's what I did for the screenshots in the bsdinstall(8) Handbook chapter.

The old way on a real console was using vidcontrol(1) -p and then convert the output.


----------



## fonz (Feb 1, 2013)

wblock@ said:
			
		

> That works and the fonts look nice.  It's what I did for the screenshots in the bsdinstall(8) Handbook chapter.
> 
> The old way on a real console was using vidcontrol(1) -p and then convert the output.


Converting vidcontrol(1) output into an image (e.g. GIF or JPEG) looks rather labour intensive, so I'll go with the VM approach. Thanks to both of you.


----------



## wblock@ (Feb 1, 2013)

graphics/scr2png is just one step, not bad.  Using GIMP to capture the VM window is easy.  Trimming off the VM menu bar is a little work, but could be scripted in GIMP or with graphics/ImageMagick's convert(1).


----------



## Amzo (Feb 1, 2013)

xfce4-screenshooter in the ports allows you to select which regions of the screen you'd like to take a screenshot of.


----------



## Beastie (Feb 1, 2013)

wblock@ said:
			
		

> Using GIMP to capture the VM window is easy.  Trimming off the VM menu bar is a little work, but could be scripted in GIMP or with graphics/ImageMagick's convert(1).


Well, since you already have graphics/ImageMagick, you might want to use import(), e.g.
`% import -window 0xc00398 test.png`

EDIT: To get the window's id you can use your WM if it has such feature or Xorg's x11/xwininfo.


----------



## fonz (Feb 1, 2013)

wblock@ said:
			
		

> graphics/scr2png is just one step, not bad.


Obviously, being way more aware of all the stuff that's in the ports tree than I am helps  I'll give it a try and see whether the result looks any good.



			
				wblock@ said:
			
		

> Using GIMP to capture the VM window is easy. Trimming off the VM menu bar is a little work


I usually use graphics/xv for screenshots. I know it's (very) old but it's much faster and isn't tied to a whole lot of runtime libraries either. However, since I'm going to have to get rid of the VM menu, I'll be using (The) GIMP anyway so I might just as well use the latter for capturing too, this time.


----------



## wblock@ (Feb 1, 2013)

If you do script trimming that window through GIMP, please post it.  GIMP scripting is something that could be useful but I have never tried.


----------



## Presence (Feb 1, 2013)

If you are using VirtualBox, you can simply press Host Key+E to take a screenshot.


----------



## AllanTheBrummie (Mar 16, 2022)

Apologies for resurrecting a _very _old thread, but the suggested solution above is not available to me and I'm wondering if anything has changed in the last 9 years to address this issue... Like fonz above, I too have searched the forums, but to no avail...
I'm doing a FreeBSD install on a single 4TB HDD and want to use ZFS (if only for the experience!)  I want to set up a non-standard partitioning scheme and I'd like to document it reasonably neatly especially as I'm relatively new to ZFS.  I would therefore like to take screenshots at each command.  Clearly at this point in the installation FreeBSD itself has not yet been installed...so none of the packages which I might normally expect exist yet.  So, is there any way I can modify the installation USB to include access to any keyboard-shortcut screen-grabs which would have to be loaded before disk setup takes place?  I had already considered the VM approach, but I don't have access to any system which would allow me to create a 4TB VM, though I guess I could use it to demonstrate the principle... but I'd rather document the actual process to avoid any errors! 

Otherwise, I'm down to taking photographs!

Regards, Allan.


----------



## scottro (Mar 16, 2022)

I see that I use to do (but haven't tested in years) opening another terminal, for example, using alt+F3, I would then use

```
vidcontrol -p < /dev/ttyv0 > shot1.scr
```
Then, using scr2png I would convert the scr to a png image. (It might also work with ImageMagick's convert but I've not tried that)

I would do that on the machine I was using for install, at least the vidcontrol < /dev/ttyv0 > shot1.scr.

Then, after installation, I would just scp the scr's over to another machine and do the scr2png there. Of course, you could also install scr2png on the machine you're installing, once finished with the install, and do the work on that machine.


----------



## grahamperrin@ (Mar 16, 2022)

AllanTheBrummie said:


> … document it reasonably neatly …



If you'll type carefully, then you might like script(1).

I rarely use it, because I find it hard to resist habits such as arrow keys, and so on, which can have weird representations in the resulting transcript. Somewhere in FreeBSD Forums there might be advice on how to minimise the weirdness.


----------



## schweikh (Mar 16, 2022)

If you want pictures of "libdialog" screens, such as from bsdinstall(8), and you can run them in an xterm, then there are the quite nifty Main Options "XHTML Screen Dump" and "SVG Screen Dump".
If xterm does not show the toolbar, open the "Main Options" menu with CTRL-Leftclick. Images are saved in your home directory with date and time in the file name. Should these options not exist, your xterm was not compiled with option SCRNDUMP enabled.
Both formats allow for vector fonts and you can get superb quality images. Open an SVG for example with Firefox and make it as big as you like. You can even change the fonts *after* making the screenshots by editing the XHTML or SVG.






(This is an SVG, opened in Firefox, then screengrabbed with xv and saved as PNG, since the forum does not accept SVG).

I wish my 1987's amber monochrome monitor would have been this capable


----------



## grahamperrin@ (Mar 16, 2022)

schweikh welcome to FreeBSD Forums. 

Please, is what you describe possible in a _console_ (with neither a window manager nor a desktop environment)?


----------



## covacat (Mar 17, 2022)

go to /usr/ports/sysutils/tmux
CFLAGS=-static make
copy /usr/ports/sysutils/tmux/work/stage/usr/local/bin/tmux to the install media
edit install media's /etc/rc.local to run bsdinstall within tmux
use capture-pane -e  and save-buffer to save the screen to a file that you can cat after in an xterm / ssh session an take a screen shot








						Capture colors with tmux buffer copy (hardcopy)
					

I am using the following line in tmux for getting a "hardcopy" feature like in GNU Screen:  bind H capture-pane \; save-buffer -b 0 ~/tmux.hardcopy \; delete-buffer -b 0 However, the ANSI colors a...




					unix.stackexchange.com
				











						How to execute code in a new tmux session - from within current session?
					

I use Ubuntu 16.04 and I need the following tmux solution because I want to run a timeout process with sleep as in my particular case I wasn't satisfied from at and encountered a bug with nohup (when




					unix.stackexchange.com


----------



## covacat (Mar 17, 2022)

or if you have the possibility use serial console


----------



## Profighost (Mar 17, 2022)

Under X (Desktop/Gnome/Xfce/fvwm...) I use xwd 
You may program a button to activate it by keystrike.
If you are under a virtual terminal (text only) I don't can figure out, why to make real screenshot there. and frankly I don't know how it can be done, since you may redirect the output into a textfile such as 
	
	



```
# ll > directory.txt
```


----------



## schweikh (Mar 17, 2022)

grahamperrin said:


> schweikh welcome to FreeBSD Forums.
> 
> Please, is what you describe possible in a _console_ (with neither a window manager nor a desktop environment)?


No. That's why I have qualified and introduced my answer with "if [...] and you can run them in an xterm".
I have often found the need to make high quality vectorized (scalable) screenshots of terminal screens for books. Any pixel image based solution just does not cut it and there are ways around it.
Hence my attempt to provide an alternative for use cases that can relax the "FreeBSD Console" requirement of yours a bit.

On a theoretical note, vt has undergone some refinement in the past (e.g. it maskerades as an xterm, since it uses TERM=xterm). It does not implement many of the xterm control sequences right now. But it is entirely possible to teach it to produce an SVG screen dump upon request, say, hitting the Print Screen key. That could be a Summer of Code project one fine day


----------



## AllanTheBrummie (Mar 17, 2022)

scottro said:


> I see that I use to do (but haven't tested in years) opening another terminal, for example, using alt+F3, I would then use
> 
> ```
> vidcontrol -p < /dev/ttyv0 > shot1.scr
> ...


Thanks scottro, that looks like exactly what I need, provided that Alt-F3 works when booting from a freeBSD installation memory stick...  My understanding (?!) is that the stick it boots a copy of freeBSD itself before showing the installation options screens, but I imagined it to be severely chopped down to offer just the minimum needed to do the installation... I'll try it tonight if I can, and let you all know how I get on...  Allan.


----------



## AllanTheBrummie (Mar 17, 2022)

schweikh said:


> No. That's why I have qualified and introduced my answer with "if [...] and you can run them in an xterm".
> I have often found the need to make high quality vectorized (scalable) screenshots of terminal screens for books. Any pixel image based solution just does not cut it and there are ways around it.
> Hence my attempt to provide an alternative for use cases that can relax the "FreeBSD Console" requirement of yours a bit.
> 
> On a theoretical note, vt has undergone some refinement in the past (e.g. it maskerades as an xterm, since it uses TERM=xterm). It does not implement many of the xterm control sequences right now. But it is entirely possible to teach it to produce an SVG screen dump upon request, say, hitting the Print Screen key. That could be a Summer of Code project one fine day


Thanks for the contribution schweikh.... I'm guessing that there is no way to run the console shown by the installation memory stick as an xterm.  But I could very well be wrong!

Allan


----------



## AllanTheBrummie (Mar 17, 2022)

covacat said:


> or if you have the possibility use serial console


Thanks covacat, it might be possible to configure the installer memory stick to switch IO to a serial port, its an interesting idea.  Then I could kermit to it from a  windows PC just like in the olden days.  Come to think of it though my freeBSD box does not possess any serial ports I don't think...    I could buy a card I guess!

Thanks very much for replying though it could well help other people if not me on this occasion...

Allan


----------



## AllanTheBrummie (Mar 17, 2022)

covacat said:


> go to /usr/ports/sysutils/tmux
> CFLAGS=-static make
> copy /usr/ports/sysutils/tmux/work/stage/usr/local/bin/tmux to the install media
> edit install media's /etc/rc.local to run bsdinstall within tmux
> ...


----------



## SirDice (Mar 17, 2022)

Does the server have IPMI? Modern IPMI console access has a record/screenshot option. If it hasn't you could still make a screenshot of the console window. It's going to be a bitmapped screenshot but you can probably convert those to SVG using ImageMagick.


----------



## AllanTheBrummie (Mar 17, 2022)

covacat said:


> or if you have the possibility use serial console


Thanks covacat, it might be possible to configure the installer memory stick to switch IO to a serial port, its an interesting idea.  Then I could kermit to it from a  windows PC just like in the olden days.  Come to think of it though my freeBSD box does not possess any serial ports I don't think...    I could buy a card I guess!

Thanks very much for replying though it could well help other people if not me on this occasion


covacat said:


> go to /usr/ports/sysutils/tmux
> CFLAGS=-static make
> copy /usr/ports/sysutils/tmux/work/stage/usr/local/bin/tmux to the install media
> edit install media's /etc/rc.local to run bsdinstall within tmux
> ...



...Ah, now this idea sounds more appropriate in my case.   I wondered whether I could modify the usb install stick without breaking it and this seems to suggest I can!  If there is enough room left on the USB anyway...  Thanks again!

Allan


----------



## AllanTheBrummie (Mar 17, 2022)

SirDice said:


> Does the server have IPMI? Modern IPMI console access has a record/screenshot option. If it hasn't you could still make a screenshot of the console window. It's going to be a bitmapped screenshot but you can probably convert those to SVG using ImageMagick.



Thanks SirDice... Lovely idea but this is a low budget minimum hardware project.... I'm using a gaming motherboard/AMD 2500 cpu/lto7 drive to assemble a backup machine for all my other kit...


----------



## grahamperrin@ (Mar 18, 2022)

scottro said:


> I see that I use to do (but haven't tested in years) opening another terminal, for example, using alt+F3, I would then use
> 
> `vidcontrol -p < /dev/ttyv0 > shot1.scr`
> …



_Inappropriate ioctl for device_ – am I missing something?


```
root@mowa219-gjp4-8570p-freebsd:~ # cat typescript
Script started on Fri Mar 18 15:52:43 2022
root@mowa219-gjp4-8570p-freebsd:~ # vidcontrol -p < /dev/ttyv0 > shot.scr
0H7I7F0Gvidcontrol: dumping screen: Inappropriate ioctl for device
root@mowa219-gjp4-8570p-freebsd:~ # exit
exit

Script done on Fri Mar 18 15:53:03 2022
root@mowa219-gjp4-8570p-freebsd:~ #
```


----------



## blind0ne (Mar 18, 2022)

Try camera or capture card.


----------



## ralphbsz (Mar 18, 2022)

grahamperrin said:


> _Inappropriate ioctl for device_ – am I missing something?


In a nutshell, your console driver (vt or sc a.k.a. syscons) does not support the CONS_SCRSHOT ioctl. The error message "inappropriate ioctl" (which used to be called "not a typewriter" and still has the error code ENOTTY) simply means that a device has no entry for a handler function in the table of ioctls. It happens for example if you send the ioctl for "eject page" to a disk drive, or the ioctl for "turn caps lock light on" to a printer.

Now, which console driver are you running? Does it always, sometimes, or never support taking screenshots? If it is "sometimes", what do you need to do to make it happen? This is where a half hour long trip into the source code is probably required. But as a first attempt: You can switch between the vt and sc drivers (in the loader config), try that. It might have other side-effects that are much worse than not getting screen shots.


----------



## scottro (Mar 18, 2022)

Possibly useful to mention that when I did this, it was on DragonFlyBSD and done around 2005 or so. Found this by checking my old notes, which I hadn't done previously.


----------



## astyle (Mar 18, 2022)

schweikh said:


> Should these options not exist, your xterm was not compiled with option SCRNDUMP enabled


This is one reason why I compile ports instead of using pkg. Oh, and if you use a VM, on your personal machine, the host should offer screenshot capabilities. Heck, if you SSH in, you can just take a dump of your PowerShell window


----------



## mark_j (Mar 18, 2022)

Use `screen` then do a hardcopy? Couldn't be easier (or messier if there's a ton of ANSI )


----------



## hardworkingnewbie (Mar 18, 2022)

Use textproc/py-asciinema. This is an ASCII screen recorder. 

When you need a screenshot: playback your recording, pause it where necessary and make a copy. Bam, job done.






						asciinema - Record and share your terminal sessions, the simple way
					






					asciinema.org


----------



## jb_fvwm2 (Mar 18, 2022)

ralphbsz said:


> In a nutshell, your console driver (vt or sc a.k.a. syscons) does not support the CONS_SCRSHOT ioctl. The error message "inappropriate ioctl" (which used to be called "not a typewriter" and still has the error code ENOTTY) simply means that a device has no entry for a handler function in the table of ioctls. It happens for example if you send the ioctl for "eject page" to a disk drive, or the ioctl for "turn caps lock light on" to a printer.
> 
> Now, which console driver are you running? Does it always, sometimes, or never support taking screenshots? If it is "sometimes", what do you need to do to make it happen? This is where a half hour long trip into the source code is probably required. But as a first attempt: You can switch between the vt and sc drivers (in the loader config), try that. It might have other side-effects that are much worse than not getting screen shots.


Just learned about "ioctl". Having received that error message many times with trying to fix wifi drivers, and probably elsewhere, I think it would be useful for the message to also print which ioctl was requested and what device lacked it within its table.


----------



## astyle (Mar 18, 2022)

hardworkingnewbie said:


> Use textproc/py-asciinema. This is an ASCII screen recorder.
> 
> When you need a screenshot: playback your recording, pause it where necessary and make a copy. Bam, job done.
> 
> ...


sounds like a pain in the ass to deal with  Just try pronouncing it yourself.


----------



## grahamperrin@ (Mar 19, 2022)

ralphbsz said:


> … as a first attempt: You can switch between the vt and sc drivers (in the loader config), try that. It might have other side-effects that are much worse …



`sc` was certainly a problem when I tried it with an HP ZBook 17 G2 in July March 2021. I kept a comment in the file:


```
% grep -B 4 -A 1 kern.vty /boot/loader.conf

# <https://old.reddit.com/r/freebsd/comments/m4w2fs/-/gr1c3ba/>
# <https://lists.freebsd.org/archives/freebsd-current/2021-July/000402.html>
# sc is no good with n248269-941650aae97 on an HP ZBook 17 G2
# kern.vty="sc"

%
```

_Probably_ with the NVIDIA GPU alone at the time.


----------



## grahamperrin@ (Mar 20, 2022)

As I suspected, `kern.vty="sc"` also causes a blackout with AMD Thames [Radeon HD 7550M/7570M/7650M] in an HP EliteBook 8570p. 

I'm not concerned. For me it's easier to use VirtualBox, or a camera.


----------

