Skip to main content
The script also saves the $file in the clipboard.
Source Link

This is the perl6 script I use to taketakes root, area, window, or delay ScreenShots using import: and saves them in a $file and in the clipboard.

#!/usr/bin/env perl6 use v6; sub print_window(Str $file) { qx{xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"} ~~ /(0x\S*)/; run <import -window>, $0, $file; } sub MAIN( Str $option where $option ∈ <root area window delay> ) { my $today = DateTime.now( formatter =>    formatter => { sprintf "%04d_%02d_%02d_%02d:%02d:%02d",   sprintf "%04d_%02d_%02d_%02d-%02d-%02d", .year, .month, .day, .hour, .minute, .second   } ); my $file = "$*HOME/Dades/Imatges/ScreenShots/$today.png"; given $option { when 'root' { run <import -window root>, $file } when 'area' { run 'import', $file } when 'window' { print_window($file) } when 'delay' { sleep 10; print_window($file) } } run <xclip -selection clipboard -target image/png -i>, $file; run <xmessage -nearmouse -timeout 3>, "Screenshot in clipboard, and saved in $file";$today.png"; } 

These are the key bindings in i3 to run the script:

bindsym $mod+Print exec Print_Screen root bindsym --release $mod+Shift+Print exec Print_Screen area bindsym $mod+Mod1+Print exec Print_Screen delay bindsym $mod+Control+Print exec Print_Screen window 

This is the perl6 script I use to take root, area, window, or delay ScreenShots using import:

#!/usr/bin/env perl6 use v6; sub print_window(Str $file) { qx{xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"} ~~ /(0x\S*)/; run <import -window>, $0, $file; } sub MAIN( Str $option where $option ∈ <root area window delay> ) { my $today = DateTime.now( formatter =>    { sprintf "%04d_%02d_%02d_%02d:%02d:%02d",   .year, .month, .day, .hour, .minute, .second   } ); my $file = "$*HOME/Dades/Imatges/ScreenShots/$today.png"; given $option { when 'root' { run <import -window root>, $file } when 'area' { run 'import', $file } when 'window' { print_window($file) } when 'delay' { sleep 10; print_window($file) } } run <xmessage -nearmouse -timeout 3>, "Screenshot saved in $file"; } 

These are the key bindings in i3 to run the script:

bindsym $mod+Print exec Print_Screen root bindsym --release $mod+Shift+Print exec Print_Screen area bindsym $mod+Mod1+Print exec Print_Screen delay bindsym $mod+Control+Print exec Print_Screen window 

This perl6 script takes root, area, window, or delay ScreenShots using import and saves them in a $file and in the clipboard.

#!/usr/bin/env perl6 use v6; sub print_window(Str $file) { qx{xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"} ~~ /(0x\S*)/; run <import -window>, $0, $file; } sub MAIN( Str $option where $option ∈ <root area window delay> ) { my $today = DateTime.now( formatter => { sprintf "%04d_%02d_%02d_%02d-%02d-%02d", .year, .month, .day, .hour, .minute, .second } ); my $file = "$*HOME/Dades/Imatges/ScreenShots/$today.png"; given $option { when 'root' { run <import -window root>, $file } when 'area' { run 'import', $file } when 'window' { print_window($file) } when 'delay' { sleep 10; print_window($file) } } run <xclip -selection clipboard -target image/png -i>, $file; run <xmessage -nearmouse -timeout 3>, "Screenshot in clipboard, and saved in $today.png"; } 

These are the key bindings in i3 to run the script:

bindsym $mod+Print exec Print_Screen root bindsym --release $mod+Shift+Print exec Print_Screen area bindsym $mod+Mod1+Print exec Print_Screen delay bindsym $mod+Control+Print exec Print_Screen window 
Improved script.
Source Link

This is the perl6 script I use to take root, area, window, or delay ScreenShots using import:

#!/usr/bin/env perl6 use v6; sub message(Str $file) { run <xmessage -nearmouse -timeout 3>, "Screenshot saved in $file"; } sub print_window(Str $file) { qx{xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"} ~~ /(0x\d*0x\S*).*$/; run <import -window>, $0, $file; message($file); } sub MAIN( Str $option where $option ∈ <root area window delay> ) { my $today = DateTime.now( formatter => { { sprintf "%04d_%02d_%02d_%02d:%02d:%02d",   .year, .month, .day, .hour, .minute, .second }  ); my $file = "$*HOME/Dades/Imatges/ScreenShots/$today.png"; given $option { when 'root' { run <import -window root>, $file; message($file) } when 'area' { run "import"'import', $file  ; message($file) } when 'window' { print_window($file)  } when 'delay' { sleep 5;10; print_window($file)  }  default  { say 'Something went wrong' ; exit }  run <xmessage -nearmouse -timeout 3>, "Screenshot } saved in }$file"; } 

These are the key bindings in i3 to run the script:

bindsym $mod+Print exec Print_Screen root bindsym --release $mod+Shift+Print exec Print_Screen area bindsym $mod+Mod1+Print exec Print_Screen delay bindsym $mod+Control+Print exec Print_Screen window 

This is the perl6 script I use to take root area window or delay ScreenShots using import:

