i3wm Screenshot Shortcuts
Diego Juliao

Diego Juliao @dianjuar

About: FullStack JavaScript Engineer👨‍💻. OSS Contributor. Dog person🐶🐶. Adrenaline Junkie 🚲⛰️🥾🧗. ISTJ/A 🧠

Location:
Medellín, Colombia 🇨🇴
Joined:
Sep 23, 2019

i3wm Screenshot Shortcuts

Publish Date: Mar 26 '22
39 7

Have excellent screenshot shortcuts in your i3wm.

Feature Shortcut
Full Screen PrtScrn
Selection Shift + PrtScrn
Active Window Super + PrtScrn
Clipboard Full Screen Ctrl + PrtScrn
Clipboard Selection Ctrl + Shift + PrtScrn
Clipboard Active Window Ctrl + Super + PrtScrn

All the screenshots are saved on ~/Pictures/CURRENT_DATE.
The key super refers to the modifier key (window/command or alt by default depending on config).

Requirements

  • maim
  • xclip
  • xdotool

Set-up

Set this on your i3 config file ~/.i3/config.

## Screenshots
bindsym Print exec --no-startup-id maim "/home/$USER/Pictures/$(date)"
bindsym $mod+Print exec --no-startup-id maim --window $(xdotool getactivewindow) "/home/$USER/Pictures/$(date)"
bindsym Shift+Print exec --no-startup-id maim --select "/home/$USER/Pictures/$(date)"

## Clipboard Screenshots
bindsym Ctrl+Print exec --no-startup-id maim | xclip -selection clipboard -t image/png
bindsym Ctrl+$mod+Print exec --no-startup-id maim --window $(xdotool getactivewindow) | xclip -selection clipboard -t image/png
bindsym Ctrl+Shift+Print exec --no-startup-id maim --select | xclip -selection clipboard -t image/png
Enter fullscreen mode Exit fullscreen mode

You may want to remove the default or any other screenshot shortcuts to prevent errors.
Don't forget to reload your window manager super+ shift+ c.


The source of this information is from my gist My i3 shortcuts to take screenshots.

Comments 7 total

  • Crosson David
    Crosson DavidSep 14, 2022

    thanks for sharing :)

  • Crosson David
    Crosson DavidSep 14, 2022

    I made some changes, and I had to provide explicitly the format to use in order for the clipboard cases to work.

    # For screenshots install :
    # apt-get install maim xclip copyq
    
    ##  Screenshots in files
    bindsym Print exec --no-startup-id maim --format=png "/home/$USER/Pictures/screenshot-$(date -u +'%Y%m%d-%H%M%SZ')-all.png"
    bindsym $mod+Print exec --no-startup-id maim --format=png --window $(xdotool getactivewindow) "/home/$USER/Pictures/screenshot-$(date -u +'%Y%m%d-%H%M%SZ')-current.png"
    bindsym Shift+Print exec --no-startup-id maim --format=png --select "/home/$USER/Pictures/screenshot-$(date -u +'%Y%m%d-%H%M%SZ')-selected.png"
    
    ## Screenshots in clipboards
    bindsym Ctrl+Print exec --no-startup-id maim --format=png | xclip -selection clipboard -t image/png
    bindsym Ctrl+$mod+Print exec --no-startup-id maim --format=png --window $(xdotool getactivewindow) | xclip -selection clipboard -t image/png
    bindsym Ctrl+Shift+Print exec --no-startup-id maim --format=png --select | xclip -selection clipboard -t image/png
    
    
    
    Enter fullscreen mode Exit fullscreen mode
  • Yuhang "Eric" Wei
    Yuhang "Eric" WeiJan 23, 2023

    Thanks for sharing! I would like to add

    apt install xdotool 
    
    Enter fullscreen mode Exit fullscreen mode

    for your script to work.

  • the hengker
    the hengkerJan 7, 2024

    thank you alot, this work for me too. you save my pain brooooo

  • Artemis
    ArtemisFeb 13, 2024

    Hello, thanks for the script ! Really useful
    However I like to have my screenshots both saved to a specific directory and copied to clipboard, it seems it's one or the other, is there a way to do both ?
    Thanks !

    • Diego Juliao
      Diego JuliaoFeb 27, 2024

      The key bindings are designed to have both.
      When you use the Ctrl key, it will store your screenshot on your clipboard.

  • Victor Licht
    Victor LichtMar 21, 2024

    Thanks for that

Add comment