Coder Social home page Coder Social logo

xyproto / grimrec Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 1.0 334 KB

:grimacing: Record a window to a GIF, under Sway/Wayland

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%
screen-recorder sway wayland grim imagemagick python archlinux linux screenshot

grimrec's Introduction

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

grimrec's People

Contributors

x1a0 avatar xyproto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

x1a0

grimrec's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.