#!/usr/bin/env perl6 use v6; sub message(Str $file) { run <xmessage -nearmouse -timeout 3>, "Screenshot saved in $file"; } sub print_window(Str $file) { qx{xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"} ~~ /(0x\d*).*$/; run <import -window>, $0, $file; message($file); } sub MAIN( Str $option where $option ∈ <root area window delay> ) { my $today = DateTime.now( formatter => { sprintf "%04d_%02d_%02d_%02d:%02d:%02d",   .year, .month, .day, .hour, .minute, .second } ); my $file = "$*HOME/Dades/Imatges/ScreenShots/$today.png"; given $option { when 'root' { run <import -window root>, $file; message($file) } when 'area' { run "import", $file  ; message($file) } when 'window' { print_window($file)  } when 'delay' { sleep 5; print_window($file)  }  default  { say 'Something went wrong' ; exit  }  } } 

These are the key bindings in i3 to run the script:

bindsym $mod+Print exec Print_Screen root bindsym --release $mod+Shift+Print exec Print_Screen area bindsym $mod+Mod1+Print exec Print_Screen delay bindsym $mod+Control+Print exec Print_Screen window 

This is the perl6 script I use to take root, area, window, or delay ScreenShots using import:

#!/usr/bin/env perl6 use v6; sub print_window(Str $file) { qx{xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"} ~~ /(0x\S*)/; run <import -window>, $0, $file; } sub MAIN( Str $option where $option ∈ <root area window delay> ) { my $today = DateTime.now( formatter => { sprintf "%04d_%02d_%02d_%02d:%02d:%02d", .year, .month, .day, .hour, .minute, .second }  ); my $file = "$*HOME/Dades/Imatges/ScreenShots/$today.png"; given $option { when 'root' { run <import -window root>, $file } when 'area' { run 'import', $file } when 'window' { print_window($file) } when 'delay' { sleep 10; print_window($file) } }  run <xmessage -nearmouse -timeout 3>, "Screenshot saved in $file"; } 

These are the key bindings in i3 to run the script:

bindsym $mod+Print exec Print_Screen root bindsym --release $mod+Shift+Print exec Print_Screen area bindsym $mod+Mod1+Print exec Print_Screen delay bindsym $mod+Control+Print exec Print_Screen window 
correct typo
Source Link

This is the perl6 script I use to take root area window or delay ScreenShots using import:

#!/usr/bin/env perl6 use v6; sub message(Str $file) { run <xmessage -nearmouse -timeout 3>, "Screenshot saved in $file">;$file"; } sub print_window(Str $file) { qx{xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"} ~~ /(0x\d*).*$/; run <import -window>, $0, $file; message($file); } sub MAIN( Str $option where $option ∈ <root area window delay> ) { my $today = DateTime.now( formatter => { sprintf "%04d_%02d_%02d_%02d:%02d:%02d", .year, .month, .day, .hour, .minute, .second } ); my $file = "$*HOME/Dades/Imatges/ScreenShots/$today.png"; given $option { when 'root' { run <import -window root>, $file; message($file) } when 'area' { run "import", $file ; message($file) } when 'window' { print_window($file) } when 'delay' { sleep 5; print_window($file) } default { say 'Something went wrong' ; exit } } } 

These are the key bindings in i3 to run the script:

bindsym $mod+Print exec Print_Screen root bindsym --release $mod+Shift+Print exec Print_Screen area bindsym $mod+Mod1+Print exec Print_Screen delay bindsym $mod+Control+Print exec Print_Screen window 

This is the perl6 script I use to take root area window or delay ScreenShots using import:

#!/usr/bin/env perl6 use v6; sub message(Str $file) { run <xmessage -nearmouse -timeout 3>, "Screenshot saved in $file">; } sub print_window(Str $file) { qx{xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"} ~~ /(0x\d*).*$/; run <import -window>, $0, $file; message($file); } sub MAIN( Str $option where $option ∈ <root area window delay> ) { my $today = DateTime.now( formatter => { sprintf "%04d_%02d_%02d_%02d:%02d:%02d", .year, .month, .day, .hour, .minute, .second } ); my $file = "$*HOME/Dades/Imatges/ScreenShots/$today.png"; given $option { when 'root' { run <import -window root>, $file; message($file) } when 'area' { run "import", $file ; message($file) } when 'window' { print_window($file) } when 'delay' { sleep 5; print_window($file) } default { say 'Something went wrong' ; exit } } } 

These are the key bindings in i3 to run the script:

bindsym $mod+Print exec Print_Screen root bindsym --release $mod+Shift+Print exec Print_Screen area bindsym $mod+Mod1+Print exec Print_Screen delay bindsym $mod+Control+Print exec Print_Screen window 

This is the perl6 script I use to take root area window or delay ScreenShots using import:

#!/usr/bin/env perl6 use v6; sub message(Str $file) { run <xmessage -nearmouse -timeout 3>, "Screenshot saved in $file"; } sub print_window(Str $file) { qx{xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"} ~~ /(0x\d*).*$/; run <import -window>, $0, $file; message($file); } sub MAIN( Str $option where $option ∈ <root area window delay> ) { my $today = DateTime.now( formatter => { sprintf "%04d_%02d_%02d_%02d:%02d:%02d", .year, .month, .day, .hour, .minute, .second } ); my $file = "$*HOME/Dades/Imatges/ScreenShots/$today.png"; given $option { when 'root' { run <import -window root>, $file; message($file) } when 'area' { run "import", $file ; message($file) } when 'window' { print_window($file) } when 'delay' { sleep 5; print_window($file) } default { say 'Something went wrong' ; exit } } } 

These are the key bindings in i3 to run the script:

bindsym $mod+Print exec Print_Screen root bindsym --release $mod+Shift+Print exec Print_Screen area bindsym $mod+Mod1+Print exec Print_Screen delay bindsym $mod+Control+Print exec Print_Screen window 
Source Link
Loading