Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dianjuar
Last active April 11, 2024 21:55
Show Gist options
  • Save dianjuar/ee774561a8bc02b077989bc17424a19f to your computer and use it in GitHub Desktop.
Save dianjuar/ee774561a8bc02b077989bc17424a19f to your computer and use it in GitHub Desktop.
My i3 shortcuts to take screenshots

Requirements

  • maim
  • xclip

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

You may remove the default screenshot shortcuts to prevent error

What it does

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 screen shots are saved on ~/Pictures/CURRENT_DATE

super key is the windows key

@pavelmetalarm
Copy link

Brilliance, dude

@MaciejWieczor
Copy link

Thank you, very cool

@mhalano
Copy link

mhalano commented Aug 8, 2021

Very good. I just changed the generated file names to mimic the ones produced by the gnome-screenshot command.

@MagnesiaReal
Copy link

MagnesiaReal commented Sep 27, 2021

Simple and the best configuration, thanks.

@antonixmed
Copy link

thanks broooooooooooooooooooooo

@jokerekv2
Copy link

I was looking for exactly that!

@HarshalRathore
Copy link

Thanks Good Sir for this code :)

@VenerableCrow
Copy link

Finally, something that works. Thank you.

@OsmanBytyqi
Copy link

Simple and fast, thx :- )

@kolxz2
Copy link

kolxz2 commented Feb 5, 2022

Thank you. Very good

@Khalmeera
Copy link

EXACTLY what I needed, I love you.

@Tmodrzyk
Copy link

Thank you for this ! Quick and easy, just as I need :)

@MarcoCenturion
Copy link

Great job, thanks! it works perfect!

@dianjuar
Copy link
Author

I post this information in an article, i3wm-screenshot-shortcuts

@Noapoleon
Copy link

Hey it normal screenshots (not the clipboard ones) don't seem to be working for me.
Or at least they don't properly save to /home/$USER/Pictures/, it just doesn't create the file.
I was wondering if there was something wrong with the variables so I replaced them with a normal path without variables, eg: /home/noa/Pictures/test1
but it still didn't create single screenshot file

@nachiketkanore
Copy link

Awesome! Thanks a lot for the configs!

@JourneyToSilius
Copy link

when I change my hard drive for a new one, I always forget to copy my I3 config .. this is the kind of thing that I love about Github. thanks

@osxxii
Copy link

osxxii commented May 15, 2022

Thank you so much!!! Helped alot :-)

@aloisdg
Copy link

aloisdg commented May 18, 2022

Thank you :)

@yebt
Copy link

yebt commented May 20, 2022

Nice bro, thanks

@ValeriyDP
Copy link

Hey it normal screenshots (not the clipboard ones) don't seem to be working for me. Or at least they don't properly save to /home/$USER/Pictures/, it just doesn't create the file. I was wondering if there was something wrong with the variables so I replaced them with a normal path without variables, eg: /home/noa/Pictures/test1 but it still didn't create single screenshot file

the same issue...
I'm using ubuntu

@Flo-Slv
Copy link

Flo-Slv commented Aug 5, 2022

Hey it normal screenshots (not the clipboard ones) don't seem to be working for me. Or at least they don't properly save to /home/$USER/Pictures/, it just doesn't create the file. I was wondering if there was something wrong with the variables so I replaced them with a normal path without variables, eg: /home/noa/Pictures/test1 but it still didn't create single screenshot file

the same issue... I'm using ubuntu

Seems not working with Ubuntu 22.04 for me too

@mangelozzi
Copy link

mangelozzi commented Aug 7, 2022

I think this is a better file name (with extension and ordered dates):
exec --no-startup-id maim "/$HOME/Pictures/screenshot_$(date +'%Y-%m-%d_%H:%M:%S').png"

EDIT: @eivindbergem thanks for the $HOME tip

@eivindbergem
Copy link

The home directory might not be /home/$USER. It's better to use $HOME.

@PaulJ505
Copy link

It's great. Thank you.

@mdxaasil
Copy link

mdxaasil commented Jun 3, 2023

Super thanks bro!

@Zaahed
Copy link

Zaahed commented Aug 31, 2023

Thanks!

@gitTov
Copy link

gitTov commented Nov 1, 2023

Ubuntu 22.04

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

The above line was causing a duplication error, although that didn't seem obvious at first. Changing $mod to Mod1 dealt with the error, however the command does not capture the active window. I can live it with it for now, as I really just wanted the select feature. So if anything, this comment is more of just a "fyi".

@PryPii
Copy link

PryPii commented Nov 16, 2023

Thanks bro

@shukurillo0516
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment