Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.
/ grimrec Public archive

😬 Record a window to a GIF, under Sway/Wayland

License

Notifications You must be signed in to change notification settings

xyproto/grimrec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grimrec

Record the focused window to a GIF file, using grim and ImageMagick, under Sway.

This is the "glue and rubberband" way of doing a screeen recording under Sway, but it works.

The code is just 122 lines of Python.

Example recording

triangles

Installation

install -Dm755 grimrec /usr/bin/grimrec
  • Install by using sudo or running as root, if needed.
  • If possible, install with a proper package manager.
  • Install to /usr/local/bin if you have a UNIX beard.

Configuration

Add this to ~/.config/sway/config:

bindsym Ctrl+Shift+F12 exec /usr/bin/grimrec /tmp/output.gif 20 9

This will set up ctrl-shift-f12 as a hotkey to record the currently focused window for 20 seconds, with 9 frames per second, to /tmp/output.gif.

Then reload the configuration in Sway, or restart Sway.

The conversion to GIF may take a couple of seconds after the recording has completed.

If you have mako and notify-send installed, a message can be displayed after the file has been written:

bindsym Ctrl+Shift+F12 exec /usr/bin/grimrec /tmp/output.gif 20 9 && notify-send 'Recording completed'

Features and limitations

  • The FPS is limited by how fast screenshots can be taken of the focused window.
  • 24 frames per second is usually not possible, but it depends on the size of the window and the speed of the computer.
  • The conversion from screenshots to GIF will take a very long time if the focused window is large. Try to keep it as small as possible.
  • Make sure there is enough space in /tmp for what you are trying to capture.

Dependencies

These executables are expected to be found:

  • /usr/bin/convert
  • /usr/bin/env
  • /usr/bin/grep
  • /usr/bin/grim
  • /usr/bin/swaymsg
  • Python 3 in the PATH as python3

Testing

For testing grimrec, before installing, try creating a 1 second recording, with 7 frames per second:

./grimrec a.gif 1 7

It can be viewed with imv:

imv a.gif

General info