Butcher maim script
This commit is contained in:
parent
c5f57dc4c5
commit
1ac63ac180
70
src/bin/butcher
Executable file
70
src/bin/butcher
Executable file
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env nu
|
||||
# Copyright 2025 Marty Sluijtman <marty.wanderer@disroot.org>
|
||||
# Distributed under the terms of the GPLv3 license
|
||||
|
||||
let savedir = match ($env.SCROTDIR | is-empty) {
|
||||
true => $"($env.HOME)/Pictures/Screenshots"
|
||||
false => $env.SCROTDIR
|
||||
}
|
||||
|
||||
let date = ^date -Iseconds
|
||||
let filename = $"($savedir)/($date)_screenshot.png"
|
||||
|
||||
def notify [message: string] {
|
||||
^notify-send "Butcher" $message
|
||||
}
|
||||
|
||||
def clipboard [] {
|
||||
$in | ^pngquant - | ^xclip -sel clip -t image/png
|
||||
}
|
||||
|
||||
def main [--clipboard (-c)] {
|
||||
let scrot = ^maim -ui root | complete
|
||||
match $clipboard {
|
||||
true => {
|
||||
$scrot.stdout | clipboard
|
||||
notify "Shot entire screen and tossed the output to the clipboard"
|
||||
}
|
||||
false => {
|
||||
$scrot.stdout | save $filename
|
||||
notify $"Shot entire screen and saved the result to:\n($filename)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def "main window" [--clipboard (-c)] {
|
||||
let window = ^xdotool getactivewindow
|
||||
let scrot = ^maim -ui $window | complet
|
||||
match $clipboard {
|
||||
true => {
|
||||
$scrot.stdout | clipboad
|
||||
notify $"Took screenshot of focussed window and tossed it to clipboard"
|
||||
}
|
||||
false => {
|
||||
$scrot.stdout | save $filename
|
||||
notify $"Saved screenshot of focussed window and save it to:\n($filename)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def "main selection" [--clipboard(-c)] {
|
||||
let scrot = ^maim -su | complete
|
||||
match $scrot.exit_code {
|
||||
0 => {
|
||||
match $clipboard {
|
||||
true => {
|
||||
$scrot.stdout | clipboard
|
||||
notify "Took screenshot and tossed it to clipboard"
|
||||
}
|
||||
false => {
|
||||
$scrot.stdout | save $filename
|
||||
notify $"Shot selection and saved it to:\n($filename)"
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
notify "Screenshot selection cancelled"
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue