DEV Community

Cover image for Tomar capturas de pantalla facilmente en i3wm
zJairO
zJairO

Posted on

4 3

Tomar capturas de pantalla facilmente en i3wm

Hola, hoy les quiero compartir un script que uso diariamente para tomar capturas de pantalla en mi arch linux con escritorio i3wm.

Este no es de mi autoría, es de Rui F Ribeiro, usuario de stackexchange, este script funciona con los paquetes xclip e imagemagick, los cuales nos permitirán capturar la pantalla de nuestro escritorio y además poder seleccionar la región que queramos.

Comenzamos instalando los paquetes xclip e imagemagick

sudo pacman -S xclip imagemagick
Enter fullscreen mode Exit fullscreen mode

Crearemos un archivo y añadiremos lo siguiente (puedes usar tu editor favorito ya sea code, vim, etc)

#!/usr/bin/env bash

# screenshots stuff
# TODO: docs

function help_and_exit {
    if [ -n "${1}" ]; then
        echo "${1}"
    fi
    cat <<-EOF
    Usage: scregcp [-h|-s] [<screenshots_base_folder>]

    Take screenshot of a whole screen or a specified region,
    save it to a specified folder (current folder is default)
    and copy it to a clipboard. 

       -h   - print help and exit
       -s   - take a screenshot of a screen region
EOF
    if [ -n "${1}" ]; then
        exit 1
    fi
    exit 0
}

if [ "${1}" == '-h'  ]; then
    help_and_exit
elif [ "${1:0:1}" == '-' ]; then
    if [ "${1}" != '-s' ]; then
        help_and_exit "error: unknown option ${1}"  
    fi
    base_folder="${2}"
else
    base_folder="${1}"
    params="-window root"
fi  

file_path=${base_folder}$( date '+%Y-%m-%d_%H-%M-%S' )_screenshot.png
import ${params} ${file_path}
xclip -selection clipboard -target image/png -i < ${file_path}
Enter fullscreen mode Exit fullscreen mode

Guardamos nuestro archivo como scregcp y le damos permisos de ejecución

chmod +x scregcp
Enter fullscreen mode Exit fullscreen mode

Moveremos nuestro archivo a /usr/bin/

sudo mv scregcp /usr/bin/
Enter fullscreen mode Exit fullscreen mode

Para finalizar editaremos el archivo .config/i3/config para configurar los nuevos shortcuts

bindsym --release Shift+Print exec "scregcp -s $HOME/Pictures/Screenshots/"
bindsym --release Print exec "scregcp $HOME/Pictures/Screenshots/"
Enter fullscreen mode Exit fullscreen mode

Ahora refrescamos la configuración de i3wm y tendremos todo listo, en mi caso las capturas se guardaran en Pictures/Screenshots/ de igual manera se copiaran en nuestro clipboard.

Saludos.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more