degoogle: Add the script
This script will convert WebP to PNG and WebM to MP4. Added custom action for Thunar as well.
This commit is contained in:
parent
34f61bfc58
commit
0adb282700
|
|
@ -12,4 +12,16 @@
|
||||||
<startup-notify/>
|
<startup-notify/>
|
||||||
<directories/>
|
<directories/>
|
||||||
</action>
|
</action>
|
||||||
|
<action>
|
||||||
|
<icon>gtk-convert</icon>
|
||||||
|
<name>Degoogle</name>
|
||||||
|
<submenu></submenu>
|
||||||
|
<unique-id>1685216951025684-1</unique-id>
|
||||||
|
<command>~/.scripts/degoogle %F</command>
|
||||||
|
<description>Convert WebP and WebM to PNG and MP4 respectively</description>
|
||||||
|
<range>*</range>
|
||||||
|
<patterns>*.webp;*.webm</patterns>
|
||||||
|
<image-files/>
|
||||||
|
<video-files/>
|
||||||
|
</action>
|
||||||
</actions>
|
</actions>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env fish
|
||||||
|
|
||||||
|
for filename in $argv
|
||||||
|
switch $filename
|
||||||
|
case '*.webp'
|
||||||
|
set -l basename (basename $filename)
|
||||||
|
set -l dirname (dirname $filename)
|
||||||
|
set -l rootname (echo $basename | string split -f 1 -m 1 -r .)
|
||||||
|
set targetname "$dirname/$rootname.png"
|
||||||
|
|
||||||
|
set attempt 0
|
||||||
|
while test $attempt -le 200
|
||||||
|
if test -f $targetname
|
||||||
|
set attempt (math $attempt + 1)
|
||||||
|
set targetname "$dirname/$rootname-$attempt.png"
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
convert "$filename" "$targetname"
|
||||||
|
break
|
||||||
|
end
|
||||||
|
case '*.webm'
|
||||||
|
set -l basename (basename $filename)
|
||||||
|
set -l dirname (dirname $filename)
|
||||||
|
set -l rootname (echo $basename | string split -f 1 -m 1 -r .)
|
||||||
|
set -l targetname "$dirname/$rootname.mp4"
|
||||||
|
|
||||||
|
ffmpeg -i $filename -c:v libx264 -crf 24 $targetname
|
||||||
|
case '*'
|
||||||
|
echo "Neither webp nor webm, skipping."
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue