Compare commits
No commits in common. "1ac63ac1809729ce28f3cc5d729d3815f4def3d3" and "590ea9d11ff50cf51317dab948b23748f80dc7a5" have entirely different histories.
1ac63ac180
...
590ea9d11f
2 changed files with 24 additions and 94 deletions
|
@ -1,70 +1,31 @@
|
||||||
#!/usr/bin/env nu
|
#!/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) {
|
def main [input: string, --resize(-r): string, --length(-l): string = "00:00:05"] {
|
||||||
true => $"($env.HOME)/Pictures/Screenshots"
|
let resize = if ($resize | is-empty ) { "" } else { $resize }
|
||||||
false => $env.SCROTDIR
|
destroy (glitch $input $resize $length)
|
||||||
}
|
}
|
||||||
|
|
||||||
let date = ^date -Iseconds
|
def glitch [input: string, resize: string, length: string] {
|
||||||
let filename = $"($savedir)/($date)_screenshot.png"
|
let output = [ ($input | path parse | get stem ) "_glitch.mkv" ] | str join
|
||||||
|
let filter = if ($resize | is-not-empty) {
|
||||||
def notify [message: string] {
|
$"\'scale=($resize):-2,fps=60,frei0r=filter_name=glitch0r:filter_params=0.2|0.8|.04|1,rgbashift=rh=4:bh=-2,interlace=lowpass=complex\'"
|
||||||
^notify-send "Butcher" $message
|
} else {
|
||||||
|
"\'fps=60,frei0r=filter_name=glitch0r:filter_params=0.2|0.8|.04|1,rgbashift=rh=4:bh=-2,interlace=lowpass=complex\'"
|
||||||
|
}
|
||||||
|
#echo $"ffmpeg -loop 1 -i ($input) -filter_complex ($filter) -to ($length) ($output) -y"
|
||||||
|
ffmpeg -loop 1 -i $input -filter_complex $filter -to $length $output -y
|
||||||
|
echo $output
|
||||||
}
|
}
|
||||||
|
|
||||||
def clipboard [] {
|
def destroy [input: string] {
|
||||||
$in | ^pngquant - | ^xclip -sel clip -t image/png
|
let output = ($input | path parse | get stem )
|
||||||
}
|
let pngOutput = [ $output "_animated.png" ] | str join
|
||||||
|
let mp4Output = [ ($input | path parse | get stem ) "_animated.mp4" ] | str join
|
||||||
def main [--clipboard (-c)] {
|
let mp4OutputFixed = [ ($mp4Output | path parse | get stem ) "_fixed.mp4" ] | str join
|
||||||
let scrot = ^maim -ui root | complete
|
echo $"Creating destroyed png image at: ($pngOutput)"
|
||||||
match $clipboard {
|
magick -monitor $input $"APNG:($pngOutput)"
|
||||||
true => {
|
echo $"Creating video at: ($mp4Output)"
|
||||||
$scrot.stdout | clipboard
|
ffmpeg -i $pngOutput -vcodec libx265 -pix_fmt yuva420p $mp4Output -y
|
||||||
notify "Shot entire screen and tossed the output to the clipboard"
|
echo $"Fixing video at: ($mp4OutputFixed)"
|
||||||
}
|
ffmpeg -i $mp4Output $mp4OutputFixed -y
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
#!/usr/bin/env nu
|
|
||||||
|
|
||||||
def main [input: string, --resize(-r): string, --length(-l): string = "00:00:05"] {
|
|
||||||
let resize = if ($resize | is-empty ) { "" } else { $resize }
|
|
||||||
destroy (glitch $input $resize $length)
|
|
||||||
}
|
|
||||||
|
|
||||||
def glitch [input: string, resize: string, length: string] {
|
|
||||||
let output = [ ($input | path parse | get stem ) "_glitch.mkv" ] | str join
|
|
||||||
let filter = if ($resize | is-not-empty) {
|
|
||||||
$"scale=($resize):-2,fps=60,frei0r=filter_name=glitch0r:filter_params=0.2|0.8|.04|1,rgbashift=rh=4:bh=-2,interlace=lowpass=complex"
|
|
||||||
} else {
|
|
||||||
"fps=60,frei0r=filter_name=glitch0r:filter_params=0.2|0.8|.04|1,rgbashift=rh=4:bh=-2,interlace=lowpass=complex"
|
|
||||||
}
|
|
||||||
#echo $"ffmpeg -loop 1 -i ($input) -filter_complex ($filter) -to ($length) ($output) -y"
|
|
||||||
ffmpeg -loop 1 -i $input -filter_complex $filter -to $length $output -y
|
|
||||||
echo $output
|
|
||||||
}
|
|
||||||
|
|
||||||
def destroy [input: string] {
|
|
||||||
let output = ($input | path parse | get stem )
|
|
||||||
let pngOutput = [ $output "_animated.png" ] | str join
|
|
||||||
let mp4Output = [ ($input | path parse | get stem ) "_animated.mp4" ] | str join
|
|
||||||
let mp4OutputFixed = [ ($mp4Output | path parse | get stem ) "_fixed.mp4" ] | str join
|
|
||||||
echo $"Creating destroyed png image at: ($pngOutput)"
|
|
||||||
magick -monitor $input $"APNG:($pngOutput)"
|
|
||||||
echo $"Creating video at: ($mp4Output)"
|
|
||||||
ffmpeg -i $pngOutput -vcodec libx265 -pix_fmt yuva420p $mp4Output -y
|
|
||||||
echo $"Fixing video at: ($mp4OutputFixed)"
|
|
||||||
ffmpeg -i $mp4Output $mp4OutputFixed -y
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue